d24 rotation fixed
authorClaus Gittinger <cg@exept.de>
Thu, 24 Apr 1997 13:32:31 +0200
changeset 1653 7ab13998d4cd
parent 1652 5745269f78a3
child 1654 93c6430368d7
d24 rotation fixed
Image.st
--- a/Image.st	Thu Apr 24 13:30:51 1997 +0200
+++ b/Image.st	Thu Apr 24 13:32:31 1997 +0200
@@ -7631,7 +7631,6 @@
      pX pY srcX srcY pix nX nY 
      sinRot cosRot sinPY cosPY|
 
-
     "/ placing the image at the origin,
     "/ compute the diagonal and angle.
 
@@ -7706,10 +7705,12 @@
         newImage mask:(mask rotated:degrees)
     ] ifFalse:[
         self isMask ifFalse:[
-            m := ImageMask width:width height:height.
-            m bits:(maskBits := ByteArray new:(m bytesPerRow * height)).
-            maskBits atAllPut:16rFF.
-            newImage mask:(m rotated:degrees)
+            self depth ~~ 1 ifTrue:[
+                m := ImageMask width:width height:height.
+                m bits:(maskBits := ByteArray new:(m bytesPerRow * height)).
+                maskBits atAllPut:16rFF.
+                newImage mask:(m rotated:degrees)
+            ]
         ]
     ].
 
@@ -7758,15 +7759,10 @@
     int __srcBytesPerRow = __intVal(bytesPerRow);
     int __dstBytesPerRow = __intVal(newBytesPerRow);
     int __dstMask, __blackPixel;
-    int __rot1 = 0;
     double __sin, __cos;
     double sin(), cos();
 #   define Float_PI 3.14159
 
-    if (__isSmallInteger(degrees) && (__intVal(degrees)<90)) {
-        __rot1 = 1;
-    }
-
     bad = true;
     if (1
      && __isFloat(minX) 
@@ -7829,7 +7825,7 @@
                         if (__nX < 0) {
 #ifdef EARLY_OUT
                             if (didFetchInRow) {
-                                if (__rot1) break;
+                                break;
                             }
 #endif
 #ifdef FAST_ADVANCE
@@ -7856,7 +7852,7 @@
                             if (__srcX >= __width) {
 #ifdef EARLY_OUT
                                 if (didFetchInRow) {
-                                    if (__rot1) break;
+                                    break;
                                 }
 #endif
 #ifdef FAST_ADVANCE2
@@ -7888,7 +7884,7 @@
                                 if (__nY < 0) {
 #ifdef EARLY_OUT
                                     if (didFetchInRow) {
-                                        if (__rot1) break;
+                                        break;
                                     }
 #endif
 #ifdef FAST_ADVANCE2
@@ -7915,7 +7911,7 @@
                                     if (__srcY >= __height) {
 #ifdef EARLY_OUT
                                         if (didFetchInRow) {
-                                            if (__rot1) break;
+                                            break;
                                         }
 #endif
 #ifdef FAST_ADVANCE
@@ -7992,7 +7988,22 @@
                         if (__nX < 0) {
 #ifdef EARLY_OUT
                             if (didFetchInRow) {
-                                if (__rot1) break;
+                                break;
+                            }
+#endif
+#ifdef FAST_ADVANCE
+                            if (__blackPixel == 0) {
+                                do {
+                                    /* try advance by 8 pixels ... */
+                                    __dstX += 8; __dstPtr ++;
+                                    if (__dstX >= __newWidth) {
+                                        break;
+                                    }
+                                    __pX = (double)(__dstX + __minX);
+                                    __nX = (__cos * __pX) - __sinPY;
+                                    __nX = __nX + __halfW + 0.5;
+                                } while (__nX < 0);
+                                __dstX -= 8; __dstPtr--;
                             }
 #endif
                             __pix = __blackPixel;
@@ -8004,7 +8015,23 @@
                             if (__srcX >= __width) {
 #ifdef EARLY_OUT
                                 if (didFetchInRow) {
-                                    if (__rot1) break;
+                                    break;
+                                }
+#endif
+#ifdef FAST_ADVANCE2
+                                if (__blackPixel == 0) {
+                                    do {
+                                        /* try advance by 8 pixels ... */
+                                        __dstX += 8; __dstPtr++;
+                                        if (__dstX >= __newWidth) {
+                                            break;
+                                        }
+                                        __pX = (double)(__dstX + __minX);
+                                        __nX = (__cos * __pX) - __sinPY;
+                                        __nX = __nX + __halfW + 0.5;
+                                        __srcX = (int)__nX;
+                                    } while (__srcX >= __width);
+                                    __dstX -= 8; __dstPtr--;
                                 }
 #endif
                                 __pix = __blackPixel;
@@ -8020,7 +8047,22 @@
                                 if (__nY < 0) {
 #ifdef EARLY_OUT
                                     if (didFetchInRow) {
-                                        if (__rot1) break;
+                                        break;
+                                    }
+#endif
+#ifdef FAST_ADVANCE2
+                                    if (__blackPixel == 0) {
+                                        do {
+                                            /* try advance by 8 pixels ... */
+                                            __dstX += 8; __dstPtr++;
+                                            if (__dstX >= __newWidth) {
+                                                break;
+                                            }
+                                            __pX = (double)(__dstX + __minX);
+                                            __nY = (__sin * __pX) + __cosPY;
+                                            __nY = __nY + __halfH + 0.5;
+                                        } while (__nY < 0);
+                                        __dstX -= 8; __dstPtr--;
                                     }
 #endif
                                     __pix = __blackPixel;
@@ -8032,7 +8074,23 @@
                                     if (__srcY >= __height) {
 #ifdef EARLY_OUT
                                         if (didFetchInRow) {
-                                            if (__rot1) break;
+                                            break;
+                                        }
+#endif
+#ifdef FAST_ADVANCE
+                                        if (__blackPixel == 0) {
+                                            do {
+                                                /* try advance by 8 pixels ... */
+                                                __dstX += 8; __dstPtr++;
+                                                if (__dstX >= __newWidth) {
+                                                    break;
+                                                }
+                                                __pX = (double)(__dstX + __minX);
+                                                __nY = (__sin * __pX) + __cosPY;
+                                                __nY = __nY + __halfH + 0.5;
+                                                __srcY = (int)__nY;
+                                            } while (__srcY >= __height);
+                                            __dstX -= 8; __dstPtr--;
                                         }
 #endif
                                         __pix = __blackPixel;
@@ -8098,7 +8156,7 @@
                         if (__nX < 0) {
 #ifdef EARLY_OUT
                             if (didFetchInRow) {
-                                if (__rot1) break;
+                                break;
                             }
 #endif
                             __pix = __blackPixel;
@@ -8110,7 +8168,7 @@
                             if (__srcX >= __width) {
 #ifdef EARLY_OUT
                                 if (didFetchInRow) {
-                                    if (__rot1) break;
+                                    break;
                                 }
 #endif
                                 __pix = __blackPixel;
@@ -8126,7 +8184,7 @@
                                 if (__nY < 0) {
 #ifdef EARLY_OUT
                                     if (didFetchInRow) {
-                                        if (__rot1) break;
+                                        break;
                                     }
 #endif
                                     __pix = __blackPixel;
@@ -8138,7 +8196,7 @@
                                     if (__srcY >= __height) {
 #ifdef EARLY_OUT
                                         if (didFetchInRow) {
-                                            if (__rot1) break;
+                                            break;
                                         }
 #endif
                                         __pix = __blackPixel;
@@ -8154,7 +8212,8 @@
                                             __pix = __srcBytes[idx];
                                             __pix = (__pix<<8) | __srcBytes[idx+1];
                                             __pix = (__pix<<8) | __srcBytes[idx+2];
-                                            break;
+                                        } else {
+                                            __pix = __blackPixel;
                                         }
                                     }
                                 }
@@ -8203,7 +8262,7 @@
                         if (__nX < 0) {
 #ifdef EARLY_OUT
                             if (didFetchInRow) {
-                                if (__rot1) break;
+                                break;
                             }
 #endif
                             __pix = blackPixel;
@@ -8215,7 +8274,7 @@
                             if (__srcX >= __width) {
 #ifdef EARLY_OUT
                                 if (didFetchInRow) {
-                                    if (__rot1) break;
+                                    break;
                                 }
 #endif
                                 __pix = blackPixel;
@@ -8231,7 +8290,7 @@
                                 if (__nY < 0) {
 #ifdef EARLY_OUT
                                     if (didFetchInRow) {
-                                        if (__rot1) break;
+                                        break;
                                     }
 #endif
                                     __pix = blackPixel;
@@ -8243,7 +8302,7 @@
                                     if (__srcY >= __height) {
 #ifdef EARLY_OUT
                                         if (didFetchInRow) {
-                                            if (__rot1) break;
+                                            break;
                                         }
 #endif
                                         __pix = blackPixel;
@@ -8348,7 +8407,8 @@
      |i|
 
      i := Image fromFile:'bitmaps/gifImages/garfield.gif'.
-     (i rotated:45) inspect
+     i := Depth24Image fromImage:i.
+     (i rotated:200) inspect
     "
     "
      |i|
@@ -8380,7 +8440,7 @@
      |v i rI rot|
 
      i := Image fromFile:'bitmaps/gifImages/claus.gif'.
-     v := View new extent:300@300.
+     v := View new extent:400@400.
      v openAndWait.
      rot := 0.
      [true] whileTrue:[
@@ -10316,6 +10376,6 @@
 !Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.184 1997-04-24 10:03:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.185 1997-04-24 11:32:31 cg Exp $'
 ! !
 Image initialize!