329 'The color associated to the left mouse button.\Also the color used in fill operations' |
329 'The color associated to the left mouse button.\Also the color used in fill operations' |
330 |
330 |
331 #drawingColor2 |
331 #drawingColor2 |
332 'The color associated to the right mouse button.\Also the second color used in gradient fill operations' |
332 'The color associated to the right mouse button.\Also the second color used in gradient fill operations' |
333 |
333 |
|
334 #drawingAlpha |
|
335 'The alpha value to be used in edit operations.\If the "mask"-color is selected, only the alpha value will be changed.\Otherwise, the selected color plus this alpha value will be used for drawing' |
|
336 |
334 #autoCropAll |
337 #autoCropAll |
335 'Find and remove all borders' |
338 'Find and remove all borders' |
336 |
339 |
337 #autoCropBottom |
340 #autoCropBottom |
338 'Find and remove bottom border' |
341 'Find and remove bottom border' |
2469 name: 'MouseButtonColorToolBar' |
2472 name: 'MouseButtonColorToolBar' |
2470 layout: (LayoutFrame 0 0.0 0 0 0 1.0 24 0) |
2473 layout: (LayoutFrame 0 0.0 0 0 0 1.0 24 0) |
2471 level: 0 |
2474 level: 0 |
2472 menu: menuMouseButtonColors |
2475 menu: menuMouseButtonColors |
2473 ) |
2476 ) |
|
2477 (LabelSpec |
|
2478 label: 'Label' |
|
2479 name: 'Label1' |
|
2480 layout: (LayoutFrame -160 1 0 0 -104 1 22 0) |
|
2481 translateLabel: true |
|
2482 labelChannel: alphaText |
|
2483 visibilityChannel: alphaVisibleHolder |
|
2484 activeHelpKey: drawingAlpha |
|
2485 ) |
|
2486 (InputFieldSpec |
|
2487 name: 'EntryField1' |
|
2488 layout: (LayoutFrame -106 1 2 0 -56 1 22 0) |
|
2489 acceptOnReturn: true |
|
2490 acceptOnTab: true |
|
2491 acceptOnPointerLeave: true |
|
2492 visibilityChannel: alphaVisibleHolder |
|
2493 activeHelpKey: drawingAlpha |
|
2494 model: alphaHolder |
|
2495 type: numberInRange |
|
2496 numChars: 3 |
|
2497 minValue: 0 |
|
2498 maxValue: 100 |
|
2499 ) |
2474 (ViewSpec |
2500 (ViewSpec |
2475 name: 'Box1' |
2501 name: 'Box1' |
2476 layout: (LayoutFrame -40 1.0 4 0 -26 1.0 18 0) |
2502 layout: (LayoutFrame -40 1.0 4 0 -26 1.0 18 0) |
2477 activeHelpKey: drawingColor1 |
2503 activeHelpKey: drawingColor1 |
2478 level: -1 |
2504 level: -1 |
4294 ^ self infoLabelHolder |
4322 ^ self infoLabelHolder |
4295 |
4323 |
4296 "Modified: / 29.7.1998 / 18:49:03 / cg" |
4324 "Modified: / 29.7.1998 / 18:49:03 / cg" |
4297 ! |
4325 ! |
4298 |
4326 |
|
4327 alphaHolder |
|
4328 |holder| |
|
4329 |
|
4330 (holder := builder bindingAt:#alphaHolder) isNil ifTrue:[ |
|
4331 builder aspectAt:#alphaHolder put:(holder := 100 asValue). |
|
4332 holder onChangeEvaluate:[ imageEditView drawingAlpha:holder value ]. |
|
4333 ]. |
|
4334 ^ holder |
|
4335 |
|
4336 "Created: / 05-09-2017 / 00:38:14 / cg" |
|
4337 "Modified: / 05-09-2017 / 10:35:25 / cg" |
|
4338 ! |
|
4339 |
|
4340 alphaText |
|
4341 ^ 'alpha:' |
|
4342 |
|
4343 "Created: / 05-09-2017 / 00:32:55 / cg" |
|
4344 ! |
|
4345 |
|
4346 alphaVisibleHolder |
|
4347 |holder| |
|
4348 |
|
4349 (holder := builder bindingAt:#alphaVisibleHolder) isNil ifTrue:[ |
|
4350 builder aspectAt:#alphaVisibleHolder put:(holder := false asValue). |
|
4351 ]. |
|
4352 ^ holder |
|
4353 |
|
4354 "Created: / 05-09-2017 / 00:35:36 / cg" |
|
4355 ! |
|
4356 |
4299 canAddColorToColormap |
4357 canAddColorToColormap |
4300 |img| |
4358 |img| |
4301 |
4359 |
4302 img := self image. |
4360 img := self image. |
4303 img isNil ifTrue:[^ false]. |
4361 img isNil ifTrue:[^ false]. |
4870 ]. |
4928 ]. |
4871 newListOfColors notEmptyOrNil ifTrue:[ |
4929 newListOfColors notEmptyOrNil ifTrue:[ |
4872 drawColor1 := newListOfColors at:1. |
4930 drawColor1 := newListOfColors at:1. |
4873 drawColor2 := newListOfColors at:2 ifAbsent:drawColor1. |
4931 drawColor2 := newListOfColors at:2 ifAbsent:drawColor1. |
4874 |
4932 |
4875 self hasMask ifTrue: [ |
4933 self hasTransparentColorInColorList ifTrue: [ |
4876 (newListOfColors includes:(Color colorId:0)) ifFalse:[ |
4934 (newListOfColors includes:(Color colorId:0)) ifFalse:[ |
4877 newListOfColors addFirst:(Color colorId:0). |
4935 newListOfColors addFirst:(Color colorId:0). |
4878 drawColor1 := newListOfColors at:2. |
4936 drawColor1 := newListOfColors at:2. |
4879 drawColor2 := newListOfColors at:3 ifAbsent:drawColor1. |
4937 drawColor2 := newListOfColors at:3 ifAbsent:drawColor1. |
4880 ] |
4938 ] |
4886 ]. |
4944 ]. |
4887 self listOfColors asOrderedCollection ~= newListOfColors ifTrue:[ |
4945 self listOfColors asOrderedCollection ~= newListOfColors ifTrue:[ |
4888 self listOfColors contents:newListOfColors. |
4946 self listOfColors contents:newListOfColors. |
4889 ]. |
4947 ]. |
4890 |
4948 |
4891 "Modified: / 06-04-2017 / 13:20:10 / cg" |
4949 "Modified: / 05-09-2017 / 09:03:31 / cg" |
4892 ! |
4950 ! |
4893 |
4951 |
4894 selectedColorsChanged |
4952 selectedColorsChanged |
4895 |colorIndices selectedIndex| |
4953 |colorIndices selectedIndex| |
4896 |
4954 |
4930 changedObject == self listOfColors ifTrue:[ |
4988 changedObject == self listOfColors ifTrue:[ |
4931 something == #at: ifTrue:[ |
4989 something == #at: ifTrue:[ |
4932 "/ colormap entry changed at aParameter |
4990 "/ colormap entry changed at aParameter |
4933 |
4991 |
4934 clrIndex := aParameter. |
4992 clrIndex := aParameter. |
4935 (self hasMask) ifTrue:[ |
4993 (self hasTransparentColorInColorList) ifTrue:[ |
4936 clrIndex := clrIndex - 1. |
4994 clrIndex := clrIndex - 1. |
4937 ]. |
4995 ]. |
4938 changedColor := changedObject at:aParameter. |
4996 changedColor := changedObject at:aParameter. |
4939 cMap := image colorMap. |
4997 cMap := image colorMap. |
4940 (cMap notNil and:[cMap isFixedPalette not]) ifTrue:[ |
4998 (cMap notNil and:[cMap isFixedPalette not]) ifTrue:[ |
4990 ]. |
5048 ]. |
4991 something == #selectedColor ifTrue:[ |
5049 something == #selectedColor ifTrue:[ |
4992 (aParameter isNil or:[aParameter = (Color colorId:0)]) ifTrue:[ |
5050 (aParameter isNil or:[aParameter = (Color colorId:0)]) ifTrue:[ |
4993 "/ no color/mask */ |
5051 "/ no color/mask */ |
4994 "/ self halt. |
5052 "/ self halt. |
4995 clrIndex := self hasMask ifTrue:[1] ifFalse:[0]. |
5053 clrIndex := self hasTransparentColorInColorList ifTrue:[1] ifFalse:[0]. |
4996 ] ifFalse:[ |
5054 ] ifFalse:[ |
4997 clrIndex := self listOfColors indexOf:aParameter. |
5055 clrIndex := self listOfColors indexOf:aParameter. |
4998 ]. |
5056 ]. |
4999 self selectedColors value:{clrIndex}. "/ selectionOfColor value:clrIndex. |
5057 self selectedColors value:{clrIndex}. "/ selectionOfColor value:clrIndex. |
5000 ^ self. |
5058 ^ self. |
5031 imageSeqNr := 1 |
5089 imageSeqNr := 1 |
5032 ]. |
5090 ]. |
5033 self imageHasImageSequenceHolder value:(self imageHasImageSequence). |
5091 self imageHasImageSequenceHolder value:(self imageHasImageSequence). |
5034 self imageHasNextImageHolder value:(self imageHasNextImage). |
5092 self imageHasNextImageHolder value:(self imageHasNextImage). |
5035 self imageHasPreviousImageHolder value:(self imageHasPreviousImage). |
5093 self imageHasPreviousImageHolder value:(self imageHasPreviousImage). |
|
5094 self alphaVisibleHolder value:(img hasAlphaChannel) |
5036 ] ifFalse:[ |
5095 ] ifFalse:[ |
5037 self updateForNoImage |
5096 self updateForNoImage |
5038 ] |
5097 ] |
5039 |
5098 |
5040 "Modified: / 21-10-2010 / 14:40:45 / cg" |
5099 "Modified: / 05-09-2017 / 00:44:10 / cg" |
5041 ! |
5100 ! |
5042 |
5101 |
5043 updateColorsFromImage:image |
5102 updateColorsFromImage:image |
5044 |colors depth| |
5103 |colors depth| |
5045 |
5104 |
5075 |
5134 |
5076 self imageIsLoadedHolder value: false. |
5135 self imageIsLoadedHolder value: false. |
5077 self listOfColors removeAll. |
5136 self listOfColors removeAll. |
5078 self imagePreView image: nil. |
5137 self imagePreView image: nil. |
5079 self imageHasImageSequenceHolder value:false. |
5138 self imageHasImageSequenceHolder value:false. |
5080 |
5139 self alphaVisibleHolder value:false. |
5081 "Modified: / 21-10-2010 / 14:39:13 / cg" |
5140 |
|
5141 "Modified: / 05-09-2017 / 00:44:20 / cg" |
5082 ! |
5142 ! |
5083 |
5143 |
5084 updateLabelsAndHistory |
5144 updateLabelsAndHistory |
5085 "updates labels and history, if something has changed" |
5145 "updates labels and history, if something has changed" |
5086 |
5146 |
5104 |
5164 |
5105 "Modified: / 01-09-2017 / 10:10:12 / cg" |
5165 "Modified: / 01-09-2017 / 10:10:12 / cg" |
5106 ! |
5166 ! |
5107 |
5167 |
5108 updateListOfColorsAndColormapMode |
5168 updateListOfColorsAndColormapMode |
5109 |selectedColor colorMap image| |
5169 |listOfColors selectedColor colorMap image| |
5110 |
5170 |
5111 selectedColor := self selectedColorOrNil. |
5171 selectedColor := self selectedColorOrNil. |
5112 |
5172 listOfColors := self listOfColors. |
|
5173 |
5113 image := self image. |
5174 image := self image. |
5114 image isNil ifTrue:[ |
5175 image isNil ifTrue:[ |
5115 self listOfColors removeAll. |
5176 listOfColors removeAll. |
5116 ] ifFalse:[ |
5177 ] ifFalse:[ |
5117 colorMap := image colorMap. |
5178 colorMap := image colorMap. |
5118 colorMap notNil ifTrue:[ |
5179 colorMap notNil ifTrue:[ |
5119 (colorMap size <= 4096) ifTrue:[ |
5180 (colorMap size <= 4096) ifTrue:[ |
5120 image mask notNil ifTrue:[ |
5181 (image mask notNil or:[image hasAlphaChannel]) ifTrue:[ |
5121 colorMap := (Array with:(Color noColor)),colorMap. |
5182 colorMap := (Array with:(Color noColor)),colorMap. |
5122 ]. |
5183 ]. |
5123 self listOfColors contents:colorMap. |
5184 listOfColors contents:colorMap. |
5124 ] ifFalse:[ |
5185 ] ifFalse:[ |
5125 self listOfColors removeAll. |
5186 listOfColors removeAll. |
5126 colorMap isFixedPalette ifTrue:[ |
5187 colorMap isFixedPalette ifTrue:[ |
5127 image colorMap:nil. |
5188 image colorMap:nil. |
5128 image photometric:#rgb. |
5189 image photometric:#rgb. |
5129 image samplesPerPixel:3. |
5190 image samplesPerPixel:3. |
5130 |
5191 |
5138 ]. |
5199 ]. |
5139 self findColorMapMode. |
5200 self findColorMapMode. |
5140 selectedColor notNil ifTrue:[ |
5201 selectedColor notNil ifTrue:[ |
5141 self selectColor:selectedColor. |
5202 self selectColor:selectedColor. |
5142 ]. |
5203 ]. |
|
5204 |
|
5205 "Modified: / 05-09-2017 / 08:25:14 / cg" |
5143 ! ! |
5206 ! ! |
5144 |
5207 |
5145 !ImageEditor methodsFor:'data access'! |
5208 !ImageEditor methodsFor:'data access'! |
5146 |
5209 |
5147 atColor:anOldColor put:newColor |
5210 atColor:anOldColor put:newColor |
5769 invalidate. |
5832 invalidate. |
5770 ! ! |
5833 ! ! |
5771 |
5834 |
5772 !ImageEditor methodsFor:'queries'! |
5835 !ImageEditor methodsFor:'queries'! |
5773 |
5836 |
|
5837 hasAlphaChannel |
|
5838 |img| |
|
5839 |
|
5840 img := self image. |
|
5841 img isNil ifTrue:[^ false]. |
|
5842 ^ img hasAlphaChannel |
|
5843 |
|
5844 "Created: / 05-09-2017 / 08:29:23 / cg" |
|
5845 ! |
|
5846 |
5774 hasLastGrabScreenArea |
5847 hasLastGrabScreenArea |
5775 ^ [ lastGrabbedScreenArea notNil ] |
5848 ^ [ lastGrabbedScreenArea notNil ] |
5776 ! |
5849 ! |
5777 |
5850 |
5778 hasMask |
5851 hasMask |
5779 self image isNil ifTrue:[^ false]. |
5852 |img| |
5780 self image mask isNil ifTrue:[^ false]. |
5853 |
|
5854 img := self image. |
|
5855 img isNil ifTrue:[^ false]. |
|
5856 img mask isNil ifTrue:[^ false]. |
5781 ^ colorMapMode value notNil and:[colorMapMode value startsWith:'mask'] |
5857 ^ colorMapMode value notNil and:[colorMapMode value startsWith:'mask'] |
5782 |
5858 |
5783 "Created: / 18-08-1998 / 17:17:38 / cg" |
5859 "Created: / 18-08-1998 / 17:17:38 / cg" |
5784 "Modified: / 18-02-2017 / 00:40:25 / cg" |
5860 "Modified: / 05-09-2017 / 08:28:44 / cg" |
5785 ! |
5861 ! |
5786 |
5862 |
5787 hasMaskHolder |
5863 hasMaskHolder |
5788 ^ [ self hasMask ] |
5864 ^ [ self hasMask ] |
5789 |
5865 |
5790 "Created: / 18-02-2017 / 00:41:19 / cg" |
5866 "Created: / 18-02-2017 / 00:41:19 / cg" |
|
5867 ! |
|
5868 |
|
5869 hasTransparentColorInColorList |
|
5870 ^ self hasMask or:[self hasAlphaChannel] |
|
5871 |
|
5872 "Created: / 05-09-2017 / 09:03:24 / cg" |
5791 ! |
5873 ! |
5792 |
5874 |
5793 modified |
5875 modified |
5794 "true if the image was modified" |
5876 "true if the image was modified" |
5795 |
5877 |
5908 (builder componentAt:#infoBarSubSpec) beInvisible |
5990 (builder componentAt:#infoBarSubSpec) beInvisible |
5909 ] |
5991 ] |
5910 ! |
5992 ! |
5911 |
5993 |
5912 open |
5994 open |
5913 "after opening, sets the masterApplication of the imageEditView to self" |
5995 "after opening, gets the imageEditView" |
5914 |
5996 |
5915 super open. |
5997 super open. |
5916 |
5998 |
5917 imageEditView := (self componentAt: #imageEditView) subViews first. |
5999 imageEditView := (self componentAt: #imageEditView) subViews first. |
|
6000 |
|
6001 "Modified (comment): / 05-09-2017 / 10:39:45 / cg" |
5918 ! |
6002 ! |
5919 |
6003 |
5920 postOpenWith:aBuilder |
6004 postOpenWith:aBuilder |
5921 "after opening, sets the masterApplication of the imageEditView to self; |
6005 "after opening, sets the masterApplication of the imageEditView to self; |
5922 evaluate the postOpenAction" |
6006 evaluate the postOpenAction" |
5929 self windowGroup addPreEventHook:self. |
6013 self windowGroup addPreEventHook:self. |
5930 self colorCropTabSelectionIndexChanged. |
6014 self colorCropTabSelectionIndexChanged. |
5931 |
6015 |
5932 self drawingColor1Holder valueHolder:(imageEditView drawingColorHolders at:1). |
6016 self drawingColor1Holder valueHolder:(imageEditView drawingColorHolders at:1). |
5933 self drawingColor2Holder valueHolder:(imageEditView drawingColorHolders at:2). |
6017 self drawingColor2Holder valueHolder:(imageEditView drawingColorHolders at:2). |
5934 |
6018 imageEditView drawingAlpha:(self alphaHolder value). |
5935 "Modified: / 23-02-2017 / 10:19:27 / cg" |
6019 |
|
6020 "Modified (format): / 05-09-2017 / 10:40:10 / cg" |
5936 ! ! |
6021 ! ! |
5937 |
6022 |
5938 !ImageEditor methodsFor:'user actions-colormap'! |
6023 !ImageEditor methodsFor:'user actions-colormap'! |
5939 |
6024 |
5940 addColorToColormap |
6025 addColorToColormap |
6886 |cMap colors cmapOffset| |
6971 |cMap colors cmapOffset| |
6887 |
6972 |
6888 cMap := self image colorMap. |
6973 cMap := self image colorMap. |
6889 |
6974 |
6890 "/ if there is a mask, it is at position 1 in the table |
6975 "/ if there is a mask, it is at position 1 in the table |
6891 cmapOffset := self hasMask ifTrue:[1] ifFalse:[0]. |
6976 cmapOffset := self hasTransparentColorInColorList ifTrue:[1] ifFalse:[0]. |
6892 colors := self selectedColors value collect:[:idx | cMap at:idx-cmapOffset]. |
6977 colors := self selectedColors value collect:[:idx | cMap at:idx-cmapOffset]. |
6893 self changeHLSOfColors:colors. |
6978 self changeHLSOfColors:colors. |
6894 |
6979 |
6895 "Modified: / 31-08-2017 / 14:15:03 / cg" |
6980 "Modified: / 05-09-2017 / 09:03:47 / cg" |
6896 ! |
6981 ! |
6897 |
6982 |
6898 makeSlightlyBrighter |
6983 makeSlightlyBrighter |
6899 self updateImageAfterDoing:#makeSlightlyBrighter. |
6984 self updateImageAfterDoing:#makeSlightlyBrighter. |
6900 |
6985 |
7112 (imageEditView image:newImage) notNil ifTrue:[ |
7197 (imageEditView image:newImage) notNil ifTrue:[ |
7113 self fetchImageData. |
7198 self fetchImageData. |
7114 ]. |
7199 ]. |
7115 self selectedColors value:selectedColorIndices. |
7200 self selectedColors value:selectedColorIndices. |
7116 |
7201 |
7117 "Modified: / 22-02-2017 / 19:45:29 / cg" |
7202 "Modified: / 05-09-2017 / 09:03:52 / cg" |
7118 ! |
7203 ! |
7119 |
7204 |
7120 reduceNumberOfColors |
7205 reduceNumberOfColors |
7121 "reduce by masking off r/g/b bits" |
7206 "reduce by masking off r/g/b bits" |
7122 |
7207 |
7268 img isNil ifTrue:[ |
7353 img isNil ifTrue:[ |
7269 "/ self warn:'No Image.'. |
7354 "/ self warn:'No Image.'. |
7270 ^ nil |
7355 ^ nil |
7271 ]. |
7356 ]. |
7272 clrIndex := self selectionOfColor value. |
7357 clrIndex := self selectionOfColor value. |
7273 self hasMask "img mask notNil" ifTrue: [ |
7358 self hasTransparentColorInColorList ifTrue: [ |
7274 (clrIndex isInteger and:[clrIndex > 1]) ifTrue:[ |
7359 (clrIndex isInteger and:[clrIndex > 1]) ifTrue:[ |
7275 ^ clrIndex - 1 |
7360 ^ clrIndex - 1 |
7276 ]. |
7361 ]. |
7277 ^ nil |
7362 ^ nil |
7278 ]. |
7363 ]. |
7279 ^ clrIndex |
7364 ^ clrIndex |
|
7365 |
|
7366 "Modified: / 05-09-2017 / 09:04:05 / cg" |
7280 ! |
7367 ! |
7281 |
7368 |
7282 selectedColorOrNil |
7369 selectedColorOrNil |
7283 |cmapIndex img cMap colorList| |
7370 |cmapIndex img cMap colorList| |
7284 |
7371 |