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