Image.st
changeset 7523 f51843b46318
parent 7522 b9cefa848775
child 7529 5f77a718b7bd
--- a/Image.st	Tue Aug 30 16:35:19 2016 +0200
+++ b/Image.st	Tue Aug 30 17:02:10 2016 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1991 by Claus Gittinger
               All Rights Reserved
@@ -276,7 +278,15 @@
                                                                                         [exBegin]
         (Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif') inspect
                                                                                         [exEnd]
-
+    Boy, was I young, when writing ST/X... ;-)                                                                                                 
+                                                                                        [exBegin]
+        (Image fromFile:'../../goodies/bitmaps/gifImages/claus.gif') inspect
+        ((Image fromFile:'../../goodies/bitmaps/gifImages/claus.gif') rotated:90) inspect
+        ((Image fromFile:'../../goodies/bitmaps/gifImages/claus.gif') rotated:45) inspect
+        ((Image fromFile:'../../goodies/bitmaps/gifImages/claus.gif') rotated:25) inspect
+                                                                                        [exEnd]
+
+                                                                                        
     better use package relative file names:
                                                                                         [exBegin]
         (Image fromFile:'bitmaps/gifImages/garfield.gif' inPackage:'stx:goodies') inspect
@@ -10397,6 +10407,63 @@
     "Modified: / 24-11-2010 / 11:06:58 / cg"
 !
 
+easy2RotateBitsInto:destinationImage angle:degrees
+    "helper for rotation - does the actual pixel shuffling.
+     by degrees clockwise. Here, only 90, 180 and 270 degrees
+     are implemented. Hard angles are done in #hardRotate:.
+     The code here is depth-independent (but not too fast);
+     can be redefined in subclasses for more performance"
+
+    |w  "{Class: SmallInteger }"
+     h  "{Class: SmallInteger }"
+     c2 r2 pixelArray pixelMover|
+
+    w := width - 1.
+    h := height - 1.
+
+    degrees = 90 ifTrue:[
+        pixelMover := [:col :row :pixel | destinationImage pixelAtX:(h-row) y:col put:pixel].    
+    ] ifFalse:[
+        degrees = 180 ifTrue:[
+            pixelMover := [:col :row :pixel | destinationImage pixelAtX:(w-col) y:(h-row) put:pixel].    
+        ] ifFalse:[
+            degrees = 270 ifTrue:[
+                pixelMover := [:col :row :pixel | destinationImage pixelAtX:row y:(w-col) put:pixel].    
+            ] ifFalse:[
+                ^ self
+            ].
+        ].
+    ].    
+    self valuesFromX:0 y:0 toX:w y:h do:pixelMover.
+    ^ self.
+
+    "
+     |i|
+
+     i := Image fromFile:'../../goodies/bitmaps/gifImages/claus.gif'.
+     i inspect.
+     (i rotated:45) inspect.
+     (i rotated:90) inspect.
+     (i rotated:180) inspect.
+     (i rotated:270) inspect.
+    "
+    "
+     |i|
+     i := Image fromFile:'../../goodies/bitmaps/gifImages/claus.gif'.
+     Time millisecondsToRun:[ 100 timesRepeat:[ i rotated:90 ] ]
+1110
+1090
+    "
+    "
+     |i|
+     i := Image fromScreen.
+     Time millisecondsToRun:[ 20 timesRepeat:[ i rotated:90 ] ]
+    "
+    
+    "Created: 23.4.1997 / 14:36:45 / cg"
+    "Modified: 24.4.1997 / 17:26:26 / cg"
+!
+
 easyRotateBitsInto:destinationImage angle:degrees
     "helper for rotation - does the actual pixel shuffling.
      by degrees clockwise. Here, only 90, 180 and 270 degrees
@@ -10406,13 +10473,29 @@
 
     |w  "{Class: SmallInteger }"
      h  "{Class: SmallInteger }"
-     c2 r2 pixelArray|
+     c2 r2 pixelArray pixelMover|
 
     w := width - 1.
     h := height - 1.
 
+"/    degrees = 90 ifTrue:[
+"/        pixelMover := [:col :row :pixel | destinationImage pixelAtX:(h-row) y:col put:pixel].    
+"/    ] ifFalse:[
+"/        degrees = 180 ifTrue:[
+"/            pixelMover := [:col :row :pixel | destinationImage pixelAtX:(w-col) y:(h-row) put:pixel].    
+"/        ] ifFalse:[
+"/            degrees = 270 ifTrue:[
+"/                pixelMover := [:col :row :pixel | destinationImage pixelAtX:row y:(w-col) put:pixel].    
+"/            ] ifFalse:[
+"/                ^ self
+"/            ].
+"/        ].
+"/    ].    
+"/    self valuesFromX:0 y:0 toX:w y:h do:pixelMover.
+"/    ^ self.
+    
     pixelArray := self pixelArraySpecies new:width.
-
+    
     degrees = 90 ifTrue:[
         0 to:h do:[:row |
             self rowAt:row into:pixelArray startingAt:1.
@@ -10443,6 +10526,29 @@
         ]
     ]
 
+    "
+     |i|
+
+     i := Image fromFile:'../../goodies/bitmaps/gifImages/claus.gif'.
+     i inspect.
+     (i rotated:45) inspect.
+     (i rotated:90) inspect.
+     (i rotated:180) inspect.
+     (i rotated:270) inspect.
+    "
+    "
+     |i|
+     i := Image fromFile:'../../goodies/bitmaps/gifImages/claus.gif'.
+     Time millisecondsToRun:[ 100 timesRepeat:[ i rotated:90 ] ]
+1110
+1090
+    "
+    "
+     |i|
+     i := Image fromScreen.
+     Time millisecondsToRun:[ 20 timesRepeat:[ i rotated:90 ] ]
+    "
+    
     "Created: 23.4.1997 / 14:36:45 / cg"
     "Modified: 24.4.1997 / 17:26:26 / cg"
 !