ImageEditor.st
changeset 1643 91b7ea254a3b
parent 1640 87ce36f48fbc
child 1644 df1f5a97b8e9
equal deleted inserted replaced
1642:8119edd52cf8 1643:91b7ea254a3b
    12 
    12 
    13 "{ Package: 'stx:libtool2' }"
    13 "{ Package: 'stx:libtool2' }"
    14 
    14 
    15 ToolApplicationModel subclass:#ImageEditor
    15 ToolApplicationModel subclass:#ImageEditor
    16 	instanceVariableNames:'imageEditView colorMapMode editMode mouseKeyColorMode
    16 	instanceVariableNames:'imageEditView colorMapMode editMode mouseKeyColorMode
    17 		selectedColorIndex postOpenAction imageSeqNr'
    17 		selectedColorIndex postOpenAction imageSeqNr drawingColormap'
    18 	classVariableNames:'LastDirectory LastSizeString MaskClipboard LastColormapMode
    18 	classVariableNames:'LastDirectory LastSizeString MaskClipboard LastColormapMode
    19 		DefaultRelativeSizes'
    19 		DefaultRelativeSizes'
    20 	poolDictionaries:''
    20 	poolDictionaries:''
    21 	category:'Interface-UIPainter'
    21 	category:'Interface-UIPainter'
    22 !
    22 !
  2496             clrIndex := aParameter.
  2496             clrIndex := aParameter.
  2497             (self hasMask) ifTrue:[
  2497             (self hasMask) ifTrue:[
  2498                 clrIndex := clrIndex - 1.
  2498                 clrIndex := clrIndex - 1.
  2499             ].
  2499             ].
  2500 
  2500 
  2501             img colorMap at:clrIndex put:(changedObject at:aParameter).
  2501             (img colorMap ? drawingColormap) at:clrIndex put:(changedObject at:aParameter).
  2502             self colorMapChanged.
  2502             self colorMapChanged.
  2503             ^ self
  2503             ^ self
  2504         ].
  2504         ].
  2505     ].
  2505     ].
  2506 
  2506 
  2987 ! !
  2987 ! !
  2988 
  2988 
  2989 !ImageEditor methodsFor:'user actions - colormap'!
  2989 !ImageEditor methodsFor:'user actions - colormap'!
  2990 
  2990 
  2991 addColorToColormap
  2991 addColorToColormap
  2992     |depth img cMap newColorMap newImage oldCListSize newMode|
  2992     |depth img cMap newColorMap newImage oldCListSize newMode listOfColors|
  2993 
  2993 
  2994     img := self image.
  2994     img := self image.
  2995     img isNil ifTrue:[
  2995     img isNil ifTrue:[
  2996         self warn:'No Image.'.
  2996         self warn:'No Image.'.
  2997         ^ self
  2997         ^ self
  2998     ].
  2998     ].
  2999 
  2999 
  3000     depth := img depth.
  3000     depth := img depth.
  3001     cMap := img colorMap.
  3001     cMap := img colorMap.
  3002     cMap isNil ifTrue:[
  3002     cMap isNil ifTrue:[
  3003         self warn:'Image has no colormap.\Change colorMap mode first.' withCRs.
  3003         drawingColormap isNil ifTrue:[
       
  3004             self information:'Image has no colormap.\The shown colorMap is for drawing only.' withCRs.
       
  3005             drawingColormap := OrderedCollection new.
       
  3006         ].
       
  3007         drawingColormap add:(Color black).
       
  3008         self listOfColors contents:drawingColormap.
       
  3009         self selectionOfColor value:(drawingColormap size).
       
  3010 
       
  3011         "/ self warn:'Image has no colormap.\Change colorMap mode first.' withCRs.
  3004         ^ self
  3012         ^ self
  3005     ].
  3013     ].
  3006 
  3014 
  3007     ("(depth == 1)" false
  3015     ("(depth == 1)" false
  3008     or:[cMap size == (1 bitShift:depth)]) ifTrue:[
  3016     or:[cMap size == (1 bitShift:depth)]) ifTrue:[
  3021     ] ifFalse:[
  3029     ] ifFalse:[
  3022         imageEditView makeUndo.
  3030         imageEditView makeUndo.
  3023     ].
  3031     ].
  3024 
  3032 
  3025     cMap := cMap asArray.
  3033     cMap := cMap asArray.
  3026     oldCListSize := self listOfColors size.
  3034     listOfColors := self listOfColors.
       
  3035     oldCListSize := listOfColors size.
  3027 
  3036 
  3028 "/    (colorMapMode value asString endsWith:'mask') ifTrue:[
  3037 "/    (colorMapMode value asString endsWith:'mask') ifTrue:[
  3029 "/        cMap last = Color noColor ifTrue:[
  3038 "/        cMap last = Color noColor ifTrue:[
  3030 "/            cMap := cMap copyWithoutLast:1
  3039 "/            cMap := cMap copyWithoutLast:1
  3031 "/        ] ifFalse:[
  3040 "/        ] ifFalse:[
  3047     newImage colorMap:newColorMap.  
  3056     newImage colorMap:newColorMap.  
  3048     newImage fileName:img fileName.
  3057     newImage fileName:img fileName.
  3049     newImage mask:(img mask copy).
  3058     newImage mask:(img mask copy).
  3050 
  3059 
  3051     (imageEditView image:newImage) notNil ifTrue:[
  3060     (imageEditView image:newImage) notNil ifTrue:[
  3052         self listOfColors contents: newImage colorMap.
  3061         listOfColors contents: newImage colorMap.
  3053         self findColorMapMode.
  3062         self findColorMapMode.
  3054         "/ mhmh - somehow, we get two colors added ... (sigh findColorMapMode adds another one ...)
  3063         "/ mhmh - somehow, we get two colors added ... (sigh findColorMapMode adds another one ...)
  3055         self listOfColors size > (oldCListSize + 1) ifTrue:[
  3064         listOfColors size > (oldCListSize + 1) ifTrue:[
  3056             self listOfColors removeLast
  3065             listOfColors removeLast
  3057         ].
  3066         ].
  3058         self selectionOfColor value:(self listOfColors size).
  3067         self selectionOfColor value:(listOfColors size).
  3059         self updateLabelsAndHistory.
  3068         self updateLabelsAndHistory.
  3060     ]
  3069     ]
  3061 
  3070 
  3062     "Created: / 12.3.1999 / 00:20:28 / cg"
  3071     "Created: / 12.3.1999 / 00:20:28 / cg"
  3063     "Modified: / 16.3.1999 / 21:57:26 / cg"
  3072     "Modified: / 16.3.1999 / 21:57:26 / cg"