ImageEditor.st
changeset 1930 7b5ec69e6526
parent 1929 13237e16b048
child 1931 34b208e7231f
equal deleted inserted replaced
1929:13237e16b048 1930:7b5ec69e6526
  3134 !ImageEditor methodsFor:'data access'!
  3134 !ImageEditor methodsFor:'data access'!
  3135 
  3135 
  3136 atColor:aOldColor put:newColor
  3136 atColor:aOldColor put:newColor
  3137     "a color changed to a new color
  3137     "a color changed to a new color
  3138     "
  3138     "
  3139     |index list oldColor image newImage|
  3139     |index list oldColor image newImage oldSel|
  3140 
  3140 
  3141     list  := self listOfColors.
  3141     list  := self listOfColors.
  3142     index := list identityIndexOf:aOldColor.
  3142     index := list identityIndexOf:aOldColor.
  3143 
  3143 
       
  3144     oldSel := self selectionOfColor value.
  3144     index ~~ 0 ifTrue:[
  3145     index ~~ 0 ifTrue:[
  3145         oldColor := list at:index.
  3146         oldColor := list at:index.
  3146         list at:index put:newColor
  3147         list at:index put:newColor
  3147     ] ifFalse:[
  3148     ] ifFalse:[
  3148         self error:'internal error' mayProceed:true.
  3149         self error:'internal error' mayProceed:true.
  3165                 ].
  3166                 ].
  3166             imageEditView image:newImage.
  3167             imageEditView image:newImage.
  3167             imageEditView setModified.
  3168             imageEditView setModified.
  3168             self updateImage.
  3169             self updateImage.
  3169             self updateImagePreView.
  3170             self updateImagePreView.
       
  3171 
       
  3172             self selectionOfColor value:oldSel.
       
  3173             imageEditView selectedColorIndex:oldSel.
       
  3174             imageEditView selectedColor:(self listOfColors at:oldSel).
  3170         ]
  3175         ]
  3171     ].
  3176     ].
  3172 !
  3177 !
  3173 
  3178 
  3174 blueAtColor:aColor put:newBlue
  3179 blueAtColor:aColor put:newBlue
  4284             ]
  4289             ]
  4285         ]
  4290         ]
  4286     ].
  4291     ].
  4287 !
  4292 !
  4288 
  4293 
       
  4294 reduceNumberOfColors2
       
  4295     |s n anyChange img usedColors|
       
  4296 
       
  4297     s := Dialog request:'Similarity Delta (1..) ?' initialAnswer:2.
       
  4298     s size == 0 ifTrue:[
       
  4299         self reduceNumberOfColors2.
       
  4300         ^ self
       
  4301     ].
       
  4302     n := Integer readFrom:s onError:0.
       
  4303     (n >= 1) ifFalse:[
       
  4304         Dialog warn:'Image unchanged'.
       
  4305         ^ self
       
  4306     ].
       
  4307 
       
  4308     self withExecuteCursorDo:[
       
  4309 "/        anyChange := imageEditView reduceColorResolutionBy:n.
       
  4310 "/        anyChange ifFalse:[
       
  4311 "/            Dialog warn:'Image unchanged'.
       
  4312 "/        ] ifTrue:[
       
  4313 "/            img := imageEditView image.
       
  4314 "/            imageEditView image:img.
       
  4315 "/
       
  4316 "/            self fetchImageData.
       
  4317 "/            usedColors := img usedColorsMax:10000.
       
  4318 "/            usedColors size == 10000 ifTrue:[
       
  4319 "/                Dialog information:('>= ' , usedColors size printString , ' colors used.')
       
  4320 "/            ] ifFalse:[
       
  4321 "/                Dialog information:(usedColors size printString , ' colors used.')
       
  4322 "/            ]
       
  4323 "/        ]
       
  4324     ].
       
  4325 !
       
  4326 
  4289 selectedColorIndexOrNil
  4327 selectedColorIndexOrNil
  4290     | img clrIndex|
  4328     | img clrIndex|
  4291 
  4329 
  4292     img := self image.
  4330     img := self image.
  4293     img isNil ifTrue:[
  4331     img isNil ifTrue:[