checkin from browser
authorClaus Gittinger <cg@exept.de>
Mon, 21 Jul 1997 20:03:25 +0200
changeset 1817 2f71142cb24d
parent 1816 88716b7cc777
child 1818 fd245b7ae2f9
checkin from browser
Depth24Image.st
--- a/Depth24Image.st	Mon Jul 21 18:07:37 1997 +0200
+++ b/Depth24Image.st	Mon Jul 21 20:03:25 1997 +0200
@@ -532,6 +532,7 @@
     int iR, iG, iB;
     int idx;
     int __w = __intVal(w);
+    int leftToRight;
 
     if (__isByteArray(__INST(bytes))
      && __isByteArray(pseudoBits)
@@ -549,58 +550,117 @@
         __fG = __intVal(fixG)-1;
         __fB = __intVal(fixB)-1;
 
+        leftToRight = 1;
         for (__y=__intVal(h); __y>0; __y--) {
-            __eR = __eG = __eB = 0;
-            for (__x=__w; __x>0; __x--) {
-                int __want;
+            if (leftToRight) {
+                for (__x=__w; __x>0; __x--) {
+                    int __want;
+
+                    /*
+                     * wR, wG and wB is the wanted r/g/b value;
+                     * compute the index into the dId table ..
+                     * values: 0..255; scale to 0..fR-1, 0..fG-1, 0..fB-1
+                     *
+                     * bad kludge: knows how to index into FixColor table
+                     */
+                    __wantR = __want = srcP[0] + __eR;
+
+                    if (__want > 255) __want = 255;
+                    else if (__want < 0) __want = 0;
+
+                    iR = __want * __fR / 128;
+                    iR = (iR / 2) + (iR & 1);
 
-                /*
-                 * wR, wG and wB is the wanted r/g/b value;
-                 * compute the index into the dId table ..
-                 * values: 0..255; scale to 0..fR-1, 0..fG-1, 0..fB-1
-                 *
-                 * bad kludge: knows how to index into FixColor table
-                 */
-                __wantR = __want = srcP[0] + __eR;
+                    __wantG = __want = srcP[1] + __eG;
+                    if (__want > 255) __want = 255;
+                    else if (__want < 0) __want = 0;
+
+                    iG = __want * __fG / 128;
+                    iG = (iG / 2) + (iG & 1);
+
+                    __wantB = __want = srcP[2] + __eB;
+                    if (__want > 255) __want = 255;
+                    else if (__want < 0) __want = 0;
 
-                if (__want > 255) __want = 255;
-                else if (__want < 0) __want = 0;
+                    iB = __want * __fB / 128;
+                    iB = (iB / 2) + (iB & 1);
+
+                    idx = iR * (__fG+1);
+                    idx = (idx + iG) * (__fB+1);
+                    idx = idx + iB;
 
-                iR = __want * __fR / 128;
-                iR = (iR / 2) + (iR & 1);
+                    /*
+                     * store the corresponding dither colorId
+                     */
+                    *dstP++ = idP[idx];
+                    usedIdP[idx] = 1;
 
-                __wantG = __want = srcP[1] + __eG;
-                if (__want > 255) __want = 255;
-                else if (__want < 0) __want = 0;
+                    srcP += 3;
 
-                iG = __want * __fG / 128;
-                iG = (iG / 2) + (iG & 1);
-
-                __wantB = __want = srcP[2] + __eB;
-                if (__want > 255) __want = 255;
-                else if (__want < 0) __want = 0;
+                    /*
+                     * the new error:
+                     */
+                    __eR = __wantR - (iR * 256 / __fR); 
+                    __eG = __wantG - (iG * 256 / __fG); 
+                    __eB = __wantB - (iB * 256 / __fB);
+                }
+                leftToRight = 0;
+            } else {
+                srcP += (__w*3);
+                dstP += __w;
+                for (__x=__w; __x>0; __x--) {
+                    int __want;
 
-                iB = __want * __fB / 128;
-                iB = (iB / 2) + (iB & 1);
+                    /*
+                     * wR, wG and wB is the wanted r/g/b value;
+                     * compute the index into the dId table ..
+                     * values: 0..255; scale to 0..fR-1, 0..fG-1, 0..fB-1
+                     *
+                     * bad kludge: knows how to index into FixColor table
+                     */
+                    srcP -= 3;
+                    __wantR = __want = srcP[0] + __eR;
 
-                idx = iR * (__fG+1);
-                idx = (idx + iG) * (__fB+1);
-                idx = idx + iB;
+                    if (__want > 255) __want = 255;
+                    else if (__want < 0) __want = 0;
+
+                    iR = __want * __fR / 128;
+                    iR = (iR / 2) + (iR & 1);
 
-                /*
-                 * store the corresponding dither colorId
-                 */
-                *dstP++ = idP[idx];
-                usedIdP[idx] = 1;
+                    __wantG = __want = srcP[1] + __eG;
+                    if (__want > 255) __want = 255;
+                    else if (__want < 0) __want = 0;
+
+                    iG = __want * __fG / 128;
+                    iG = (iG / 2) + (iG & 1);
+
+                    __wantB = __want = srcP[2] + __eB;
+                    if (__want > 255) __want = 255;
+                    else if (__want < 0) __want = 0;
+
+                    iB = __want * __fB / 128;
+                    iB = (iB / 2) + (iB & 1);
 
-                srcP += 3;
+                    idx = iR * (__fG+1);
+                    idx = (idx + iG) * (__fB+1);
+                    idx = idx + iB;
+
+                    /*
+                     * store the corresponding dither colorId
+                     */
+                    *--dstP = idP[idx];
+                    usedIdP[idx] = 1;
 
-                /*
-                 * the new error:
-                 */
-                __eR = __wantR - (iR * 256 / __fR); 
-                __eG = __wantG - (iG * 256 / __fG); 
-                __eB = __wantB - (iB * 256 / __fB); 
+                    /*
+                     * the new error:
+                     */
+                    __eR = __wantR - (iR * 256 / __fR); 
+                    __eG = __wantG - (iG * 256 / __fG); 
+                    __eB = __wantB - (iB * 256 / __fB); 
+                }
+                srcP += (__w*3);
+                dstP += __w;
+                leftToRight = 1;
             }
         }
     }
@@ -2203,5 +2263,5 @@
 !Depth24Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.54 1997-07-18 22:41:23 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.55 1997-07-21 18:03:25 cg Exp $'
 ! !