ImageEditor.st
changeset 3405 02c67d9a5e65
parent 3404 cd90f4aece50
child 3407 2e0024e012e9
--- a/ImageEditor.st	Thu Feb 16 01:46:35 2017 +0100
+++ b/ImageEditor.st	Thu Feb 16 12:39:40 2017 +0100
@@ -265,275 +265,14 @@
 !ImageEditor class methodsFor:'help specs'!
 
 flyByHelpSpec
-    <resource: #help>
-
-    ^super flyByHelpSpec addPairsFrom:(self localHelpTexts)
-
-    "Modified: / 19-01-2012 / 13:29:48 / cg"
-!
-
-helpSpec
-    "This resource specification was automatically generated
-     by the UIHelpTool of ST/X."
-
-    "Do not manually edit this!! If it is corrupted,
-     the UIHelpTool may not be able to read the specification."
-
-    "
-     UIHelpTool openOnClass:ImageEditor
-    "
-
-    <resource: #help>
-
-    ^ super helpSpec addPairsFrom:#(
-
-#colorMap
-'ColorMap functions'
-
-#colorMap1
-'Convert to depth-1 image'
-
-#colorMap1M
-'Convert to depth-1 image plus mask'
-
-#colorMap2
-'Convert to depth-2 image'
-
-#colorMap24
-'Convert to depth-24 image (rgb)'
-
-#colorMap2M
-'Convert to depth-2 image plus mask'
-
-#colorMap32
-'Convert to depth-32 image (rgba)'
-
-#colorMap4
-'Convert to depth-4 image'
-
-#colorMap4M
-'Convert to depth-4 image plus mask'
-
-#colorMap8
-'Convert to depth-8 image'
-
-#colorMap8M
-'Convert to depth-8 image plus mask'
-
-#colorMapTable
-'Shows a list of used colors of the image'
-
-#compressColormap
-'Remove unneeded entries from the colorMap'
-
-#cropAll
-'Find and remove all borders'
-
-#cropBottom
-'Find and remove bottom border'
-
-#cropLeft
-'Find and remove left border'
-
-#cropManual
-'Specify border(s) to remove.'
-
-#cropRight
-'Find and remove right border'
-
-#cropTop
-'Find and remove top border'
-
-#drawModeBox
-'Rectangle Drawing Mode'
-
-#drawModeCircle
-'Circle Drawing Mode'
-
-#drawModeCopy
-'Area Copy Mode'
-
-#drawModeFill
-'Flood Fill Mode'
-
-#drawModeFilledBox
-'Filled Rectangle Drawing Mode'
-
-#drawModePaste
-'Paste Mode'
-
-#drawModePasteUnder
-'Paste-Under Mode'
-
-#drawModePasteWithMask
-'Paste-with-Mask Mode'
-
-#drawModePoint
-'Point Drawing Mode'
-
-#drawModeSpecial
-'Special operations (select rectangle, then choose operation)'
-
-#drawModeSpray
-'Spray Drawing Mode'
-
-#edit3DProjection
-''
-
-#editFlipHorizontal
-'Flip the image horizontally'
-
-#editFlipVertical
-'Flip the image vertically'
-
-#editMagnifyImage
-'Magnify the image'
-
-#editNegate
-'Invert the images colors'
-
-#editResize
-'Resize the image (preserving the old image)'
-
-#editRotate
-'Rotate the image'
-
-#fileEditMask
-''
-
-#fileGrabImageFromScreen
-'Pick an image from the screen (specify area)'
-
-#fileGrabImageFromWindow
-'Pick an image from a window on the screen (click on window)'
-
-#fileLoadFromClass
-'Select and load an image from a resource method'
-
-#fileLoadFromFile
-'Select and load an image from a file'
-
-#fileLoadFromURL
-'Load an image from the net, given its URL'
-
-#fileNewImage
-'Create a new image'
-
-#fileNewImageFromClipboard
-'Create a new image and initialize it from the clipboard'
-
-#fileNewMaskFromClipboard
-'Paste the image in the clipboard as a mask. Must be a depth-1 image'
-
-#filePrint
-'Print the image on a postscript printer'
-
-#fileSave
-'Save the image'
-
-#fileSaveAs
-'Save the image to a file'
-
-#fileSaveButtonImageAs
-'Save an image of a button with the image to a file (for html use)'
-
-#fileSaveMaskAs
-'Save the mask of the image to a file'
-
-#fileSaveMethod
-'Save the image as resource method in the current class and selector'
-
-#fileSaveMethodAs
-'Save the image as resource method in a class'
-
-#gropBottom
-'Cut off the specified number of pixels at the bottom'
-
-#gropLeft
-'Cut off the specified number of pixels at the left'
-
-#gropRight
-'Cut off the specified number of pixels at the right'
-
-#gropTop
-'Cut off the specified number of pixels at the top'
-
-#magnificationNumber
-'Shows the current magnification'
-
-#magnifyImageDown
-'Decrease magnification'
-
-#magnifyImageUp
-'Increase magnification'
-
-#mouseKeyColorMode
-'Toggle between left and right mouse button color'
-
-#nextImageInSequence
-'Go to the next image in the animated gif image sequence.'
-
-#previewView
-'Shows a preview of the image'
-
-#previousImageInSequence
-'Go to the previous image in the animated gif image sequence.'
-
-#settingsGridMagnification
-'Change the grid magnification of the edit view'
-
-#xdrawModeBox
-'Rectangle'
-
-#xdrawModeCopy
-'Copy'
-
-#xdrawModeFill
-'Flood-fill'
-
-#xdrawModeFilledBox
-'Filled rectangle'
-
-#xdrawModePaste
-'Paste'
-
-#xdrawModePasteUnder
-'Paste under'
-
-#xdrawModePasteWithMask
-'Paste with Mask'
-
-#xdrawModePoint
-'Point'
-
-#xfileGrabImage
-'Pick from screen'
-
-#xfileLoadFromClass
-'Load from method...'
-
-#xfileLoadFromFile
-'Load from file...'
-
-#xfileNewImage
-'New image'
-
-#xfileSaveAs
-'Save to file...'
-
-#xfileSaveMaskAs
-'Save mask to file...'
-
-#xfileSaveMethod
-'Save as method'
-
-#xfileSaveMethodAs
-'Save as Method...'
-
-)
-!
-
-localHelpTexts
+    <resource: #programHelp>
+
+    ^super flyByHelpSpec addPairsFrom:(self helpPairs)
+
+    "Modified: / 16-02-2017 / 12:30:55 / cg"
+!
+
+helpPairs
     "This resource specification was automatically generated
      by the UIHelpTool of ST/X."
 
@@ -776,9 +515,59 @@
 #settingsGridMagnification
 'Change the grid magnification of the edit view'
 
+
+
+
+#drawModeFilledCircle
+'Filled Circle Drawing Mode'
+
+#drawModeMaskOutsideCircle
+'Mask everything outside a Circle'
+
+#drawModeMaskOutsideRectangle
+'Mask everything outside a Rectangle'
+
+#edit3DProjection
+'Generate a 3D projection'
+
+#fileEditMask
+'Load Mask from a File'
+
+
+#gropBottom
+'Cut off the specified number of pixels at the bottom'
+
+#gropLeft
+'Cut off the specified number of pixels at the left'
+
+#gropRight
+'Cut off the specified number of pixels at the right'
+
+#gropTop
+'Cut off the specified number of pixels at the top'
+
+
 )
 
-    "Created: / 19-01-2012 / 13:29:31 / cg"
+    "Created: / 16-02-2017 / 12:29:54 / cg"
+!
+
+helpSpec
+    "This resource specification was automatically generated
+     by the UIHelpTool of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the UIHelpTool may not be able to read the specification."
+
+    "
+     UIHelpTool openOnClass:ImageEditor
+    "
+
+    <resource: #programHelp>
+
+    ^super helpSpec addPairsFrom:(self helpPairs)
+
+    "Modified: / 16-02-2017 / 12:30:50 / cg"
 ! !
 
 !ImageEditor class methodsFor:'image specs'!
@@ -853,6 +642,28 @@
     ^ ToolbarIconLibrary startImageEditorIcon
 !
 
+fillCircleIcon
+    "This resource specification was automatically generated
+     by the ImageEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the ImageEditor may not be able to read the specification."
+
+    "
+     self fillCircleIcon inspect
+     ImageEditor openOnClass:self andSelector:#fillCircleIcon
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'ImageEditor class fillCircleIcon'
+        ifAbsentPut:[(Depth1Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@A@@@@@@@@@@@@@@@C@@@@@@@@@@@@@@@a')
+            colorMapFromArray:#[0 0 0 255 0 0]
+            mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@N@C>@_<A?0O? ?>C?8G?@_<@? @8@@@@@a'); yourself); yourself]
+!
+
 fillGradientRectIcon
     <resource: #image>
     "This resource specification was automatically generated
@@ -1114,6 +925,50 @@
         ]
 !
 
+maskOutsideCircleIcon
+    "This resource specification was automatically generated
+     by the ImageEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the ImageEditor may not be able to read the specification."
+
+    "
+     self maskOutsideCircleIcon inspect
+     ImageEditor openOnClass:self andSelector:#maskOutsideCircleIcon
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'ImageEditor class maskOutsideCircleIcon'
+        ifAbsentPut:[(Depth1Image width:14 height:14) bits:(ByteArray fromPackedString:'??3??O1=<A3 CN@L0@S@AL@G8@3 CO@\?G3??@@a')
+            colorMapFromArray:#[0 0 0 255 0 0]
+            mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'??3??O?<??3??O?<??3??O?<??3??O?<??3??@@a'); yourself); yourself]
+!
+
+maskOutsideRectangleIcon
+    "This resource specification was automatically generated
+     by the ImageEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the ImageEditor may not be able to read the specification."
+
+    "
+     self maskOutsideRectangleIcon inspect
+     ImageEditor openOnClass:self andSelector:#maskOutsideRectangleIcon
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'ImageEditor class maskOutsideRectangleIcon'
+        ifAbsentPut:[(Depth1Image width:14 height:14) bits:(ByteArray fromPackedString:'??3??L@M0@3@CL@L0@3@CL@L0@3@CL@L??7??@@a')
+            colorMapFromArray:#[0 0 0 255 0 0]
+            mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'??3??O?<??3??O?<??3??O?<??3??O?<??3??@@a'); yourself); yourself]
+!
+
 pasteIcon
     <resource: #image>
     "This resource specification was automatically generated
@@ -2545,7 +2400,8 @@
      #(Menu
         (
          (MenuItem
-            enabled: imageIsLoadedAndAllowedToChangeImageDimensionAndDepth
+            "/ enabled: imageIsLoadedAndAllowedToChangeImageDimensionAndDepth
+            enabled: imageIsLoaded
             label: 'Depth'
             translateLabel: true
             submenu: 
@@ -2559,6 +2415,7 @@
                   argument: depth1
                   choice: colorMapMode
                   choiceValue: depth1
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   activeHelpKey: colorMap1M
@@ -2568,6 +2425,7 @@
                   argument: masked1
                   choice: colorMapMode
                   choiceValue: masked1
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   label: '-'
@@ -2580,6 +2438,7 @@
                   argument: depth2
                   choice: colorMapMode
                   choiceValue: depth2
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   activeHelpKey: colorMap2M
@@ -2589,6 +2448,7 @@
                   argument: masked2
                   choice: colorMapMode
                   choiceValue: masked2
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   label: '-'
@@ -2601,6 +2461,7 @@
                   argument: depth4
                   choice: colorMapMode
                   choiceValue: depth4
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   activeHelpKey: colorMap4M
@@ -2610,6 +2471,7 @@
                   argument: masked4
                   choice: colorMapMode
                   choiceValue: masked4
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   label: '-'
@@ -2622,6 +2484,7 @@
                   argument: depth8
                   choice: colorMapMode
                   choiceValue: depth8
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   activeHelpKey: colorMap8M
@@ -2631,6 +2494,7 @@
                   argument: masked8
                   choice: colorMapMode
                   choiceValue: masked8
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   label: '-'
@@ -2643,6 +2507,7 @@
                   argument: depth16
                   choice: colorMapMode
                   choiceValue: depth16
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   activeHelpKey: colorMap16M
@@ -2652,6 +2517,7 @@
                   argument: masked16
                   choice: colorMapMode
                   choiceValue: masked16
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   label: '-'
@@ -2664,6 +2530,7 @@
                   argument: depth24
                   choice: colorMapMode
                   choiceValue: depth24
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   activeHelpKey: colorMap24M
@@ -2673,6 +2540,7 @@
                   argument: masked24
                   choice: colorMapMode
                   choiceValue: masked24
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                (MenuItem
                   label: '-'
@@ -2685,6 +2553,7 @@
                   argument: depth32
                   choice: colorMapMode
                   choiceValue: depth32
+            enabled: imageIsLoadedAndNotReadonlyHolder
                 )
                )
               nil
@@ -2692,7 +2561,7 @@
             )
           )
          (MenuItem
-            enabled: imageIsLoadedHolder
+            enabled: imageIsLoadedAndNotReadonlyHolder
             label: 'ColorMap'
             translateLabel: true
             submenu: 
@@ -2753,7 +2622,7 @@
             )
           )
          (MenuItem
-            enabled: imageIsLoadedHolder
+            enabled: imageIsLoadedAndNotReadonlyHolder
             label: 'Process'
             translateLabel: true
             submenu: 
@@ -2821,7 +2690,7 @@
             )
           )
          (MenuItem
-            enabled: imageIsLoadedHolder
+            enabled: imageIsLoadedAndNotReadonlyHolder
             label: 'Mask'
             translateLabel: true
             submenu: 
@@ -2862,6 +2731,8 @@
         nil
         nil
       )
+
+    "Modified: / 16-02-2017 / 10:27:13 / cg"
 !
 
 menuEdit
@@ -2936,7 +2807,7 @@
             translateLabel: true
           )
          (MenuItem
-            enabled: imageIsLoadedHolder
+            enabled: imageIsLoadedAndAllowedToFlipHolder
             label: 'Flip'
             translateLabel: true
             submenu: 
@@ -2944,7 +2815,7 @@
               (
                (MenuItem
                   activeHelpKey: editFlipVertical
-                  enabled: imageIsLoadedHolder
+                  enabled: imageIsLoadedAndNotReadonlyHolder
                   label: 'Flip - Vertical'
                   itemValue: doFlipVertical
                   translateLabel: true
@@ -2952,7 +2823,7 @@
                 )
                (MenuItem
                   activeHelpKey: editFlipHorizontal
-                  enabled: imageIsLoadedHolder
+                  enabled: imageIsLoadedAndNotReadonlyHolder
                   label: 'Flip - Horizontal'
                   itemValue: doFlipHorizontal
                   translateLabel: true
@@ -2967,7 +2838,7 @@
             label: '-'
           )
          (MenuItem
-            enabled: imageIsLoadedAndAllowedToChangeImageDimensionAndDepth
+            enabled: imageIsLoadedAndAllowedToChangeImageDimension
             label: 'Crop'
             translateLabel: true
             submenu: 
@@ -3029,7 +2900,7 @@
           )
          (MenuItem
             activeHelpKey: shiftManual
-            enabled: imageIsLoadedHolder
+            enabled: imageIsLoadedAndAllowedToChangeImageDimension
             label: 'Shift...'
             itemValue: doShiftManual
             translateLabel: true
@@ -3045,7 +2916,7 @@
             translateLabel: true
           )
          (MenuItem
-            enabled: imageIsLoadedHolder
+            enabled: imageIsLoadedAndNotReadonlyHolder
             label: 'Text...'
             itemValue: doInsertTextFromUser
             translateLabel: true
@@ -3054,6 +2925,7 @@
             label: '-'
           )
          (MenuItem
+            enabled: imageIsLoadedHolder
             label: 'Animation Sequence'
             translateLabel: true
             submenu: 
@@ -3089,6 +2961,8 @@
         nil
         nil
       )
+
+    "Modified: / 16-02-2017 / 11:01:52 / cg"
 !
 
 menuFile
@@ -3533,6 +3407,7 @@
     "Do not manually edit this!! If it is corrupted,
      the MenuEditor may not be able to read the specification."
 
+
     "
      MenuEditor new openOnClass:ImageEditor andSelector:#modeMenu
      (Menu new fromLiteralArrayEncoding:(ImageEditor modeMenu)) startUp
@@ -3547,16 +3422,17 @@
             activeHelpKey: drawModePoint
             enabled: imageIsLoadedHolder
             label: 'Point'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor pointIcon 'Point')
             choice: editMode
             choiceValue: point
           )
          (MenuItem
+            label: '-'
+          )
+         (MenuItem
             activeHelpKey: drawModePoint
             enabled: imageIsLoadedHolder
             label: 'Spray'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor sprayIcon 'Spray')
             choice: editMode
             choiceValue: spray
@@ -3565,16 +3441,17 @@
             activeHelpKey: drawModeSmooth
             enabled: imageIsLoadedHolder
             label: 'Smooth'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor smoothIcon 'Smooth')
             choice: editMode
             choiceValue: smooth
           )
          (MenuItem
+            label: '-'
+          )
+         (MenuItem
             activeHelpKey: drawModeBox
             enabled: imageIsLoadedHolder
             label: 'Rect'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor rectIcon 'Rect')
             choice: editMode
             choiceValue: box
@@ -3583,34 +3460,60 @@
             activeHelpKey: drawModeFilledBox
             enabled: imageIsLoadedHolder
             label: 'Filled Rectangle'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor fillRectIcon 'Filled Rectangle')
             choice: editMode
             choiceValue: filledBox
           )
          (MenuItem
-            activeHelpKey: drawModeBox
+            activeHelpKey: drawModeCircle
             enabled: imageIsLoadedHolder
             label: 'Circle'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor circleIcon 'Circle')
             choice: editMode
             choiceValue: circle
           )
          (MenuItem
+            activeHelpKey: drawModeFilledCircle
+            enabled: imageIsLoadedHolder
+            label: 'Filled Circle'
+            labelImage: (ResourceRetriever ImageEditor fillCircleIcon 'Filled Circle')
+            choice: editMode
+            choiceValue: filledCircle
+          )
+         (MenuItem
             activeHelpKey: drawModeFill
             enabled: imageIsLoadedHolder
             label: 'Fill'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor fillIcon 'Fill')
             choice: editMode
             choiceValue: fill
           )
          (MenuItem
+            label: '-'
+          )
+         (MenuItem
+            activeHelpKey: drawModeMaskOutsideRectangle
+            enabled: imageHasMaskAndIsNotReadOnlyHolder
+            label: 'Mask Outside Rectangle'
+            labelImage: (ResourceRetriever ImageEditor maskOutsideRectangleIcon 'Mask Outside Rectangle')
+            choice: editMode
+            choiceValue: maskOutsideRect
+          )
+         (MenuItem
+            activeHelpKey: drawModeMaskOutsideCircle
+            enabled: imageHasMaskAndIsNotReadOnlyHolder
+            label: 'Mask Outside Circle'
+            labelImage: (ResourceRetriever ImageEditor maskOutsideCircleIcon 'Mask Outside Circle')
+            choice: editMode
+            choiceValue: maskOutsideCircle
+          )
+         (MenuItem
+            label: '-'
+          )
+         (MenuItem
             activeHelpKey: drawModeCopy
             enabled: imageIsLoadedHolder
             label: 'Copy'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor copyIcon 'Copy')
             choice: editMode
             choiceValue: copy
@@ -3619,7 +3522,6 @@
             activeHelpKey: drawModePaste
             enabled: imageIsLoadedHolder
             label: 'Paste'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor pasteIcon 'Paste')
             choice: editMode
             choiceValue: paste
@@ -3628,7 +3530,6 @@
             activeHelpKey: drawModePasteUnder
             enabled: imageIsLoadedHolder
             label: 'Paste Under'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor pasteUnderIcon 'Paste Under')
             choice: editMode
             choiceValue: pasteUnder
@@ -3637,16 +3538,17 @@
             activeHelpKey: drawModePasteWithMask
             enabled: imageIsLoadedHolder
             label: 'Paste with Mask'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor pasteWithMaskIcon 'Paste with Mask')
             choice: editMode
             choiceValue: pasteWithMask
           )
          (MenuItem
+            label: '-'
+          )
+         (MenuItem
             activeHelpKey: drawModeSpecial
             enabled: imageIsLoadedHolder
             label: 'Special'
-            translateLabel: true
             labelImage: (ResourceRetriever ImageEditor specialIcon 'Special')
             choice: editMode
             choiceValue: specialOperation
@@ -3655,8 +3557,6 @@
         nil
         nil
       )
-
-    "Modified: / 04-07-2010 / 10:18:08 / cg"
 !
 
 previewMenu
@@ -3974,6 +3874,14 @@
 
 !ImageEditor methodsFor:'accessing-behavior'!
 
+allowedToChangeImageDimension
+    "used to edit an existing image's contents only (Expecco)"
+
+    ^ self allowedToChangeImageDimensionAndDepth
+
+    "Created: / 16-02-2017 / 01:59:21 / cg"
+!
+
 allowedToChangeImageDimensionAndDepth
     "used to edit an existing image's contents only (Expecco)"
 
@@ -4152,6 +4060,16 @@
     "Modified: / 21-10-2010 / 14:36:57 / cg"
 !
 
+imageHasMaskAndIsNotReadOnlyHolder
+    "returns whether an image is loaded and editable as value holder"
+
+    ^ BlockValue
+        with:[:loaded | loaded and:[ self image mask notNil and:[self readOnly not] ]]
+        argument:(self imageIsLoadedHolder)
+
+    "Created: / 16-02-2017 / 12:17:25 / cg"
+!
+
 imageHasNextImage
     ^ self imageHasImageSequence and:[ (imageSeqNr ? 1) < self image imageSequence size ]
 
@@ -4199,6 +4117,17 @@
     "Modified: / 04-07-2010 / 10:15:14 / cg"
 !
 
+imageIsLoadedAndAllowedToChangeImageDimension
+    "returns whether an image is loaded as value holder"
+
+    ^ [ 
+        self imageIsLoadedHolder value
+        and:[ self allowedToChangeImageDimension ] 
+      ]
+
+    "Created: / 16-02-2017 / 01:58:41 / cg"
+!
+
 imageIsLoadedAndAllowedToChangeImageDimensionAndDepth
     "returns whether an image is loaded as value holder"
 
@@ -4223,12 +4152,11 @@
 imageIsLoadedAndNotReadonlyHolder
     "returns whether an image is loaded and editable as value holder"
 
-    ^ [ 
-        self imageIsLoadedHolder value
-        and:[ self readOnly not  ] 
-      ]
-
-    "Modified: / 04-07-2010 / 10:15:43 / cg"
+    ^ BlockValue
+        with:[:loaded | loaded and:[ self readOnly not ]]
+        argument:(self imageIsLoadedHolder)
+
+    "Modified: / 16-02-2017 / 12:11:31 / cg"
 !
 
 imageIsLoadedHolder
@@ -4444,14 +4372,14 @@
 !
 
 update:something with:aParameter from:changedObject
-    |clrIndex img imagePreView clr changedColor cMap|
-
-    img := self image.
+    |clrIndex image imagePreView clr changedColor cMap|
+
+    image := self image.
     imagePreView := self imagePreView.
 
     changedObject == self tileModeHolder ifTrue:[
         imagePreView 
-            tileMode:(changedObject value) tileOffset:(img extent);
+            tileMode:(changedObject value) tileOffset:(image extent);
             clear; 
             invalidate.
         ^ self
@@ -4479,9 +4407,9 @@
             drawingColormap notNil ifTrue:[
                 drawingColormap at:clrIndex put:changedColor.
             ].
-            cMap := img colorMap.
+            cMap := image colorMap.
             (cMap notNil and:[cMap isMappedPalette not and:[cMap isFixedPalette not]]) ifTrue:[
-                img colorMap at:clrIndex put:changedColor.
+                image colorMap at:clrIndex put:changedColor.
                 self colorMapChanged.
             ].
             ^ self
@@ -4501,15 +4429,15 @@
         ].
         something == #image ifTrue:[
             self updateAfterImageChange.
-            imagePreView image:img scroll:false.
+            imagePreView image:image scroll:false.
             self updateListOfColorsAndColormapMode.
             self tileModeHolder value ifTrue:[
-                imagePreView tileMode:true tileOffset:(img extent).
+                imagePreView tileMode:true tileOffset:(image extent).
             ].
             ^ self.
         ].
         something == #subImageIn ifTrue:[
-            imagePreView image ~~ img ifTrue:[
+            imagePreView image ~~ image ifTrue:[
                 self error:'internal error' mayProceed:true.
             ].
             self tileModeHolder value ifTrue:[
@@ -4547,6 +4475,7 @@
     super update:something with:aParameter from:changedObject
 
     "Modified: / 03-02-2017 / 21:52:33 / cg"
+    "Modified (format): / 16-02-2017 / 10:20:18 / cg"
 !
 
 updateAfterImageChange
@@ -4839,6 +4768,7 @@
 
     view := anEvent view.
     view notNil ifTrue:[
+        
         view == self imagePreView ifTrue:[
             ((anEvent isButtonPressEvent and:[ anEvent button == 1 ])
             or:[ anEvent isButtonMotionEvent and:[ anEvent hasButton1 ]])  ifTrue:[
@@ -4868,6 +4798,7 @@
     ^ false.
 
     "Modified: / 04-04-2011 / 13:50:09 / cg"
+    "Modified (format): / 16-02-2017 / 09:54:01 / cg"
 ! !
 
 !ImageEditor methodsFor:'help'!
@@ -4910,19 +4841,13 @@
         ^ self.
     ].
 
-"/    (imageEditView resourceClass == aClass
-"/    and:[ imageEditView resourceSelector == aSelector ]) ifTrue:[
-"/        imageEditView modified ifFalse:[
-"/            ^ self.
-"/        ].
-"/    ].
-
     (imageEditView loadFromClass:aClass andSelector:aSelector) notNil ifTrue:[
         self updateAfterImageChange.
         self clearModified.
     ]
 
-    "Modified: / 16.3.1999 / 21:44:41 / cg"
+    "Modified: / 16-03-1999 / 21:44:41 / cg"
+    "Modified (comment): / 16-02-2017 / 10:22:51 / cg"
 !
 
 loadFromFile:aFileName
@@ -4950,15 +4875,9 @@
     imageEditView clearModified.
 
     self updateAfterImageChange.
-"/    img notNil ifTrue:[    
-"/        self updateColorsFromImage:img.
-"/        self findColorMapMode.
-"/        self updateLabelsAndHistory.
-"/    ] ifFalse:[
-"/        self updateForNoImage
-"/    ]
-
-    "Modified: / 16.3.1999 / 21:43:56 / cg"
+
+    "Modified: / 16-03-1999 / 21:43:56 / cg"
+    "Modified (comment): / 16-02-2017 / 10:21:47 / cg"
 !
 
 loadFromOrPrepareForClass: aClass andSelector: aSelector
@@ -5014,6 +4933,12 @@
     ^ self imageIsLoadedAndNotReadonlyHolder
 
     "Created: / 16-02-2017 / 01:44:47 / cg"
+!
+
+imageIsLoadedAndAllowedToFlipHolder
+    ^ self imageIsLoadedAndNotReadonlyHolder
+
+    "Created: / 16-02-2017 / 01:57:02 / cg"
 ! !
 
 !ImageEditor methodsFor:'menu item visibility'!
@@ -5172,6 +5097,9 @@
     img := imageEditView image.
     imageEditView image:img.
     self fetchImageData.
+    self imageIsLoadedHolder changed.
+
+    "Modified: / 16-02-2017 / 12:18:08 / cg"
 !
 
 updateImagePreView
@@ -5335,6 +5263,11 @@
 !
 
 addColorToColormap:newColor
+    "when editing a palette image, the new color is added to the images colorMap
+     (unless it is full).
+     when editing a true-color image, it is added to my own list-of-colors,
+     which only holds drawing colors, but is not the colormap's image"
+     
     |depth img cMap newColorMap newImage oldCListSize newMode listOfColors|
 
     img := self image.
@@ -5357,8 +5290,7 @@
         ^ self
     ].
 
-    ("(depth == 1)" false
-    or:[cMap size == (1 bitShift:depth)]) ifTrue:[
+    (cMap size == (1 bitShift:depth)) ifTrue:[
         depth >= 8 ifTrue:[
             self warn:'No space for more colors in colormap.'.
             ^ self
@@ -5386,9 +5318,7 @@
     newColorMap := cMap copyWith:newColor.
 
     newImage := img species new
-                    width:img width
-                    height:img height
-                    depth:depth
+                    width:(img width) height:(img height) depth:depth
                     fromArray:img bits.
 
     newImage colorMap:newColorMap.  
@@ -5407,7 +5337,7 @@
     ]
 
     "Created: / 12-03-1999 / 00:20:28 / cg"
-    "Modified: / 03-02-2017 / 21:42:18 / cg"
+    "Modified: / 16-02-2017 / 10:17:25 / cg"
 !
 
 changeHLS
@@ -5721,7 +5651,9 @@
 !
 
 colorMapMode:aMode
-    "calculates a new color map for the image from aMode"
+    "calculates a new color map for the image from aMode.
+     This might involve the computation of a colormap 
+     (if depth is smaller)"
 
     |depth numColors newColorMap newImage 
      oldImage image newColors realColorMap oldFileName
@@ -5759,8 +5691,9 @@
             ]
         ].
         ((prevMode = aMode)
-        or:[depth > oldImage depth
-        or:[self confirm:(resources string:quest)]]) ifTrue:[
+          or:[depth > oldImage depth
+          or:[true "self confirm:(resources string:quest)"]]
+        ) ifTrue:[
             (newColorMap isOrderedCollection or:[newColorMap isFixedPalette not]) ifTrue:[
 
                 "/ keep the colormap
@@ -5854,17 +5787,14 @@
         newImage := Image newForDepth:depth.
         newImage depth:depth.
         depth >= 16 ifTrue:[
+            newImage colorMap:nil. 
             depth == 32 ifTrue:[
-                newImage colorMap:nil.
-                newImage samplesPerPixel:4.
-                newImage photometric:#rgba.
+                newImage samplesPerPixel:4; photometric:#rgba.
             ] ifFalse:[    
-                newImage colorMap:nil.
-                newImage samplesPerPixel:3.
-                newImage photometric:#rgb.
+                newImage samplesPerPixel:3; photometric:#rgb.
             ].    
-        ].    
-"/        newImage photometric:oldImage photometric.
+        ].   
+        "/ newImage photometric:oldImage photometric.
 
         oldFileName := oldImage fileName.
 
@@ -5924,8 +5854,6 @@
                     maskImage bits:(ByteArray 
                                         new:(maskImage bytesPerRow * maskImage height)
                                         withAll:16rFF).
-
-"/                    maskImage fillRectangle:(image bounds) withColor:(Color colorId:1).
                 ].
                 image mask:maskImage.
             ].
@@ -5959,7 +5887,7 @@
         ]
     ]
 
-    "Modified: / 22-11-2016 / 03:44:00 / cg"
+    "Modified (format): / 16-02-2017 / 10:24:41 / cg"
 !
 
 colorize
@@ -7368,7 +7296,7 @@
         file := img fileName
     ].
 
-    title := (resources string:'Load Image From').
+    title := (resources string:'Load Image from File:').
 
     (UserPreferences current useNativeFileDialog
      and:[Screen current isWindowsPlatform]) ifTrue:[
@@ -7408,7 +7336,7 @@
         self loadFromFile:file
     ]
 
-    "Modified: / 14-12-2010 / 13:52:11 / cg"
+    "Modified: / 16-02-2017 / 10:53:41 / cg"
 !
 
 doLoadFromURL
@@ -7419,7 +7347,7 @@
     self checkModified ifFalse:[ ^ self ].
 
     url := Dialog 
-                request:(resources string:'Load Image from URL')
+                request:(resources string:'Load Image from URL:')
                 initialAnswer:LastURL.
 
     url notEmptyOrNil ifTrue:[
@@ -7439,6 +7367,7 @@
     ]
 
     "Created: / 20-09-2010 / 11:30:59 / cg"
+    "Modified: / 16-02-2017 / 10:51:18 / cg"
 !
 
 doNewImage
@@ -7547,9 +7476,8 @@
     newImage mask:mask.
     imageEditView newImageWithUndo:newImage.
     self updateAfterImageChange.
-"/    self updateColorsFromImage:image.
-"/    self findColorMapMode.
-"/    self updateLabelsAndHistory.
+
+    "Modified (comment): / 16-02-2017 / 10:22:19 / cg"
 !
 
 grabScreenImage
@@ -7677,7 +7605,7 @@
             file := Screen current
                 nativeFileDialogFor:(self window topView id)
                 save:true
-                title:(resources string:'Save Image To')
+                title:(resources string:'Save Image in File')
                 inDirectory:(file notNil ifTrue:[file asFilename directory pathName] ifFalse:[LastDirectory])
                 initialAnswer:(file notNil ifTrue:[file asFilename baseName] ifFalse:['image.png'])
                 "/ flags:#( ENABLESIZING "HIDEREADONLY" EXPLORER NOCHANGEDIR)
@@ -7710,7 +7638,7 @@
                             withFileFilters:filters.
             ] ifFalse:[
                 file := FileSelectionBrowser
-                            request:'Save Image To'
+                            request:'Save Image in File:'
                             inDirectory:LastDirectory
                             withFileFilters:filters.
             ].
@@ -7723,7 +7651,7 @@
         self clearModifiedAndRememberImageSavedAsFile:file.
     ]
 
-    "Modified: / 14-12-2010 / 13:51:47 / cg"
+    "Modified: / 16-02-2017 / 10:52:56 / cg"
 !
 
 doSaveImageMaskFileAs