author | Stefan Vogel <sv@exept.de> |
Mon, 08 Aug 2016 17:13:09 +0200 | |
changeset 7500 | 8839e85feeed |
parent 6300 | 09864d94c7bf |
child 7513 | 69d02ee0a01a |
permissions | -rw-r--r-- |
3 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
81 | 3 |
All Rights Reserved |
3 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
3263 | 12 |
"{ Package: 'stx:libview' }" |
13 |
||
7500 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1 | 16 |
Image subclass:#Depth2Image |
579 | 17 |
instanceVariableNames:'' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Graphics-Images' |
|
1 | 21 |
! |
22 |
||
46 | 23 |
!Depth2Image class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
81 | 28 |
All Rights Reserved |
3 | 29 |
|
46 | 30 |
This software is furnished under a license and may be used |
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
3 | 38 |
|
46 | 39 |
documentation |
40 |
" |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
41 |
this class represents four-color (2 bit / pixel) images |
46 | 42 |
(as used mainly on the NeXT). |
43 |
It mainly consists of methods already implemented in Image, |
|
44 |
reimplemented here for more performance. |
|
611 | 45 |
|
798 | 46 |
#blackIs0 / #whiteIs0 and #palette formats are supported here. |
47 |
||
611 | 48 |
[author:] |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
49 |
Claus Gittinger |
611 | 50 |
|
51 |
[see also:] |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
52 |
Depth1Image Depth4Image Depth8Image Depth16Image Depth24Image |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
53 |
ImageReader |
46 | 54 |
" |
55 |
! ! |
|
3 | 56 |
|
89 | 57 |
!Depth2Image class methodsFor:'queries'! |
58 |
||
59 |
imageDepth |
|
579 | 60 |
"return the depth of images represented by instances of |
61 |
this class - here we return 2" |
|
62 |
||
89 | 63 |
^ 2 |
579 | 64 |
|
65 |
"Modified: 20.4.1996 / 23:40:12 / cg" |
|
89 | 66 |
! ! |
67 |
||
3263 | 68 |
!Depth2Image methodsFor:'accessing-pixels'! |
1 | 69 |
|
1656
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
70 |
pixelAtX:x y:y |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
71 |
"retrieve a pixel at x/y; return a pixel value. |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
72 |
Pixels start at x=0 , y=0 for upper left pixel, end at |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
73 |
x = width-1, y=height-1 for lower right pixel" |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
74 |
|
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
75 |
|lineIndex "{ Class: SmallInteger }" |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
76 |
byte "{ Class: SmallInteger }" |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
77 |
shift "{ Class: SmallInteger }" | |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
78 |
|
6300 | 79 |
pixelFunction notNil ifTrue:[^ pixelFunction value:x value:y]. |
80 |
||
1656
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
81 |
lineIndex := (self bytesPerRow * y) + 1. |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
82 |
|
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
83 |
"left pixel in high bits" |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
84 |
byte := bytes at:(lineIndex + (x // 4)). |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
85 |
shift := #(-6 -4 -2 0) at:((x \\ 4) + 1). |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
86 |
^ (byte bitShift:shift) bitAnd:3. |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
87 |
|
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
88 |
"Created: 24.4.1997 / 16:06:39 / cg" |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
89 |
! |
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
90 |
|
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
91 |
pixelAtX:x y:y put:aPixelValue |
1 | 92 |
"set the pixel at x/y to aPixelValue. |
93 |
Pixels start at x=0 , y=0 for upper left pixel, end at |
|
94 |
x = width-1, y=height-1 for lower right pixel" |
|
95 |
||
38 | 96 |
|lineIndex "{ Class: SmallInteger }" |
97 |
index "{ Class: SmallInteger }" |
|
98 |
byte "{ Class: SmallInteger }" |
|
99 |
shift "{ Class: SmallInteger }" | |
|
1 | 100 |
|
101 |
lineIndex := (self bytesPerRow * y) + 1. |
|
102 |
||
103 |
"left pixel is in high bits" |
|
104 |
index := lineIndex + (x // 4). |
|
105 |
byte := bytes at:index. |
|
106 |
shift := #(6 4 2 0) at:((x \\ 4) + 1). |
|
107 |
byte := (byte bitAnd:(3 bitShift:shift) bitInvert) bitOr:(aPixelValue bitShift:shift). |
|
108 |
bytes at:index put:byte |
|
109 |
||
1656
ebcad6911ddb
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
110 |
"Created: 24.4.1997 / 17:06:36 / cg" |
1 | 111 |
! ! |
112 |
||
3178 | 113 |
!Depth2Image methodsFor:'converting images'! |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
114 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
115 |
anyImageAsTrueColorFormOn:aDevice |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
116 |
"return a true-color device-form for the receiver. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
117 |
Supports true color devices with depths: 8, 16, 24 and 32" |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
118 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
119 |
|depth |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
120 |
colorValues |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
121 |
form imageBits bestFormat usedDeviceDepth usedDeviceBitsPerPixel |
3851
34637f468b2a
also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents:
3842
diff
changeset
|
122 |
usedDevicePadding usedDeviceBytesPerRow padd| |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
123 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
124 |
depth := aDevice depth. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
125 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
126 |
"/ gather r/g/b values for all colors in the map ... |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
127 |
|
2204
d58ed106b422
use common colorMap helper when converting to rgb-device form
Claus Gittinger <cg@exept.de>
parents:
2201
diff
changeset
|
128 |
colorValues := self rgbColormapFor:aDevice. |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
129 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
130 |
bestFormat := self bestSupportedImageFormatFor:aDevice. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
131 |
usedDeviceDepth := bestFormat at:#depth. |
2864
dd151bfdff9d
care for deep devices which do not support deep bitmaps
Claus Gittinger <cg@exept.de>
parents:
2401
diff
changeset
|
132 |
usedDeviceDepth == 1 ifTrue:[ |
7500 | 133 |
^ self asMonochromeFormOn:aDevice |
2864
dd151bfdff9d
care for deep devices which do not support deep bitmaps
Claus Gittinger <cg@exept.de>
parents:
2401
diff
changeset
|
134 |
]. |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
135 |
usedDeviceBitsPerPixel := bestFormat at:#bitsPerPixel. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
136 |
usedDevicePadding := bestFormat at:#padding. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
137 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
138 |
usedDeviceBytesPerRow := self class bytesPerRowForWidth:width depth:usedDeviceBitsPerPixel padding:usedDevicePadding. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
139 |
padd := usedDeviceBytesPerRow -( self class bytesPerRowForWidth:width depth:usedDeviceBitsPerPixel padding:8). |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
140 |
imageBits := ByteArray uninitializedNew:(usedDeviceBytesPerRow * height). |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
141 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
142 |
"/ for now, only support some depths |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
143 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
144 |
usedDeviceBitsPerPixel == 16 ifTrue:[ |
7500 | 145 |
"/ 16 bits/pixel |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
146 |
|
7500 | 147 |
"/ now, walk over the image and replace |
148 |
"/ colorMap indices by color values in the bits array |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
149 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
150 |
%{ |
7500 | 151 |
unsigned char *srcPtr = 0; |
152 |
unsigned char *dstPtr = 0; |
|
153 |
OBJ _bytes = __INST(bytes); |
|
3851
34637f468b2a
also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents:
3842
diff
changeset
|
154 |
|
7500 | 155 |
if (__isByteArrayLike(_bytes)) { |
156 |
srcPtr = __ByteArrayInstPtr(_bytes)->ba_element; |
|
157 |
} else { |
|
158 |
if (__isExternalBytesLike(_bytes)) { |
|
159 |
srcPtr = __externalBytesAddress(_bytes); |
|
160 |
} |
|
161 |
} |
|
162 |
if (__isByteArray(imageBits)) { |
|
163 |
dstPtr = __ByteArrayInstPtr(imageBits)->ba_element; |
|
164 |
} else { |
|
165 |
if (__isExternalBytesLike(imageBits)) { |
|
166 |
dstPtr = __externalBytesAddress(imageBits); |
|
167 |
} |
|
168 |
} |
|
3851
34637f468b2a
also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents:
3842
diff
changeset
|
169 |
|
7500 | 170 |
if (__bothSmallInteger(__INST(height), __INST(width)) |
171 |
&& __isArrayLike(colorValues) |
|
172 |
&& srcPtr |
|
173 |
&& dstPtr) { |
|
174 |
int r,p; |
|
175 |
int x, y, w, h, nPix; |
|
176 |
int byte, shift; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
177 |
|
7500 | 178 |
OBJ *ap = __ArrayInstPtr(colorValues)->a_element; |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
179 |
|
7500 | 180 |
w = __intVal(__INST(width)); |
181 |
h = __intVal(__INST(height)); |
|
182 |
r = 0; |
|
183 |
p = __intVal(padd); |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
184 |
|
7500 | 185 |
nPix = w * h; |
186 |
shift = -2; |
|
187 |
while (nPix-- > 0) { |
|
188 |
unsigned idx, v; |
|
189 |
OBJ clr; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
190 |
|
7500 | 191 |
if (shift < 0) { |
192 |
byte = *srcPtr++; |
|
193 |
shift = 6; |
|
194 |
} |
|
195 |
idx = (byte >> shift) & 3; |
|
196 |
shift -= 2; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
197 |
|
7500 | 198 |
clr = ap[idx]; |
199 |
v = __intVal(clr); |
|
2401 | 200 |
#ifdef __MSBFIRST |
7500 | 201 |
((short *)dstPtr)[0] = v; |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
202 |
#else |
2225
8fb244eaaf90
the SWAP_BYTES macro does not work yet.
Claus Gittinger <cg@exept.de>
parents:
2214
diff
changeset
|
203 |
# ifdef xxSWAP_BYTES |
7500 | 204 |
SWAP_BYTES(v); |
205 |
((short *)dstPtr)[0] = v; |
|
2214
452bd64584d6
use SWAP_BYTES macro, if defined
Claus Gittinger <cg@exept.de>
parents:
2204
diff
changeset
|
206 |
# else |
7500 | 207 |
dstPtr[0] = (v>>8) & 0xFF; |
208 |
dstPtr[1] = (v) & 0xFF; |
|
2214
452bd64584d6
use SWAP_BYTES macro, if defined
Claus Gittinger <cg@exept.de>
parents:
2204
diff
changeset
|
209 |
# endif |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
210 |
#endif |
7500 | 211 |
dstPtr += 2; |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
212 |
|
7500 | 213 |
if (++r == w) { |
214 |
dstPtr += p; |
|
215 |
r = 0; |
|
216 |
shift = -2; |
|
217 |
} |
|
218 |
} |
|
219 |
} |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
220 |
%}. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
221 |
] ifFalse:[ |
7500 | 222 |
usedDeviceBitsPerPixel == 32 ifTrue:[ |
223 |
"/ 32 bits/pixel |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
224 |
|
7500 | 225 |
"/ now, walk over the image and replace |
226 |
"/ colorMap indices by color values in the bits array |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
227 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
228 |
%{ |
7500 | 229 |
unsigned char *srcPtr = 0; |
230 |
unsigned char *dstPtr = 0; |
|
231 |
OBJ _bytes = __INST(bytes); |
|
3851
34637f468b2a
also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents:
3842
diff
changeset
|
232 |
|
7500 | 233 |
if (__isByteArrayLike(_bytes)) { |
234 |
srcPtr = __ByteArrayInstPtr(_bytes)->ba_element; |
|
235 |
} else { |
|
236 |
if (__isExternalBytesLike(_bytes)) { |
|
237 |
srcPtr = __externalBytesAddress(_bytes); |
|
238 |
} |
|
239 |
} |
|
240 |
if (__isByteArray(imageBits)) { |
|
241 |
dstPtr = __ByteArrayInstPtr(imageBits)->ba_element; |
|
242 |
} else { |
|
243 |
if (__isExternalBytesLike(imageBits)) { |
|
244 |
dstPtr = __externalBytesAddress(imageBits); |
|
245 |
} |
|
246 |
} |
|
3851
34637f468b2a
also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents:
3842
diff
changeset
|
247 |
|
7500 | 248 |
if (__bothSmallInteger(__INST(height), __INST(width)) |
249 |
&& __isArrayLike(colorValues) |
|
250 |
&& srcPtr |
|
251 |
&& dstPtr) { |
|
252 |
int x, y, w, h, nPix; |
|
253 |
int r,p; |
|
254 |
int byte, shift; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
255 |
|
7500 | 256 |
OBJ *ap = __ArrayInstPtr(colorValues)->a_element; |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
257 |
|
7500 | 258 |
w = __intVal(__INST(width)); |
259 |
h = __intVal(__INST(height)); |
|
260 |
r = 0; |
|
261 |
p = __intVal(padd); |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
262 |
|
7500 | 263 |
nPix = w * h; |
264 |
shift = -2; |
|
265 |
while (nPix > 0) { |
|
266 |
unsigned idx, v; |
|
267 |
OBJ clr; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
268 |
|
7500 | 269 |
if (shift < 0) { |
270 |
byte = *srcPtr++; |
|
271 |
shift = 6; |
|
272 |
} |
|
273 |
idx = (byte >> shift) & 3; |
|
274 |
shift -= 2; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
275 |
|
7500 | 276 |
clr = ap[idx]; |
277 |
v = __intVal(clr); |
|
2401 | 278 |
#ifdef __MSBFIRST |
7500 | 279 |
((long *)dstPtr)[0] = v; |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
280 |
#else |
7500 | 281 |
dstPtr[0] = (v>>24) & 0xFF; |
282 |
dstPtr[1] = (v>>16) & 0xFF; |
|
283 |
dstPtr[2] = (v>>8) & 0xFF; |
|
284 |
dstPtr[3] = (v) & 0xFF; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
285 |
#endif |
7500 | 286 |
dstPtr += 4; |
287 |
nPix--; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
288 |
|
7500 | 289 |
if (++r == w) { |
290 |
dstPtr += p; |
|
291 |
r = 0; |
|
292 |
shift = -2; |
|
293 |
} |
|
294 |
} |
|
295 |
} |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
296 |
%}. |
7500 | 297 |
] ifFalse:[ |
298 |
usedDeviceBitsPerPixel == 8 ifTrue:[ |
|
299 |
"/ 8 bits/pixel |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
300 |
|
7500 | 301 |
"/ now, walk over the image and replace |
302 |
"/ colorMap indices by color values in the bits array |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
303 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
304 |
%{ |
7500 | 305 |
unsigned char *srcPtr = 0; |
306 |
unsigned char *dstPtr = 0; |
|
307 |
OBJ _bytes = __INST(bytes); |
|
3851
34637f468b2a
also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents:
3842
diff
changeset
|
308 |
|
7500 | 309 |
if (__isByteArrayLike(_bytes)) { |
310 |
srcPtr = __ByteArrayInstPtr(_bytes)->ba_element; |
|
311 |
} else { |
|
312 |
if (__isExternalBytesLike(_bytes)) { |
|
313 |
srcPtr = __externalBytesAddress(_bytes); |
|
314 |
} |
|
315 |
} |
|
316 |
if (__isByteArray(imageBits)) { |
|
317 |
dstPtr = __ByteArrayInstPtr(imageBits)->ba_element; |
|
318 |
} else { |
|
319 |
if (__isExternalBytesLike(imageBits)) { |
|
320 |
dstPtr = __externalBytesAddress(imageBits); |
|
321 |
} |
|
322 |
} |
|
3851
34637f468b2a
also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents:
3842
diff
changeset
|
323 |
|
7500 | 324 |
if (__bothSmallInteger(__INST(height), __INST(width)) |
325 |
&& __isArrayLike(colorValues) |
|
326 |
&& srcPtr |
|
327 |
&& dstPtr) { |
|
328 |
int x, y, w, h, nPix; |
|
329 |
int r,p, byte, shift; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
330 |
|
7500 | 331 |
OBJ *ap = __ArrayInstPtr(colorValues)->a_element; |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
332 |
|
7500 | 333 |
w = __intVal(__INST(width)); |
334 |
h = __intVal(__INST(height)); |
|
335 |
r = 0; |
|
336 |
p = __intVal(padd); |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
337 |
|
7500 | 338 |
nPix = w * h; |
339 |
shift = -2; |
|
340 |
while (nPix > 0) { |
|
341 |
unsigned idx, v; |
|
342 |
OBJ clr; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
343 |
|
7500 | 344 |
if (shift < 0) { |
345 |
byte = *srcPtr++; |
|
346 |
shift = 6; |
|
347 |
} |
|
348 |
idx = (byte >> shift) & 3; |
|
349 |
shift -= 2; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
350 |
|
7500 | 351 |
clr = ap[idx]; |
352 |
v = __intVal(clr); |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
353 |
|
7500 | 354 |
dstPtr[0] = v; |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
355 |
|
7500 | 356 |
dstPtr += 1; |
357 |
nPix--; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
358 |
|
7500 | 359 |
if (++r == w) { |
360 |
dstPtr += p; |
|
361 |
r = 0; |
|
362 |
shift = -2; |
|
363 |
} |
|
364 |
} |
|
365 |
} |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
366 |
%}. |
7500 | 367 |
] ifFalse:[ |
368 |
usedDeviceBitsPerPixel == 24 ifTrue:[ |
|
369 |
"/ 24 bits/pixel |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
370 |
|
7500 | 371 |
"/ now, walk over the image and replace |
372 |
"/ colorMap indices by color values in the bits array |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
373 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
374 |
%{ |
7500 | 375 |
unsigned char *srcPtr = 0; |
376 |
unsigned char *dstPtr = 0; |
|
377 |
OBJ _bytes = __INST(bytes); |
|
3851
34637f468b2a
also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents:
3842
diff
changeset
|
378 |
|
7500 | 379 |
if (__isByteArrayLike(_bytes)) { |
380 |
srcPtr = __ByteArrayInstPtr(_bytes)->ba_element; |
|
381 |
} else { |
|
382 |
if (__isExternalBytesLike(_bytes)) { |
|
383 |
srcPtr = __externalBytesAddress(_bytes); |
|
384 |
} |
|
385 |
} |
|
386 |
if (__isByteArray(imageBits)) { |
|
387 |
dstPtr = __ByteArrayInstPtr(imageBits)->ba_element; |
|
388 |
} else { |
|
389 |
if (__isExternalBytesLike(imageBits)) { |
|
390 |
dstPtr = __externalBytesAddress(imageBits); |
|
391 |
} |
|
392 |
} |
|
3851
34637f468b2a
also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents:
3842
diff
changeset
|
393 |
|
7500 | 394 |
if (__bothSmallInteger(__INST(height), __INST(width)) |
395 |
&& __isArrayLike(colorValues) |
|
396 |
&& srcPtr |
|
397 |
&& dstPtr) { |
|
398 |
int x, y, w, h, nPix; |
|
399 |
int r, p, byte, shift; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
400 |
|
7500 | 401 |
OBJ *ap = __ArrayInstPtr(colorValues)->a_element; |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
402 |
|
7500 | 403 |
w = __intVal(__INST(width)); |
404 |
h = __intVal(__INST(height)); |
|
405 |
r = 0; |
|
406 |
p = __intVal(padd); |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
407 |
|
7500 | 408 |
nPix = w * h; |
409 |
shift = -2; |
|
410 |
while (nPix > 0) { |
|
411 |
unsigned idx, v; |
|
412 |
OBJ clr; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
413 |
|
7500 | 414 |
if (shift < 0) { |
415 |
byte = *srcPtr++; |
|
416 |
shift = 6; |
|
417 |
} |
|
418 |
idx = (byte >> shift) & 3; |
|
419 |
shift -= 2; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
420 |
|
7500 | 421 |
clr = ap[idx]; |
422 |
v = __intVal(clr); |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
423 |
|
7500 | 424 |
dstPtr[0] = (v>>16) & 0xFF; |
425 |
dstPtr[1] = (v>>8) & 0xFF; |
|
426 |
dstPtr[2] = (v) & 0xFF; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
427 |
|
7500 | 428 |
dstPtr += 3; |
429 |
nPix--; |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
430 |
|
7500 | 431 |
if (++r == w) { |
432 |
dstPtr += p; |
|
433 |
r = 0; |
|
434 |
shift = -2; |
|
435 |
} |
|
436 |
} |
|
437 |
} |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
438 |
%}. |
7500 | 439 |
] ifFalse:[ |
440 |
'Image [warning]: unimplemented trueColor depth in anyImageAsTrueColorFormOn: ' errorPrint. usedDeviceBitsPerPixel errorPrintCR. |
|
441 |
^ nil |
|
442 |
] |
|
443 |
] |
|
444 |
] |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
445 |
]. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
446 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
447 |
imageBits isNil ifTrue:[ |
7500 | 448 |
^ nil |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
449 |
]. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
450 |
|
7500 | 451 |
form := Form imageForm width:width height:height depth:usedDeviceDepth onDevice:aDevice. |
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
452 |
form isNil ifTrue:[^ nil]. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
453 |
form initGC. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
454 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
455 |
form |
7500 | 456 |
copyBitsFrom:imageBits |
457 |
bitsPerPixel:usedDeviceBitsPerPixel |
|
458 |
depth:usedDeviceDepth |
|
459 |
padding:usedDevicePadding |
|
460 |
width:width height:height |
|
461 |
x:0 y:0 |
|
462 |
toX:0 y:0. |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
463 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
464 |
^ form |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
465 |
|
4765 | 466 |
"Created: / 20-10-1995 / 22:05:10 / cg" |
467 |
"Modified: / 29-05-2007 / 19:22:29 / cg" |
|
2200
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
468 |
! |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
469 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
470 |
greyImageAsTrueColorFormOn:aDevice |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
471 |
"return a true-color device-form for the grey-image receiver. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
472 |
Supports true color devices with depths: 8, 16, 24 and 32" |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
473 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
474 |
|f| |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
475 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
476 |
f := self anyImageAsTrueColorFormOn:aDevice. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
477 |
f notNil ifTrue:[^ f]. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
478 |
^ super greyImageAsTrueColorFormOn:aDevice |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
479 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
480 |
"Created: / 28.7.1998 / 16:57:32 / cg" |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
481 |
! |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
482 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
483 |
paletteImageAsTrueColorFormOn:aDevice |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
484 |
"return a true-color device-form for the palette-image receiver. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
485 |
Supports true color devices with depths: 8, 16, 24 and 32" |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
486 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
487 |
|f| |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
488 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
489 |
f := self anyImageAsTrueColorFormOn:aDevice. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
490 |
f notNil ifTrue:[^ f]. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
491 |
^ super paletteImageAsTrueColorFormOn:aDevice |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
492 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
493 |
"Created: / 28.7.1998 / 16:57:47 / cg" |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
494 |
! |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
495 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
496 |
rgbImageAsTrueColorFormOn:aDevice |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
497 |
"return a true-color device-form for the rgb-image receiver. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
498 |
Supports true color devices with depths: 8, 16, 24 and 32" |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
499 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
500 |
|f| |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
501 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
502 |
f := self anyImageAsTrueColorFormOn:aDevice. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
503 |
f notNil ifTrue:[^ f]. |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
504 |
^ super rgbImageAsTrueColorFormOn:aDevice |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
505 |
|
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
506 |
"Created: / 28.7.1998 / 16:58:01 / cg" |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
507 |
! ! |
4e3c5b30b2c1
tuned conversion to true-color.
Claus Gittinger <cg@exept.de>
parents:
2178
diff
changeset
|
508 |
|
810 | 509 |
!Depth2Image methodsFor:'dither helpers'! |
798 | 510 |
|
511 |
orderedDitheredMonochromeBitsWithDitherMatrix:ditherMatrix ditherWidth:dW |
|
512 |
"return the dithered monochrome bits for the receiver image; |
|
513 |
with a constant ditherMatrix, this can be used for thresholding. |
|
514 |
Redefined to make use of knowing that pixels are 2-bit values." |
|
515 |
||
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
516 |
|dH nDither bytes |
798 | 517 |
greyMap monoBits |
518 |
bytesPerMonoRow "{Class: SmallInteger }" |
|
519 |
bytesPerRow "{Class: SmallInteger }" |
|
520 |
w "{Class: SmallInteger }" |
|
521 |
h "{Class: SmallInteger }"| |
|
522 |
||
523 |
nDither := ditherMatrix size. |
|
524 |
dH := nDither / dW. |
|
525 |
||
526 |
w := width. |
|
527 |
h := height. |
|
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
528 |
bytes := self bits. |
798 | 529 |
|
530 |
bytesPerRow := self bytesPerRow. |
|
531 |
||
532 |
bytesPerMonoRow := w + 7 // 8. |
|
533 |
monoBits := ByteArray uninitializedNew:(bytesPerMonoRow * h). |
|
534 |
(monoBits isNil or:[bytes isNil]) ifTrue:[ |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
535 |
^ nil |
798 | 536 |
]. |
537 |
||
803
899f7eb32ef2
support #rgb - specialized code relaxed
Claus Gittinger <cg@exept.de>
parents:
798
diff
changeset
|
538 |
greyMap := self greyByteMapForRange:nDither. |
798 | 539 |
|
540 |
%{ |
|
541 |
int __dW = __intVal(dW); |
|
542 |
int __dH = __intVal(dH); |
|
543 |
int __byte; |
|
544 |
int __dT; |
|
545 |
int __dstIdx = 0; |
|
546 |
int __srcIdx = 0; |
|
547 |
int __bitCnt; |
|
548 |
int __inByte; |
|
549 |
int __grey; |
|
550 |
int __w = __intVal(w); |
|
551 |
int __h = __intVal(h); |
|
552 |
int __x; |
|
553 |
int __y; |
|
554 |
int __oX, __oY, __dY; |
|
555 |
int __nextDst; |
|
556 |
int __nextSrc; |
|
557 |
int __bytesPerRow = __intVal(bytesPerRow); |
|
558 |
int __bytesPerMonoRow = __intVal(bytesPerMonoRow); |
|
559 |
||
1812
beeaf75b245b
avoid type warnings (char * vs. unsigned char *)
Claus Gittinger <cg@exept.de>
parents:
1656
diff
changeset
|
560 |
unsigned char *__monoBits = __ByteArrayInstPtr(monoBits)->ba_element; |
808 | 561 |
unsigned char *__ditherMatrix = __ByteArrayInstPtr(ditherMatrix)->ba_element; |
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
562 |
unsigned char *__bytes = __ByteArrayInstPtr(bytes)->ba_element; |
798 | 563 |
unsigned char *__greyMap = __ByteArrayInstPtr(greyMap)->ba_element; |
564 |
||
565 |
__oY = __dY = 0; |
|
566 |
for (__y=0; __y<__h; __y++) { |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
567 |
__nextDst = __dstIdx + __bytesPerMonoRow; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
568 |
__nextSrc = __srcIdx + __bytesPerRow; |
798 | 569 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
570 |
__byte = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
571 |
__bitCnt = 8; |
798 | 572 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
573 |
__oX = 0; |
798 | 574 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
575 |
for (__x=0; __x<__w; __x++) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
576 |
if ((__x & 3) == 0) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
577 |
__inByte = __bytes[__srcIdx]; /* 0..255 */ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
578 |
__srcIdx++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
579 |
} else { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
580 |
__inByte = __inByte << 2; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
581 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
582 |
__grey = (__inByte >> 6) & 3; |
798 | 583 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
584 |
__grey = __greyMap[__grey]; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
585 |
__dT = __ditherMatrix[__dY + __oX]; |
798 | 586 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
587 |
__oX++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
588 |
if (__oX == __dW) __oX = 0; |
798 | 589 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
590 |
__byte = __byte << 1; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
591 |
if (__grey > __dT) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
592 |
__byte = __byte | 1; /* white */ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
593 |
} |
798 | 594 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
595 |
__bitCnt--; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
596 |
if (__bitCnt == 0) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
597 |
__monoBits[__dstIdx] = __byte; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
598 |
__dstIdx++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
599 |
__byte = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
600 |
__bitCnt = 8; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
601 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
602 |
} |
798 | 603 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
604 |
if (__bitCnt != 8) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
605 |
__byte = __byte << __bitCnt; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
606 |
__monoBits[__dstIdx] = __byte; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
607 |
} |
798 | 608 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
609 |
__oY++; __dY += __dW; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
610 |
if (__oY == __dH) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
611 |
__oY = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
612 |
__dY = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
613 |
} |
798 | 614 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
615 |
__srcIdx = __nextSrc; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
616 |
__dstIdx = __nextDst; |
798 | 617 |
} |
618 |
%}. |
|
619 |
||
620 |
^ monoBits |
|
621 |
! ! |
|
622 |
||
280 | 623 |
!Depth2Image methodsFor:'enumerating'! |
624 |
||
798 | 625 |
colorsAtY:y from:xLow to:xHigh do:aBlock |
280 | 626 |
"perform aBlock for each pixel from x1 to x2 in row y. |
627 |
The block is passed the color at each pixel. |
|
628 |
This method allows slighly faster processing of an |
|
629 |
image than using atX:y:, since some processing can be |
|
630 |
avoided when going from pixel to pixel. However, for |
|
631 |
real image processing, specialized methods should be written." |
|
632 |
||
633 |
|srcIndex "{ Class: SmallInteger }" |
|
634 |
byte "{ Class: SmallInteger }" |
|
635 |
shift "{ Class: SmallInteger }" |
|
636 |
value "{ Class: SmallInteger }" |
|
637 |
x1 "{ Class: SmallInteger }" |
|
638 |
x2 "{ Class: SmallInteger }" |
|
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
639 |
color0 color1 color2 color3 bytes| |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
640 |
|
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
641 |
bytes := self bits. |
280 | 642 |
|
2226 | 643 |
color0 := self colorFromValue:0. |
644 |
color1 := self colorFromValue:1. |
|
645 |
color2 := self colorFromValue:2. |
|
646 |
color3 := self colorFromValue:3. |
|
280 | 647 |
|
648 |
"left pixel in high bits" |
|
649 |
||
650 |
x1 := xLow. |
|
651 |
x2 := xHigh. |
|
652 |
||
653 |
srcIndex := (self bytesPerRow * y) + 1. |
|
654 |
srcIndex := srcIndex + (x1 // 4). |
|
655 |
shift := #(-6 -4 -2 0) at:((x1 \\ 4) + 1). |
|
656 |
||
798 | 657 |
byte := bytes at:srcIndex. |
280 | 658 |
x1 to:x2 do:[:x | |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
659 |
|clr| |
2226 | 660 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
661 |
value := (byte bitShift:shift) bitAnd:3. |
280 | 662 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
663 |
(value == 0) ifTrue:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
664 |
clr := color0 |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
665 |
] ifFalse:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
666 |
(value == 1) ifTrue:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
667 |
clr := color1 |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
668 |
] ifFalse:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
669 |
(value == 2) ifTrue:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
670 |
clr := color2 |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
671 |
] ifFalse:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
672 |
clr := color3 |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
673 |
] |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
674 |
] |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
675 |
]. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
676 |
aBlock value:x value:clr. |
280 | 677 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
678 |
shift == 0 ifTrue:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
679 |
shift := -6. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
680 |
srcIndex := srcIndex + 1. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
681 |
x < x2 ifTrue:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
682 |
byte := bytes at:srcIndex. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
683 |
] |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
684 |
] ifFalse:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
685 |
shift := shift + 2. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
686 |
] |
280 | 687 |
]. |
746 | 688 |
|
798 | 689 |
"Created: 7.6.1996 / 19:12:31 / cg" |
810 | 690 |
"Modified: 10.6.1996 / 10:32:47 / cg" |
280 | 691 |
! |
692 |
||
798 | 693 |
valuesAtY:y from:xLow to:xHigh do:aBlock |
280 | 694 |
"perform aBlock for each pixelValue from x1 to x2 in row y. |
695 |
The block is passed the x coordinate and the pixelValue at each pixel. |
|
696 |
This method allows slighly faster processing of an |
|
697 |
image than using valueAtX:y:, since some processing can be |
|
698 |
avoided when going from pixel to pixel. However, for |
|
699 |
real image processing, specialized methods should be written." |
|
700 |
||
701 |
|srcIndex "{ Class: SmallInteger }" |
|
702 |
byte "{ Class: SmallInteger }" |
|
703 |
shift "{ Class: SmallInteger }" |
|
704 |
value "{ Class: SmallInteger }" |
|
705 |
x1 "{ Class: SmallInteger }" |
|
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
706 |
x2 "{ Class: SmallInteger }" |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
707 |
bytes| |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
708 |
|
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
709 |
bytes := self bits. |
280 | 710 |
|
711 |
"left pixel in high bits" |
|
712 |
||
713 |
x1 := xLow. |
|
714 |
x2 := xHigh. |
|
715 |
||
716 |
srcIndex := (self bytesPerRow * y) + 1. |
|
717 |
srcIndex := srcIndex + (x1 // 4). |
|
718 |
shift := #(-6 -4 -2 0) at:((x1 \\ 4) + 1). |
|
719 |
||
798 | 720 |
byte := bytes at:srcIndex. |
280 | 721 |
x1 to:x2 do:[:x | |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
722 |
value := (byte bitShift:shift) bitAnd:3. |
280 | 723 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
724 |
aBlock value:x value:value. |
280 | 725 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
726 |
shift == 0 ifTrue:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
727 |
shift := -6. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
728 |
srcIndex := srcIndex + 1. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
729 |
x < x2 ifTrue:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
730 |
byte := bytes at:srcIndex. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
731 |
] |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
732 |
] ifFalse:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
733 |
shift := shift + 2. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
734 |
] |
280 | 735 |
]. |
798 | 736 |
|
737 |
"Created: 7.6.1996 / 19:09:42 / cg" |
|
806 | 738 |
"Modified: 8.6.1996 / 13:36:28 / cg" |
280 | 739 |
! ! |
740 |
||
1 | 741 |
!Depth2Image methodsFor:'magnification'! |
742 |
||
743 |
magnifyRowFrom:srcBytes offset:srcStart |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
744 |
into:dstBytes offset:dstStart factor:mX |
1 | 745 |
|
746 |
"magnify a single pixel row - can only magnify by integer factors" |
|
747 |
||
748 |
%{ |
|
749 |
unsigned char *srcP, *dstP; |
|
750 |
int _mag; |
|
751 |
REGISTER int i; |
|
752 |
REGISTER unsigned char _byte; |
|
753 |
int _pixels; |
|
754 |
REGISTER int outcnt, bits, bit, mask, incnt; |
|
755 |
int shift; |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
756 |
OBJ w = __INST(width); |
1 | 757 |
|
2178 | 758 |
/* helper for two-plane magnification by 2 |
759 |
* 0000 -> 0000 0000 |
|
760 |
* 0001 -> 0000 0101 |
|
761 |
* ... |
|
762 |
* 1111 -> 1111 1111 |
|
763 |
*/ |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
764 |
static unsigned char mag2[16] = {0x00, 0x05, 0x0a, 0x0f, 0x50, 0x55, 0x5a, 0x5f, |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
765 |
0xa0, 0xa5, 0xaa, 0xaf, 0xf0, 0xf5, 0xfa, 0xff}; |
2178 | 766 |
/* helper for two-plane magnification by 4 */ |
767 |
static unsigned char mag4[16] = {0x00, 0x55, 0xaa, 0xff}; |
|
1 | 768 |
|
97 | 769 |
if (__bothSmallInteger(srcStart, dstStart) |
770 |
&& __bothSmallInteger(w, mX) |
|
5478
4e83e3604f19
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
4765
diff
changeset
|
771 |
&& __isByteArrayLike(srcBytes) && __isByteArray(dstBytes)) { |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
772 |
_mag = __intVal(mX); |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
773 |
srcP = __ByteArrayInstPtr(srcBytes)->ba_element - 1 + __intVal(srcStart); |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
774 |
dstP = __ByteArrayInstPtr(dstBytes)->ba_element - 1 + __intVal(dstStart); |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
775 |
_pixels = __intVal(w); |
2178 | 776 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
777 |
switch (_mag) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
778 |
case 1: |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
779 |
break; |
1 | 780 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
781 |
case 2: |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
782 |
/* tuned for this common case */ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
783 |
while (_pixels > 2) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
784 |
_byte = *srcP++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
785 |
*dstP++ = mag2[ _byte >> 4 ]; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
786 |
*dstP++ = mag2[ _byte & 0x0F ]; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
787 |
_pixels -= 4; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
788 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
789 |
while (_pixels > 0) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
790 |
_byte = *srcP++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
791 |
*dstP++ = mag2[ _byte >> 4 ]; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
792 |
if (_pixels > 2) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
793 |
*dstP++ = mag2[ _byte & 0x0F ]; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
794 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
795 |
_pixels -= 4; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
796 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
797 |
break; |
1 | 798 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
799 |
case3: |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
800 |
/* tuned for this common case */ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
801 |
bits = 0, incnt = 0, outcnt = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
802 |
shift = 6; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
803 |
_byte = *srcP++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
804 |
while (_pixels--) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
805 |
bit = (_byte >> shift) & 3; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
806 |
incnt++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
807 |
if (incnt == 4) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
808 |
incnt = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
809 |
shift = 6; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
810 |
_byte = *srcP++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
811 |
} else { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
812 |
shift -= 2; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
813 |
} |
2178 | 814 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
815 |
switch (outcnt) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
816 |
case 0: |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
817 |
/* next three pixels */ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
818 |
bits = (((bit << 2) | bit) << 2) | bit; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
819 |
outcnt = 3; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
820 |
break; |
2178 | 821 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
822 |
case 1: |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
823 |
/* next three pixels & store */ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
824 |
bits = (((((bits << 2) | bit) << 2) | bit) << 2) | bit; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
825 |
*dstP++ = bits; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
826 |
outcnt = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
827 |
break; |
2178 | 828 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
829 |
case 2: |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
830 |
/* next two pixels & store */ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
831 |
bits = (((bits << 2) | bit) << 2) | bit; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
832 |
*dstP++ = bits; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
833 |
bits = bit; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
834 |
outcnt = 1; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
835 |
break; |
1 | 836 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
837 |
case 3: |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
838 |
/* next pixel & store */ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
839 |
bits = (bits << 2) | bit; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
840 |
*dstP++ = bits; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
841 |
bits = (bit << 2) | bit; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
842 |
outcnt = 2; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
843 |
break; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
844 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
845 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
846 |
if (outcnt) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
847 |
*dstP = bits << ((4-outcnt)*2); |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
848 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
849 |
break; |
2178 | 850 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
851 |
case 4: |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
852 |
/* tuned for this common case */ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
853 |
incnt = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
854 |
shift = 6; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
855 |
_byte = *srcP++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
856 |
while (_pixels--) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
857 |
bit = (_byte >> shift) & 3; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
858 |
incnt++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
859 |
if (incnt == 4) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
860 |
incnt = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
861 |
shift = 6; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
862 |
_byte = *srcP++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
863 |
} else { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
864 |
shift -= 2; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
865 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
866 |
*dstP++ = mag4[bit]; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
867 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
868 |
break; |
1 | 869 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
870 |
default: |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
871 |
bits = 0, incnt = 0, outcnt = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
872 |
shift = 6; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
873 |
_byte = *srcP++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
874 |
while (_pixels--) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
875 |
bit = (_byte >> shift) & 3; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
876 |
incnt++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
877 |
if (incnt == 4) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
878 |
incnt = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
879 |
shift = 6; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
880 |
_byte = *srcP++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
881 |
} else { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
882 |
shift -= 2; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
883 |
} |
1 | 884 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
885 |
for (i=_mag; i>0; i--) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
886 |
bits = (bits << 2) | bit; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
887 |
outcnt++; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
888 |
if (outcnt == 4) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
889 |
*dstP++ = bits; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
890 |
bits = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
891 |
outcnt = 0; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
892 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
893 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
894 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
895 |
if (outcnt) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
896 |
*dstP = bits << ((4-outcnt)*2); |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
897 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
898 |
break; |
2178 | 899 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
900 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
901 |
RETURN (self); |
1 | 902 |
} |
3842 | 903 |
%}. |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
904 |
super |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
905 |
magnifyRowFrom:srcBytes offset:srcStart |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
906 |
into:dstBytes offset:dstStart factor:mX |
1 | 907 |
! ! |
280 | 908 |
|
909 |
!Depth2Image methodsFor:'queries'! |
|
910 |
||
911 |
bitsPerPixel |
|
912 |
"return the number of bits per pixel" |
|
913 |
||
914 |
^ 2 |
|
915 |
! |
|
916 |
||
917 |
bitsPerRow |
|
918 |
"return the number of bits in one scanline of the image" |
|
919 |
||
3868 | 920 |
^ width * 2 |
280 | 921 |
! |
922 |
||
923 |
bytesPerRow |
|
924 |
"return the number of bytes in one scanline of the image" |
|
925 |
||
926 |
|nbytes| |
|
927 |
||
928 |
nbytes := width // 4. |
|
929 |
((width \\ 4) ~~ 0) ifTrue:[ |
|
930 |
^ nbytes + 1 |
|
931 |
]. |
|
932 |
^ nbytes |
|
933 |
! |
|
934 |
||
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
935 |
colorFromValue:colorValue |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
936 |
"given a pixel value, return the corresponding color. |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
937 |
Pixel values start with 0." |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
938 |
|
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
939 |
|p value| |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
940 |
|
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
941 |
value := colorValue. |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
942 |
p := photometric. |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
943 |
|
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
944 |
p == #whiteIs0 ifTrue:[ |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
945 |
value := 3 - value. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
946 |
p := #blackIs0 |
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
947 |
]. |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
948 |
p == #blackIs0 ifTrue:[ |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
949 |
(value == 0) ifTrue:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
950 |
^ Color black |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
951 |
]. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
952 |
(value == 3) ifTrue:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
953 |
^ Color white |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
954 |
]. |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
955 |
^ Color gray:(value == 1 ifTrue:33 ifFalse:67) |
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
956 |
]. |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
957 |
|
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
958 |
p == #palette ifTrue:[ |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
959 |
value < colorMap size ifTrue:[ |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
960 |
^ colorMap at:(value+1). |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
961 |
]. |
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
962 |
]. |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
963 |
^ super colorFromValue:colorValue. |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
964 |
! |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3851
diff
changeset
|
965 |
|
280 | 966 |
usedColors |
967 |
"return a collection of colors used in the receiver. |
|
2201 | 968 |
For depth2 images, we return the colorMap here, assuming all |
969 |
pixels are used ... |
|
970 |
... which is not really true - it could use not all colors" |
|
280 | 971 |
|
3867 | 972 |
(photometric == #whiteIs0 or:[photometric == #blackIs0]) ifTrue:[ |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
973 |
^ Array with:(Color black) |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
974 |
with:(Color gray:33) |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
975 |
with:(Color gray:67) |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
976 |
with:(Color white). |
280 | 977 |
]. |
3867 | 978 |
photometric == #palette ifTrue:[ |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
979 |
^ colorMap |
3867 | 980 |
]. |
981 |
^ super usedColors |
|
746 | 982 |
|
2278 | 983 |
"Modified: / 24.8.1998 / 18:38:08 / cg" |
280 | 984 |
! |
985 |
||
986 |
usedValues |
|
2201 | 987 |
"return a collection of color values used in the receiver. |
3274 | 988 |
For depth2 images, we assume all pixel values are present ... |
2201 | 989 |
... which is not really true" |
280 | 990 |
|
991 |
"actually, this is wrong - we have to look if those are |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5478
diff
changeset
|
992 |
really used. However, assume that we dont care for |
280 | 993 |
those extra colors here ..." |
994 |
||
995 |
^ #(0 1 2 3) |
|
2201 | 996 |
|
997 |
"Modified: / 28.7.1998 / 22:23:15 / cg" |
|
280 | 998 |
! ! |
999 |
||
1000 |
!Depth2Image class methodsFor:'documentation'! |
|
1001 |
||
1002 |
version |
|
7500 | 1003 |
^ '$Header$' |
5478
4e83e3604f19
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
4765
diff
changeset
|
1004 |
! |
4e83e3604f19
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
4765
diff
changeset
|
1005 |
|
4e83e3604f19
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
4765
diff
changeset
|
1006 |
version_CVS |
7500 | 1007 |
^ '$Header$' |
280 | 1008 |
! ! |
6300 | 1009 |