--- a/ImageEditor.st Wed Jun 09 12:08:14 2004 +0200
+++ b/ImageEditor.st Wed Jun 09 17:02:42 2004 +0200
@@ -1609,6 +1609,34 @@
)
(MenuItem
enabled: hasColormap
+ label: 'Cut Color'
+ itemValue: cutColorFromColormap
+ translateLabel: true
+ isVisible: false
+ )
+ (MenuItem
+ enabled: hasColormap
+ label: 'Copy Color'
+ itemValue: copyColorFromColormap
+ translateLabel: true
+ )
+ (MenuItem
+ enabled: hasColormap
+ label: 'Pick Color'
+ itemValue: pickColor
+ translateLabel: true
+ )
+ (MenuItem
+ enabled: hasColormap
+ label: 'Paste Color'
+ itemValue: pasteColorIntoColormap
+ translateLabel: true
+ )
+ (MenuItem
+ label: '-'
+ )
+ (MenuItem
+ enabled: hasColormap
label: 'Brighter'
itemValue: makeSelectedColorBrighter
translateLabel: true
@@ -3933,6 +3961,10 @@
"Modified: / 15.9.1998 / 17:53:32 / cg"
!
+copyColorFromColormap
+ imageEditView setSelection:(self selectedColorOrNil)
+!
+
copyMask
|mask|
@@ -4034,6 +4066,20 @@
self processSelectedColorWith:[:clr | clr darkened]
!
+pasteColorIntoColormap
+ |copyBufferColor|
+
+ copyBufferColor := imageEditView getSelection.
+ copyBufferColor isColor ifFalse:[
+ device beep.
+ ^ self
+ ].
+
+ self processSelectedColorWith:[:clr |
+ copyBufferColor
+ ]
+!
+
pasteMask
|img mask|
@@ -4058,8 +4104,15 @@
self addColorToColormap:(Color fromUser)
!
+pickColor
+ imageEditView setSelection:(Color fromUser)
+!
+
processSelectedColorWith:aBlock
- |img cMap modifiedColormap clr newImage selectedColorIndex oldSelection|
+ "undoable color processing: the selected color will be replaced by the
+ value of aBlock"
+
+ |img cMap modifiedColormap oldColor newImage selectedColorIndex oldSelection newColor|
selectedColorIndex := self selectedColorIndexOrNil.
selectedColorIndex isNil ifTrue:[^ self].
@@ -4067,14 +4120,17 @@
img := self image.
cMap := img colorMap.
cMap isNil ifTrue:[
- self warn:'Image has no colormap\change colorMap mode first.' withCRs.
+ self warn:('Image has no colormap.\Please change the colorMap mode first.' withCRs).
^ self
].
+
+ oldColor := cMap at:selectedColorIndex.
imageEditView makeUndo.
modifiedColormap := cMap asArray copy.
- clr := modifiedColormap at:selectedColorIndex.
- modifiedColormap at:selectedColorIndex put:(aBlock value:clr).
+
+ newColor := aBlock value:oldColor.
+ modifiedColormap at:selectedColorIndex put:(aBlock value:oldColor).
newImage := img species new
width:img width
@@ -4090,9 +4146,6 @@
(imageEditView image:newImage) notNil ifTrue:[
self fetchImageData.
-"/ self listOfColors contents: newImage colorMap.
-"/ self findColorMapMode.
-"/ self updateLabelsAndHistory.
].
self selectionOfColor value:oldSelection.
@@ -4149,6 +4202,22 @@
^ clrIndex
!
+selectedColorOrNil
+ |img cMap|
+
+ selectedColorIndex := self selectedColorIndexOrNil.
+ selectedColorIndex isNil ifTrue:[^ self].
+
+ img := self image.
+ cMap := img colorMap.
+ cMap isNil ifTrue:[
+ self warn:('Image has no colormap.\Please change the colorMap mode first.' withCRs).
+ ^ self
+ ].
+
+ ^ cMap at:selectedColorIndex.
+!
+
sortColorMap
"calculates a new color map for the image, sorting colors"