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