--- a/Depth24Image.st Tue Apr 22 19:24:17 1997 +0200
+++ b/Depth24Image.st Tue Apr 22 19:25:47 1997 +0200
@@ -225,15 +225,13 @@
ditherColors := Set new.
ditherColors addAll:(aDevice ditherColors).
- aDevice deviceColors do:[:anAvailableColor |
- ditherColors add:anAvailableColor.
- ].
+ ditherColors addAll:(aDevice deviceColors).
ditherColors := ditherColors asArray.
^ self
rgbImageAsDitheredPseudoFormOn:aDevice
colors:ditherColors.
- "Modified: 17.4.1997 / 00:08:45 / cg"
+ "Modified: 22.4.1997 / 11:59:44 / cg"
!
rgbImageAsDitheredPseudoFormOn:aDevice colors:fixColors
@@ -656,7 +654,7 @@
redArray greenArray blueArray
dataSize "{ Class: SmallInteger }"
nColors "{ Class: SmallInteger }"
- fit fitMap colors color
+ fit fitMap colors color ditherColors
fast
colorIndex "{ Class: SmallInteger }"
depth nColorCells deep nColorsNeeded|
@@ -695,7 +693,8 @@
nColors := 0.
srcIndex := 1.
dataSize := bytes size.
- [srcIndex < dataSize] whileTrue:[
+ [(srcIndex < dataSize)
+ and:[nColors <= nColorCells]] whileTrue:[
%{
if (__isByteArray(_INST(bytes))) {
int sI = _intVal(srcIndex);
@@ -752,16 +751,22 @@
(nColors <= nColorCells) ifTrue:[
fitMap := true
] ifFalse:[
- "must try again - cutting off some bits"
+ "/ must try again - cutting off some bits
+ "/ blue bits are snipped off faster.
(bMask == 2r11111111) ifTrue:[
- bMask := 2r11111110
+ bMask := 2r11111100
] ifFalse:[
- (bMask == 2r11111110) ifTrue:[
- bMask := 2r11111100
+ (bMask == 2r11111100) ifTrue:[
+ bMask := 2r11110000
] ifFalse:[
- rMask := (rMask bitShift:1) bitAnd:2r11111111.
- gMask := (gMask bitShift:1) bitAnd:2r11111111.
- bMask := (bMask bitShift:1) bitAnd:2r11111111
+ (rMask == 2r11111111) ifTrue:[
+ rMask := 2r11111100.
+ gMask := 2r11111100.
+ ] ifFalse:[
+ rMask := (rMask bitShift:1) bitAnd:2r11111111.
+ gMask := (gMask bitShift:1) bitAnd:2r11111111.
+ bMask := (bMask bitShift:1) bitAnd:2r11111111
+ ]
]
].
'Depth24Image [info]: too many colors; retry with less color resolution' infoPrintCR.
@@ -830,14 +835,19 @@
"cut off one more color-bit - cut off blue first"
(bMask == 2r11111111) ifTrue:[
- bMask := 2r11111110
+ bMask := 2r11111100
] ifFalse:[
- (bMask == 2r11111110) ifTrue:[
- bMask := 2r11111100
+ (bMask == 2r11111100) ifTrue:[
+ bMask := 2r11110000
] ifFalse:[
- rMask := (rMask bitShift:1) bitAnd:2r11111111.
- gMask := (gMask bitShift:1) bitAnd:2r11111111.
- bMask := (bMask bitShift:1) bitAnd:2r11111111
+ (rMask == 2r11111111) ifTrue:[
+ rMask := 2r11111100.
+ gMask := 2r11111100.
+ ] ifFalse:[
+ rMask := (rMask bitShift:1) bitAnd:2r11111111.
+ gMask := (gMask bitShift:1) bitAnd:2r11111111.
+ bMask := (bMask bitShift:1) bitAnd:2r11111111
+ ]
]
].
fitMap := false.
@@ -857,10 +867,11 @@
"/
DitherAlgorithm == #floydSteinberg ifTrue:[
colors := colors asSet.
- colors addAll:(aDevice ditherColors).
- aDevice deviceColors do:[:anAvailableColor |
- colors add:anAvailableColor.
- ].
+"/ ditherColors := aDevice availableDitherColors.
+"/ ditherColors notNil ifTrue:[
+"/ colors addAll:ditherColors.
+"/ ].
+ colors addAll:aDevice deviceColors.
colors := colors asArray.
f := self rgbImageAsDitheredPseudoFormOn:aDevice colors:colors.
f notNil ifTrue:[^ f].
@@ -1959,5 +1970,5 @@
!Depth24Image class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.46 1997-04-16 22:10:18 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.47 1997-04-22 17:25:47 cg Exp $'
! !