ImageEditor.st
changeset 1896 ab2b45d8ccc8
parent 1889 c40aa7b4d59c
child 1899 f7d3fd244804
equal deleted inserted replaced
1895:b7d6683ebaca 1896:ab2b45d8ccc8
  1816                   label: 'Browse Class'
  1816                   label: 'Browse Class'
  1817                   itemValue: doBrowseClass
  1817                   itemValue: doBrowseClass
  1818                   translateLabel: true
  1818                   translateLabel: true
  1819                 )
  1819                 )
  1820                (MenuItem
  1820                (MenuItem
       
  1821                   label: 'Inspect Image'
       
  1822                   itemValue: doInspectImage
       
  1823                   translateLabel: true
       
  1824                 )
       
  1825                (MenuItem
  1821                   label: '-'
  1826                   label: '-'
  1822                 )
  1827                 )
  1823                (MenuItem
  1828                (MenuItem
  1824                   activeHelpKey: fileExit
  1829                   activeHelpKey: fileExit
  1825                   label: 'Exit'
  1830                   label: 'Exit'
  2822 
  2827 
  2823     "Created: / 31.7.1998 / 02:04:18 / cg"
  2828     "Created: / 31.7.1998 / 02:04:18 / cg"
  2824 !
  2829 !
  2825 
  2830 
  2826 listOfColors
  2831 listOfColors
  2827     "returns the list of colors in a List"
  2832     "returns the list of colors"
  2828 
  2833 
  2829     |holder|
  2834     |list|
  2830     (holder := builder bindingAt:#listOfColors) isNil ifTrue:[
  2835 
  2831         builder aspectAt:#listOfColors put:(holder :=  List new).
  2836     (list := builder bindingAt:#listOfColors) isNil ifTrue:[
  2832         holder addDependent:self.
  2837         builder aspectAt:#listOfColors put:(list :=  List new).
  2833     ].
  2838         list addDependent:self.
  2834     ^ holder
  2839     ].
       
  2840     ^ list
  2835 !
  2841 !
  2836 
  2842 
  2837 previewBackgroundColor
  2843 previewBackgroundColor
  2838     |holder|
  2844     |holder|
  2839     (holder := builder bindingAt:#previewBackgroundColor) isNil ifTrue:[
  2845     (holder := builder bindingAt:#previewBackgroundColor) isNil ifTrue:[
  2884     |image listOfColors colorMapModeKey|
  2890     |image listOfColors colorMapModeKey|
  2885 
  2891 
  2886     image := self image.
  2892     image := self image.
  2887 
  2893 
  2888     image mask notNil ifTrue: [             
  2894     image mask notNil ifTrue: [             
  2889         colorMapModeKey := 'masked' , image depth printString.
  2895         colorMapModeKey := 'masked'.
  2890     ] ifFalse:[
  2896     ] ifFalse:[
  2891         colorMapModeKey := 'depth' , image depth printString.
  2897         colorMapModeKey := 'depth'.
  2892     ].
  2898     ].
  2893 
  2899     colorMapModeKey := colorMapModeKey , image depth printString.
  2894     colorMapMode value:colorMapModeKey.
  2900     colorMapMode setValue:colorMapModeKey.
  2895 
  2901 
  2896     image depth > 12 ifTrue:[
  2902     image depth > 12 ifTrue:[
  2897         self listOfColors removeAll.
  2903         self listOfColors removeAll.
  2898         listOfColors := image colorMap.
  2904         listOfColors := image colorMap.
  2899         listOfColors isEmptyOrNil ifTrue:[
  2905         listOfColors isEmptyOrNil ifTrue:[
  2908     ].                               
  2914     ].                               
  2909     imageEditView drawingColors:(Array
  2915     imageEditView drawingColors:(Array
  2910                                     with: (listOfColors at:1) 
  2916                                     with: (listOfColors at:1) 
  2911                                     with: (listOfColors at:2 ifAbsent:[listOfColors at:1])).
  2917                                     with: (listOfColors at:2 ifAbsent:[listOfColors at:1])).
  2912 
  2918 
  2913     image mask notNil ifTrue: [             
  2919     self hasMask "image mask" notNil ifTrue: [             
  2914         (listOfColors detect: [:clr| clr = (Color colorId:0)] ifNone: nil) isNil
  2920         (listOfColors contains: [:clr| clr = (Color colorId:0)]) 
  2915         ifTrue:[
  2921         ifFalse:[
  2916             listOfColors addFirst:(Color colorId:0).
  2922             listOfColors addFirst:(Color colorId:0).
  2917             imageEditView drawingColors: (Array 
  2923             imageEditView drawingColors: (Array 
  2918                                             with:(listOfColors at:2 ifAbsent:[listOfColors at:1]) 
  2924                                             with: (listOfColors at:2) 
  2919                                             with:(listOfColors at:1)).
  2925                                             with: (listOfColors at:3 ifAbsent:[listOfColors at:2])).
  2920         ]
  2926         ]
  2921     ].
  2927     ].
  2922     self selectionOfColor 
  2928     self selectionOfColor 
  2923         setValue: 0;
  2929         setValue: 0;
  2924         value: (self listOfColors indexOf: imageEditView selectedColor).
  2930         value: (self listOfColors indexOf: imageEditView selectedColor).
  2949 
  2955 
  2950     changedObject == self listOfColors ifTrue:[
  2956     changedObject == self listOfColors ifTrue:[
  2951         something == #at: ifTrue:[
  2957         something == #at: ifTrue:[
  2952             "/ colormap entry changed at aParameter
  2958             "/ colormap entry changed at aParameter
  2953 
  2959 
       
  2960 self halt.
  2954             clrIndex := aParameter.
  2961             clrIndex := aParameter.
  2955             (self hasMask) ifTrue:[
  2962             (self hasMask) ifTrue:[
  2956                 clrIndex := clrIndex - 1.
  2963                 clrIndex := clrIndex - 1.
  2957             ].
  2964             ].
  2958 
  2965 
  2959             (img colorMap ? drawingColormap) at:clrIndex put:(changedObject at:aParameter).
  2966             (img colorMap ? drawingColormap) at:clrIndex put:(changedObject at:aParameter).
  2960             self colorMapChanged.
  2967             self colorMapChanged.
  2961             ^ self
  2968             ^ self
  2962         ].
  2969         ].
       
  2970         ^ self
  2963     ].
  2971     ].
  2964 
  2972 
  2965     changedObject == imageEditView undoImages ifTrue:[
  2973     changedObject == imageEditView undoImages ifTrue:[
  2966         self valueOfCanUndo value:(changedObject notEmpty).
  2974         self valueOfCanUndo value:(changedObject notEmpty).
  2967         ^ self.
  2975         ^ self.
  3268     |img|
  3276     |img|
  3269 
  3277 
  3270     (imageEditView loadFromMessage: aMessage) notNil ifTrue:[
  3278     (imageEditView loadFromMessage: aMessage) notNil ifTrue:[
  3271         (img := self image) notNil ifTrue:[
  3279         (img := self image) notNil ifTrue:[
  3272             img := img onDevice:device.
  3280             img := img onDevice:device.
  3273             self listOfColors contents:(img usedColors asSet asOrderedCollection).
  3281             img colorMap isNil ifTrue:[
  3274             self findColorMapMode.
  3282                 self listOfColors contents:(img usedColors asSet asOrderedCollection).
       
  3283             ].
       
  3284 "/            self findColorMapMode.
  3275             self updateLabelsAndHistory.
  3285             self updateLabelsAndHistory.
  3276             "/ imageEditView image:img.
  3286             "/ imageEditView image:img.
  3277         ] ifFalse:[
  3287         ] ifFalse:[
  3278             self updateForNoImage
  3288             self updateForNoImage
  3279         ]
  3289         ]
  4010 
  4020 
  4011 fetchImageData
  4021 fetchImageData
  4012     |image|
  4022     |image|
  4013 
  4023 
  4014     (image := imageEditView image) notNil ifTrue:[
  4024     (image := imageEditView image) notNil ifTrue:[
  4015         self listOfColors contents:(image colorMap).
       
  4016         self findColorMapMode.
  4025         self findColorMapMode.
  4017         self updateLabelsAndHistory.
  4026         self updateLabelsAndHistory.
  4018     ]
  4027     ]
  4019 !
  4028 !
  4020 
  4029 
  4219     img isNil ifTrue:[
  4228     img isNil ifTrue:[
  4220         self warn:'No Image.'.
  4229         self warn:'No Image.'.
  4221         ^ nil
  4230         ^ nil
  4222     ].
  4231     ].
  4223     clrIndex := self selectionOfColor value.
  4232     clrIndex := self selectionOfColor value.
  4224     img mask notNil ifTrue: [ 
  4233     self hasMask "img mask notNil" ifTrue: [ 
  4225         clrIndex == 1 ifTrue:[^ nil].
  4234         clrIndex == 1 ifTrue:[^ nil].
  4226         clrIndex := clrIndex - 1 
  4235         ^ clrIndex - 1 
  4227     ].
  4236     ].
  4228     ^ clrIndex
  4237     ^ clrIndex
  4229 !
  4238 !
  4230 
  4239 
  4231 selectedColorOrNil
  4240 selectedColorOrNil
  4232     |img cMap|
  4241     |cmapIndex img cMap|
  4233 
  4242 
  4234     selectedColorIndex := self selectedColorIndexOrNil.
  4243     cmapIndex := self selectedColorIndexOrNil.
  4235     selectedColorIndex isNil ifTrue:[^ self].
  4244     cmapIndex isNil ifTrue:[^ self].
  4236 
  4245 
  4237     img := self image.
  4246     img := self image.
  4238     cMap := img colorMap.
  4247     cMap := img colorMap.
  4239     cMap isNil ifTrue:[
  4248     cMap isNil ifTrue:[
  4240         self warn:('Image has no colormap.\Please change the colorMap mode first.' withCRs).
  4249         self warn:('Image has no colormap.\Please change the colorMap mode first.' withCRs).
  4241         ^ self
  4250         ^ self
  4242     ].
  4251     ].
  4243 
  4252     ^ cMap at:cmapIndex.
  4244     ^ cMap at:selectedColorIndex.
       
  4245 !
  4253 !
  4246 
  4254 
  4247 sortColorMap
  4255 sortColorMap
  4248     "calculates a new color map for the image, sorting colors"
  4256     "calculates a new color map for the image, sorting colors"
  4249 
  4257 
  4495     "flips vertically current image"
  4503     "flips vertically current image"
  4496 
  4504 
  4497     imageEditView flipVertical
  4505     imageEditView flipVertical
  4498 !
  4506 !
  4499 
  4507 
       
  4508 doInspectImage
       
  4509     "opens a System Browser on the resourceClass and the resourceSelector"
       
  4510 
       
  4511     self image inspect
       
  4512 !
       
  4513 
  4500 doMagnifyDown
  4514 doMagnifyDown
  4501     "magnifies current image one step down"
  4515     "magnifies current image one step down"
  4502 
  4516 
  4503     |magHolder mag|
  4517     |magHolder mag|
  4504 
  4518