showCr: -> showCR:
authorClaus Gittinger <cg@exept.de>
Sat, 18 May 1996 15:55:32 +0200
changeset 694 f6c8fc8419bd
parent 693 ed557e02b378
child 695 eafce1f493f4
showCr: -> showCR:
Depth24Image.st
Depth8Image.st
Image.st
--- a/Depth24Image.st	Sat May 18 11:40:40 1996 +0200
+++ b/Depth24Image.st	Sat May 18 15:55:32 1996 +0200
@@ -725,7 +725,7 @@
      pixel0bytes pixel1bytes ditherPattern
      ditherColors first delta|
 
-    Transcript showCr:'dithering ..'. Transcript endEntry.
+    Transcript showCR:'dithering ..'. Transcript endEntry.
 
     h := height.
     w := width.
@@ -736,17 +736,17 @@
     first := (100 / nDither / 2).
     delta := 100 / nDither.
     0 to:nDither-1 do:[:i |
-	ditherColors at:i+1 put:(Color grey:(i * delta + first)).
+        ditherColors at:i+1 put:(Color grey:(i * delta + first)).
     ].
 
     nColors := 256.
     map := Array new:256.
     1 to:256 do:[:i |
-	v := i - 1.
-	" v is now in the range 0 .. 255 "
-	v := (v * (nDither - 1) // 255) rounded.
-	" v is now 0 .. nDither-1 "
-	map at:i put:(ditherColors at:(v + 1))
+        v := i - 1.
+        " v is now in the range 0 .. 255 "
+        v := (v * (nDither - 1) // 255) rounded.
+        " v is now 0 .. nDither-1 "
+        map at:i put:(ditherColors at:(v + 1))
     ].
 
     "tuning - code below is so slooow"
@@ -758,190 +758,190 @@
 
     depth := aDevice depth.
     depth == 1 ifTrue:[
-	formBytes := ByteArray uninitializedNew:(w + 7 // 8) * h.
-	patterns := Array new:nColors.
-	pixel0bytes := ByteArray uninitializedNew:nColors.
-	pixel1bytes := ByteArray uninitializedNew:nColors.
+        formBytes := ByteArray uninitializedNew:(w + 7 // 8) * h.
+        patterns := Array new:nColors.
+        pixel0bytes := ByteArray uninitializedNew:nColors.
+        pixel1bytes := ByteArray uninitializedNew:nColors.
 
-	"extract dither patterns and values to use for 1/0 bits
-	 in those from the dithercolors"
+        "extract dither patterns and values to use for 1/0 bits
+         in those from the dithercolors"
 
-	1 to:nColors do:[:i |
-	    clr := (map at:i) on:aDevice.
-	    ditherPattern := clr ditherForm.
+        1 to:nColors do:[:i |
+            clr := (map at:i) on:aDevice.
+            ditherPattern := clr ditherForm.
 
-	    ditherPattern isNil ifTrue:[
-		patterns at:i put:#[2r11111111
-				    2r11111111
-				    2r11111111
-				    2r11111111
-				    2r11111111
-				    2r11111111
-				    2r11111111
-				    2r11111111].
-		pixel0bytes at:i put:clr colorId.
-		pixel1bytes at:i put:clr colorId
-	    ] ifFalse:[
-		patterns at:i put:(ditherPattern bits).
-		pixel0bytes at:i put:(ditherPattern colorMap at:1) colorId.
-		pixel1bytes at:i put:(ditherPattern colorMap at:2) colorId.
-	    ].
-	].
+            ditherPattern isNil ifTrue:[
+                patterns at:i put:#[2r11111111
+                                    2r11111111
+                                    2r11111111
+                                    2r11111111
+                                    2r11111111
+                                    2r11111111
+                                    2r11111111
+                                    2r11111111].
+                pixel0bytes at:i put:clr colorId.
+                pixel1bytes at:i put:clr colorId
+            ] ifFalse:[
+                patterns at:i put:(ditherPattern bits).
+                pixel0bytes at:i put:(ditherPattern colorMap at:1) colorId.
+                pixel1bytes at:i put:(ditherPattern colorMap at:2) colorId.
+            ].
+        ].
 
-	srcIndex := 1.
-	dstIndex := 1.
-	mask := 16r80.
-	outBits := 0.
-	patternOffset := 1.
-	1 to:h do:[:dstY |
-	    last := nil.
-	    1 to:w do:[:dstX |
-		r := bytes at:srcIndex.
-		g := bytes at:(srcIndex + 1).
-		b := bytes at:(srcIndex + 2).
-		srcIndex := srcIndex + 3.
+        srcIndex := 1.
+        dstIndex := 1.
+        mask := 16r80.
+        outBits := 0.
+        patternOffset := 1.
+        1 to:h do:[:dstY |
+            last := nil.
+            1 to:w do:[:dstX |
+                r := bytes at:srcIndex.
+                g := bytes at:(srcIndex + 1).
+                b := bytes at:(srcIndex + 2).
+                srcIndex := srcIndex + 3.
 
-		v := ((3 * r) + (6 * g) + (1 * b)).                "pixel grey value (*10)"
-		v == last ifFalse:[
-		    index := v // 10 + 1.                          "index into map"
+                v := ((3 * r) + (6 * g) + (1 * b)).                "pixel grey value (*10)"
+                v == last ifFalse:[
+                    index := v // 10 + 1.                          "index into map"
 
-		    patternBytes := patterns at:index.             "dither pattern for color"
-		    patternBits := patternBytes at:patternOffset.  "dither row"
-		    p0 := pixel0bytes at:index.                         "value for 0-dither bit"
-		    p1 := pixel1bytes at:index.                         "value for 1-dither bit"
-		    last := v.
-		].
-		outBits := outBits bitShift:1.
+                    patternBytes := patterns at:index.             "dither pattern for color"
+                    patternBits := patternBytes at:patternOffset.  "dither row"
+                    p0 := pixel0bytes at:index.                         "value for 0-dither bit"
+                    p1 := pixel1bytes at:index.                         "value for 1-dither bit"
+                    last := v.
+                ].
+                outBits := outBits bitShift:1.
 
-		(patternBits bitAnd:mask) == 0 ifTrue:[
-		    outBits := outBits bitOr:p0.
-		] ifFalse:[
-		    outBits := outBits bitOr:p1
-		].
-		mask := mask bitShift:-1.
-		mask == 0 ifTrue:[
-		    mask := 16r80.
-		    formBytes at:dstIndex put:outBits.
-		    dstIndex := dstIndex + 1.
-		    outBits := 0
-		]
-	    ].
-	    mask == 16r80 ifFalse:[
-		[mask == 0] whileFalse:[
-		    mask := mask bitShift:-1.
-		    outBits := outBits bitShift:1.
-		].
-		formBytes at:dstIndex put:outBits.
-		dstIndex := dstIndex + 1.
-		mask := 16r80.
-		outBits := 0
-	    ].
-	    patternOffset := patternOffset + 1.
-	    patternOffset == 9 ifTrue:[
-		patternOffset := 1
-	    ]
-	].
-	f := Form width:w height:h fromArray:formBytes.
-	^ f
+                (patternBits bitAnd:mask) == 0 ifTrue:[
+                    outBits := outBits bitOr:p0.
+                ] ifFalse:[
+                    outBits := outBits bitOr:p1
+                ].
+                mask := mask bitShift:-1.
+                mask == 0 ifTrue:[
+                    mask := 16r80.
+                    formBytes at:dstIndex put:outBits.
+                    dstIndex := dstIndex + 1.
+                    outBits := 0
+                ]
+            ].
+            mask == 16r80 ifFalse:[
+                [mask == 0] whileFalse:[
+                    mask := mask bitShift:-1.
+                    outBits := outBits bitShift:1.
+                ].
+                formBytes at:dstIndex put:outBits.
+                dstIndex := dstIndex + 1.
+                mask := 16r80.
+                outBits := 0
+            ].
+            patternOffset := patternOffset + 1.
+            patternOffset == 9 ifTrue:[
+                patternOffset := 1
+            ]
+        ].
+        f := Form width:w height:h fromArray:formBytes.
+        ^ f
     ].
 
     depth == 2 ifTrue:[
-	formBytes := ByteArray uninitializedNew:(w * 2 + 7 // 8) * h.
-	patterns := Array new:nColors.
-	pixel0bytes := ByteArray uninitializedNew:nColors.
-	pixel1bytes := ByteArray uninitializedNew:nColors.
+        formBytes := ByteArray uninitializedNew:(w * 2 + 7 // 8) * h.
+        patterns := Array new:nColors.
+        pixel0bytes := ByteArray uninitializedNew:nColors.
+        pixel1bytes := ByteArray uninitializedNew:nColors.
 
-	"extract dither patterns and values to use for 1/0 bits
-	 in those from the dithercolors"
+        "extract dither patterns and values to use for 1/0 bits
+         in those from the dithercolors"
 
-	1 to:nColors do:[:i |
-	    clr := (map at:i) on:aDevice.
-	    ditherPattern := clr ditherForm.
+        1 to:nColors do:[:i |
+            clr := (map at:i) on:aDevice.
+            ditherPattern := clr ditherForm.
 
-	    ditherPattern isNil ifTrue:[
-		patterns at:i put:#[2r11111111
-				    2r11111111
-				    2r11111111
-				    2r11111111
-				    2r11111111
-				    2r11111111
-				    2r11111111
-				    2r11111111].
-		pixel0bytes at:i put:clr colorId.
-		pixel1bytes at:i put:clr colorId
-	    ] ifFalse:[
-		patterns at:i put:(ditherPattern bits).
-		pixel0bytes at:i put:(ditherPattern colorMap at:1) colorId.
-		pixel1bytes at:i put:(ditherPattern colorMap at:2) colorId.
-	    ].
-	].
+            ditherPattern isNil ifTrue:[
+                patterns at:i put:#[2r11111111
+                                    2r11111111
+                                    2r11111111
+                                    2r11111111
+                                    2r11111111
+                                    2r11111111
+                                    2r11111111
+                                    2r11111111].
+                pixel0bytes at:i put:clr colorId.
+                pixel1bytes at:i put:clr colorId
+            ] ifFalse:[
+                patterns at:i put:(ditherPattern bits).
+                pixel0bytes at:i put:(ditherPattern colorMap at:1) colorId.
+                pixel1bytes at:i put:(ditherPattern colorMap at:2) colorId.
+            ].
+        ].
 
-	srcIndex := 1.
-	dstIndex := 1.
-	mask := 16r80.
-	outBits := 0.
-	patternOffset := 1.
-	1 to:h do:[:dstY |
-	    last := nil.
-	    outCount := 0.
-	    mask := 16r80.
-	    outBits := 0.
-	    1 to:w do:[:dstX |
-		r := bytes at:srcIndex.
-		srcIndex := srcIndex + 1.
-		g := bytes at:srcIndex.
-		srcIndex := srcIndex + 1.
-		b := bytes at:srcIndex.
-		srcIndex := srcIndex + 1.
+        srcIndex := 1.
+        dstIndex := 1.
+        mask := 16r80.
+        outBits := 0.
+        patternOffset := 1.
+        1 to:h do:[:dstY |
+            last := nil.
+            outCount := 0.
+            mask := 16r80.
+            outBits := 0.
+            1 to:w do:[:dstX |
+                r := bytes at:srcIndex.
+                srcIndex := srcIndex + 1.
+                g := bytes at:srcIndex.
+                srcIndex := srcIndex + 1.
+                b := bytes at:srcIndex.
+                srcIndex := srcIndex + 1.
 
-		v := ((3 * r) + (6 * g) + (1 * b)).                "pixel grey value (*10)"
-		v == last ifFalse:[
-		    index := v // 10 + 1.                          "index into map"
+                v := ((3 * r) + (6 * g) + (1 * b)).                "pixel grey value (*10)"
+                v == last ifFalse:[
+                    index := v // 10 + 1.                          "index into map"
 
-		    patternBytes := patterns at:index.             "dither pattern for color"
-		    patternBits := patternBytes at:patternOffset.  "dither row"
-		    p0 := pixel0bytes at:index.                    "value for 0-dither bit"
-		    p1 := pixel1bytes at:index.                    "value for 1-dither bit"
-		    last := v.
-		].
-		outBits := outBits bitShift:2.
+                    patternBytes := patterns at:index.             "dither pattern for color"
+                    patternBits := patternBytes at:patternOffset.  "dither row"
+                    p0 := pixel0bytes at:index.                    "value for 0-dither bit"
+                    p1 := pixel1bytes at:index.                    "value for 1-dither bit"
+                    last := v.
+                ].
+                outBits := outBits bitShift:2.
 
-		(patternBits bitAnd:mask) == 0 ifTrue:[
-		    outBits := outBits bitOr:p0.
-		] ifFalse:[
-		    outBits := outBits bitOr:p1
-		].
-		mask := mask bitShift:-1.
-		outCount := outCount + 1.
-		outCount == 4 ifTrue:[
-		    formBytes at:dstIndex put:outBits.
-		    dstIndex := dstIndex + 1.
-		    outBits := 0.
-		    outCount := 0.
-		    mask == 0 ifTrue:[
-			mask := 16r80.
-		    ]
-		]
-	    ].
-	    (outCount == 0) ifFalse:[
-		[outCount == 4] whileFalse:[
-		    outCount := outCount + 1.
-		    outBits := outBits bitShift:2.
-		].
-		formBytes at:dstIndex put:outBits.
-		dstIndex := dstIndex + 1.
-	    ].
-	    patternOffset := patternOffset + 1.
-	    patternOffset == 9 ifTrue:[
-		patternOffset := 1
-	    ]
-	].
-	f := Form width:w height:h depth:depth.
-	f initGC.
-	f device drawBits:formBytes depth:2
-		    width:w height:h x:0 y:0
-		     into:f id x:0 y:0 width:w height:h with:f gcId.
-	^ f
+                (patternBits bitAnd:mask) == 0 ifTrue:[
+                    outBits := outBits bitOr:p0.
+                ] ifFalse:[
+                    outBits := outBits bitOr:p1
+                ].
+                mask := mask bitShift:-1.
+                outCount := outCount + 1.
+                outCount == 4 ifTrue:[
+                    formBytes at:dstIndex put:outBits.
+                    dstIndex := dstIndex + 1.
+                    outBits := 0.
+                    outCount := 0.
+                    mask == 0 ifTrue:[
+                        mask := 16r80.
+                    ]
+                ]
+            ].
+            (outCount == 0) ifFalse:[
+                [outCount == 4] whileFalse:[
+                    outCount := outCount + 1.
+                    outBits := outBits bitShift:2.
+                ].
+                formBytes at:dstIndex put:outBits.
+                dstIndex := dstIndex + 1.
+            ].
+            patternOffset := patternOffset + 1.
+            patternOffset == 9 ifTrue:[
+                patternOffset := 1
+            ]
+        ].
+        f := Form width:w height:h depth:depth.
+        f initGC.
+        f device drawBits:formBytes depth:2
+                    width:w height:h x:0 y:0
+                     into:f id x:0 y:0 width:w height:h with:f gcId.
+        ^ f
     ].
 
     "draw each pixel using dither color (let others do the dithering)
@@ -954,34 +954,36 @@
 
     srcIndex := 1.
     0 to:h-1 do:[:dstY |
-	run := 0.
-	last := nil.
-	0 to:w-1 do:[:dstX |
-	    r := bytes at:srcIndex.
-	    srcIndex := srcIndex + 1.
-	    g := bytes at:srcIndex.
-	    srcIndex := srcIndex + 1.
-	    b := bytes at:srcIndex.
-	    srcIndex := srcIndex + 1.
+        run := 0.
+        last := nil.
+        0 to:w-1 do:[:dstX |
+            r := bytes at:srcIndex.
+            srcIndex := srcIndex + 1.
+            g := bytes at:srcIndex.
+            srcIndex := srcIndex + 1.
+            b := bytes at:srcIndex.
+            srcIndex := srcIndex + 1.
 
-	    v := ((3 * r) + (6 * g) + (1 * b)) // 10.
+            v := ((3 * r) + (6 * g) + (1 * b)) // 10.
 
-	    clr := map at:(v + 1).
+            clr := map at:(v + 1).
 
-	    clr == last ifTrue:[
-		run := run + 1
-	    ] ifFalse:[
-		(run ~~ 0) ifTrue:[
-		    f fillRectangleX:dstX-run y:dstY width:run height:1.
-		].
-		run := 1.
-		f paint:clr.
-		last := clr
-	    ].
-	].
-	f fillRectangleX:width-run y:dstY width:run height:1.
+            clr == last ifTrue:[
+                run := run + 1
+            ] ifFalse:[
+                (run ~~ 0) ifTrue:[
+                    f fillRectangleX:dstX-run y:dstY width:run height:1.
+                ].
+                run := 1.
+                f paint:clr.
+                last := clr
+            ].
+        ].
+        f fillRectangleX:width-run y:dstY width:run height:1.
     ].
     ^ f
+
+    "Modified: 18.5.1996 / 15:41:58 / cg"
 !
 
 rgbImageAsPseudoFormOn:aDevice
@@ -1742,5 +1744,5 @@
 !Depth24Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.23 1996-04-25 16:22:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.24 1996-05-18 13:54:37 cg Exp $'
 ! !
--- a/Depth8Image.st	Sat May 18 11:40:40 1996 +0200
+++ b/Depth8Image.st	Sat May 18 15:55:32 1996 +0200
@@ -197,7 +197,7 @@
 "/     p1            "{Class: SmallInteger }" 
     |
 
-    Transcript showCr:'dithering ..'. Transcript endEntry.
+    Transcript showCR:'dithering ..'. Transcript endEntry.
 
     nDither := NumberOfDitherColors.
     ditherColors := Array new:nDither.
@@ -205,15 +205,15 @@
     first := (100 / nDither / 2).
     delta := 100 / nDither.
     0 to:nDither-1 do:[:i |
-	ditherColors at:i+1 put:(Color grey:(i * delta + first)).
+        ditherColors at:i+1 put:(Color grey:(i * delta + first)).
     ].
 
     map := Array new:256.
     1 to:256 do:[:i |
-	v := i - 1.
-	v := (v * (nDither - 1) // 255) rounded.
-	" v is now 0 .. nDither-1 "
-	map at:i put:(ditherColors at:(v + 1))
+        v := i - 1.
+        v := (v * (nDither - 1) // 255) rounded.
+        " v is now 0 .. nDither-1 "
+        map at:i put:(ditherColors at:(v + 1))
     ].
 
     depth := aDevice depth.
@@ -225,7 +225,7 @@
     h := height.
 
     depth == 1 ifTrue:[
-	^ self dither1PlaneUsingMap:map on:aDevice.
+        ^ self dither1PlaneUsingMap:map on:aDevice.
 
         
 "/      formBytes := ByteArray uninitializedNew:(w + 7 // 8) * h.
@@ -307,7 +307,7 @@
     ].
 
     depth == 2 ifTrue:[
-	^ self dither2PlaneUsingMap:map on:aDevice.
+        ^ self dither2PlaneUsingMap:map on:aDevice.
 
 "/      formBytes := ByteArray uninitializedNew:(w * 2 + 7 // 8) * h.
 "/      patterns := Array new:256.
@@ -409,28 +409,30 @@
 
     srcIndex := 1.
     1 to:h do:[:dstY |
-	run := 0.
-	last := nil.
-	1 to:w do:[:dstX |
-	    |clr v|
-	    v := bytes at:srcIndex.
-	    srcIndex := srcIndex + 1.
-	    clr := map at:(v + 1).
+        run := 0.
+        last := nil.
+        1 to:w do:[:dstX |
+            |clr v|
+            v := bytes at:srcIndex.
+            srcIndex := srcIndex + 1.
+            clr := map at:(v + 1).
 
-	    clr == last ifTrue:[
-		run := run + 1
-	    ] ifFalse:[
-		(run ~~ 0) ifTrue:[
-		    f fillRectangleX:dstX-run-1 y:dstY-1 width:run height:1.
-		].
-		run := 1.
-		f paint:clr.
-		last := clr
-	    ].
-	].
-	f fillRectangleX:width-run y:dstY-1 width:run height:1.
+            clr == last ifTrue:[
+                run := run + 1
+            ] ifFalse:[
+                (run ~~ 0) ifTrue:[
+                    f fillRectangleX:dstX-run-1 y:dstY-1 width:run height:1.
+                ].
+                run := 1.
+                f paint:clr.
+                last := clr
+            ].
+        ].
+        f fillRectangleX:width-run y:dstY-1 width:run height:1.
     ].
     ^ f
+
+    "Modified: 18.5.1996 / 15:42:00 / cg"
 ! !
 
 !Depth8Image methodsFor:'converting palette images'!
@@ -996,7 +998,7 @@
      srcIndex      "{Class: SmallInteger }"|
 
 
-    Transcript showCr:'dithering ..'. Transcript endEntry.
+    Transcript showCR:'dithering ..'. Transcript endEntry.
 
     nDither := NumberOfDitherColors.
     ditherColors := Array new:nDither.
@@ -1061,6 +1063,7 @@
     ^ f
 
     "Created: 2.5.1996 / 12:10:53 / cg"
+    "Modified: 18.5.1996 / 15:42:01 / cg"
 !
 
 paletteImageAsPseudoFormOn:aDevice
@@ -1860,5 +1863,5 @@
 !Depth8Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.37 1996-05-02 10:12:30 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Depth8Image.st,v 1.38 1996-05-18 13:55:00 cg Exp $'
 ! !
--- a/Image.st	Sat May 18 11:40:40 1996 +0200
+++ b/Image.st	Sat May 18 15:55:32 1996 +0200
@@ -1658,7 +1658,7 @@
      h             "{Class: SmallInteger }"
      run           "{Class: SmallInteger }" |
 
-    Transcript showCr:'slow dithering ..'. Transcript endEntry.
+    Transcript showCR:'slow dithering ..'. Transcript endEntry.
 
     w := width - 1.
     h := height - 1.
@@ -1671,27 +1671,29 @@
     f initGC.
 
     0 to:h do:[:dstY |
-	x0 := 0.
-	run := 0.
-	last := nil.
-	self atY:dstY from:0 to:w do:[:x :srcColor |
-	    |dstColor|
-
-	    srcColor ~~ last ifTrue:[
-		(run ~~ 0) ifTrue:[
-		    f fillRectangleX:x0 y:dstY width:run height:1.
-		].
-		run := 0.
-		dstColor := Color grey:(srcColor greyIntensity).
-		f paint:dstColor.
-		last := srcColor.
-		x0 := x
-	    ].
-	    run := run + 1
-	].
-	f fillRectangleX:x0 y:dstY width:run height:1.
+        x0 := 0.
+        run := 0.
+        last := nil.
+        self atY:dstY from:0 to:w do:[:x :srcColor |
+            |dstColor|
+
+            srcColor ~~ last ifTrue:[
+                (run ~~ 0) ifTrue:[
+                    f fillRectangleX:x0 y:dstY width:run height:1.
+                ].
+                run := 0.
+                dstColor := Color grey:(srcColor greyIntensity).
+                f paint:dstColor.
+                last := srcColor.
+                x0 := x
+            ].
+            run := run + 1
+        ].
+        f fillRectangleX:x0 y:dstY width:run height:1.
     ].
     ^ f
+
+    "Modified: 18.5.1996 / 15:42:23 / cg"
 !
 
 greyImageAsPseudoFormOn:aDevice
@@ -3697,6 +3699,6 @@
 !Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.71 1996-05-17 10:39:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.72 1996-05-18 13:55:32 cg Exp $'
 ! !
 Image initialize!