checkin from browser
authorClaus Gittinger <cg@exept.de>
Mon, 17 Jun 1996 17:32:27 +0200
changeset 878 b99add8dc742
parent 877 cca16d32cb60
child 879 2adf7645e7e6
checkin from browser
Image.st
--- a/Image.st	Mon Jun 17 16:31:29 1996 +0200
+++ b/Image.st	Mon Jun 17 17:32:27 1996 +0200
@@ -2624,10 +2624,11 @@
 
 asPseudoFormQuickOn:aDevice
     "return a pseudo-deviceForm from the image.
-     Fail if colors are not fully available."
+     Fail if any color is not available (i.e. do not dither)."
 
     |f d dDev temp temp8 bits anyMissing clr cMap idMap 
-     nClr "{ Class: SmallInteger }" |
+     nClr "{ Class: SmallInteger }"
+     usedColors |
 
     d := self depth.
     (d == 1
@@ -2648,13 +2649,28 @@
         nClr := nClr min:(colorMap size)
     ].
 
-    1 to:nClr do:[:pixel |
-        clr := self colorFromValue:pixel-1.
-        clr := clr exactOn:aDevice.
-        clr isNil ifTrue:[^ nil].
-
-        cMap at:(pixel) put:clr.
-        idMap at:(pixel) put:(clr colorId).
+    d == 8 ifTrue:[
+        usedColors := bytes usedValues.    "gets us an array filled with used values"
+        1 to:nClr do:[:pixel |
+            (usedColors includes:(pixel - 1)) ifFalse:[
+                clr := Color black
+            ] ifTrue:[
+                clr := self colorFromValue:pixel-1.
+                clr := clr exactOn:aDevice.
+                clr isNil ifTrue:[^ nil].
+            ].
+            cMap at:(pixel) put:clr.
+            idMap at:(pixel) put:(clr colorId).
+        ].
+    ] ifFalse:[
+        1 to:nClr do:[:pixel |
+            clr := self colorFromValue:pixel-1.
+            clr := clr exactOn:aDevice.
+            clr isNil ifTrue:[^ nil].
+
+            cMap at:(pixel) put:clr.
+            idMap at:(pixel) put:(clr colorId).
+        ].
     ].
 
     "/ got all colors; good - simply change depth & translate pixels
@@ -2736,7 +2752,7 @@
       ) inspect
      "
 
-    "Modified: 17.6.1996 / 11:39:55 / cg"
+    "Modified: 17.6.1996 / 17:31:49 / cg"
 !
 
 asStevensonArceDitheredMonochromeImage
@@ -4400,22 +4416,30 @@
                     d = dp[0];
                     delta = __wR - d;
                     if (delta < 0) delta = -delta;
-                    d = dp[1];
-                    if (__wG > d) 
-                        delta += (__wG - d);
-                    else 
-                        delta += (d - __wG);
-                    d = dp[2];
-                    if (__wB > d) 
-                        delta += (__wB - d);
-                    else 
-                        delta += (d - __wB);
                     if (delta < minDelta) {
-                        bestIdx = idx;
-                        if (delta == 0) {
-                            break;
+                        d = dp[1];
+                        if (__wG > d) 
+                            delta += (__wG - d);
+                        else 
+                            delta += (d - __wG);
+                        if (delta < minDelta) {
+                            d = dp[2];
+                            if (__wB > d) 
+                                delta += (__wB - d);
+                            else 
+                                delta += (d - __wB);
+
+                            if (delta < minDelta) {
+                                bestIdx = idx;
+                                if (delta == 0) {
+        /*
+                                if (delta < 3) {
+        */
+                                    break;
+                                }
+                                minDelta = delta;
+                            }
                         }
-                        minDelta = delta;
                     }
                     dp += 3;
                 }
@@ -7268,6 +7292,6 @@
 !Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.101 1996-06-17 12:47:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.102 1996-06-17 15:32:27 cg Exp $'
 ! !
 Image initialize!