ImageEditView.st
changeset 4032 f293d37675b5
parent 4000 21106540ffb5
child 4041 2d635ff57406
--- a/ImageEditView.st	Thu Mar 31 14:15:55 2011 +0200
+++ b/ImageEditView.st	Thu Apr 07 09:35:08 2011 +0200
@@ -1094,6 +1094,41 @@
     "Modified: / 10.2.2000 / 23:37:04 / cg"
 !
 
+flipSubImage:how in:imageBox
+    "/ now, do it
+
+    |x0 y0 x1 y1 image t|
+
+    x0 := imageBox left.
+    y0 := imageBox top.
+    x1 := imageBox right-1.
+    y1 := imageBox bottom-1.
+
+    image := self image.
+
+    how == #vertical ifTrue:[
+        0 to:((y1-y0)//2) do:[:dy |
+            x0 to:x1 do:[:x |
+                t := image pixelAtX:x y:(y0+dy).
+                image pixelAtX:x y:(y0+dy) put:(image pixelAtX:x y:(y1-dy)).
+                image pixelAtX:x y:(y1-dy) put:t.
+            ].
+        ]
+    ] ifFalse:[
+        0 to:((x1-x0)//2) do:[:dx |
+            y0 to:y1 do:[:y |
+                t := image pixelAtX:(x0+dx) y:y.
+                image pixelAtX:(x0+dx) y:y put:(image pixelAtX:(x1-dx) y:y).
+                image pixelAtX:(x1-dx) y:y put:t.
+            ].
+        ]
+    ].
+
+    self setModified.
+
+    "Created: / 07-04-2011 / 09:34:23 / cg"
+!
+
 magnifyImageTo:newSize
     self makeUndo.
     self image: (image magnifiedBy: newSize/image extent).
@@ -1462,6 +1497,9 @@
            fromList:(resources array:#(
                        'edit separately'
                        '-'
+                       'flip vertical'
+                       'flip horizontal'
+                       '-'
                        'slightly brightened'
                        'slightly darkened'
                        'brightened'
@@ -1478,9 +1516,11 @@
                        'colorize'
                      )) 
            values:#(edit nil
-                    slightlyBrightened slightlyDarkened brightened darkened 
-                    nil makeGrey greyed greyPattern unmaskedGreyPattern
-                    nil reversed nil changeHue colorize) 
+                    flipVertical flipHorizontal nil
+                    slightlyBrightened slightlyDarkened brightened darkened nil 
+                    makeGrey greyed greyPattern unmaskedGreyPattern nil 
+                    reversed nil 
+                    changeHue colorize) 
            lines:6
            cancel:nil.
 
@@ -1498,6 +1538,15 @@
         (self image subImageIn:imageBox) edit.
         ^ false.
     ].
+    operation == #flipVertical ifTrue:[
+        self flipSubImage:#vertical in:imageBox.
+        ^ true.
+    ].
+    operation == #flipHorizontal ifTrue:[
+        self flipSubImage:#horizontal in:imageBox.
+        ^ true.
+    ].
+
     operation == #slightlyBrightened ifTrue:[
         pixelAction := [:x :y :clr | clr slightlyLightened].
     ].
@@ -1594,6 +1643,8 @@
 
     self setModified.
     ^ true.
+
+    "Modified: / 07-04-2011 / 09:28:20 / cg"
 !
 
 pointAt:aPoint
@@ -2671,11 +2722,11 @@
 !ImageEditView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.245 2011-01-31 17:32:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.246 2011-04-07 07:35:08 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.245 2011-01-31 17:32:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ImageEditView.st,v 1.246 2011-04-07 07:35:08 cg Exp $'
 ! !
 
 ImageEditView initialize!