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 |
"
|
1
|
12 |
|
|
13 |
Image subclass:#Depth1Image
|
81
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Graphics-Display Objects'
|
1
|
18 |
!
|
|
19 |
|
3
|
20 |
Depth1Image comment:'
|
|
21 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
81
|
22 |
All Rights Reserved
|
54
|
23 |
|
82
|
24 |
$Header: /cvs/stx/stx/libview/Depth1Image.st,v 1.9 1994-11-21 16:43:06 claus Exp $
|
46
|
25 |
'!
|
3
|
26 |
|
46
|
27 |
!Depth1Image class methodsFor:'documentation'!
|
|
28 |
|
|
29 |
copyright
|
|
30 |
"
|
|
31 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
81
|
32 |
All Rights Reserved
|
3
|
33 |
|
46
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
!
|
3
|
42 |
|
46
|
43 |
version
|
|
44 |
"
|
82
|
45 |
$Header: /cvs/stx/stx/libview/Depth1Image.st,v 1.9 1994-11-21 16:43:06 claus Exp $
|
46
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
documentation
|
|
50 |
"
|
|
51 |
this class represents bilevel (1 bit / pixel) images.
|
81
|
52 |
It mainly consists of methods which are already implemented in Image,
|
|
53 |
but reimplemented here for more performance. If you plan to do heavy
|
|
54 |
image processing on bilevel images, you may want to add more
|
|
55 |
specialized methods here.
|
46
|
56 |
"
|
|
57 |
! !
|
3
|
58 |
|
81
|
59 |
!Depth1Image methodsFor:'queries'!
|
1
|
60 |
|
|
61 |
bitsPerPixel
|
|
62 |
"return the number of bits per pixel"
|
|
63 |
|
|
64 |
^ 1
|
|
65 |
!
|
|
66 |
|
|
67 |
bitsPerRow
|
|
68 |
"return the number of bits in one scanline of the image"
|
|
69 |
|
|
70 |
^ width
|
|
71 |
!
|
|
72 |
|
|
73 |
bitsPerSample
|
|
74 |
"return the number of bits per sample.
|
|
75 |
The return value is an array of bits-per-plane."
|
|
76 |
|
|
77 |
^ #(1)
|
|
78 |
!
|
|
79 |
|
|
80 |
bytesPerRow
|
|
81 |
"return the number of bytes in one scanline of the image"
|
|
82 |
|
|
83 |
|nbytes|
|
|
84 |
|
|
85 |
nbytes := width // 8.
|
|
86 |
((width \\ 8) ~~ 0) ifTrue:[
|
81
|
87 |
^ nbytes + 1
|
1
|
88 |
].
|
|
89 |
^ nbytes
|
|
90 |
!
|
|
91 |
|
|
92 |
samplesPerPixel
|
|
93 |
"return the number of samples per pixel in the image."
|
|
94 |
|
|
95 |
^ 1
|
81
|
96 |
! !
|
|
97 |
|
|
98 |
!Depth1Image methodsFor:'accessing'!
|
1
|
99 |
|
|
100 |
valueAtX:x y:y
|
81
|
101 |
"retrieve a pixelValue at x/y; return a number.
|
|
102 |
The interpretation of the returned value depends on the photometric
|
|
103 |
and the colormap. See also Image>>atX:y:)
|
|
104 |
Pixels start at 0@0 for upper left pixel, end at
|
|
105 |
(width-1)@(height-1) for lower right pixel"
|
1
|
106 |
|
|
107 |
|bytesPerRow "{Class: SmallInteger}"
|
|
108 |
index "{Class: SmallInteger}"
|
|
109 |
byte "{Class: SmallInteger}"
|
|
110 |
mask "{Class: SmallInteger}"|
|
|
111 |
|
|
112 |
%{ /* NOCONTEXT */
|
35
|
113 |
if (__isByteArray(_INST(bytes))
|
1
|
114 |
&& _isSmallInteger(x)
|
|
115 |
&& _isSmallInteger(y)
|
|
116 |
&& _isSmallInteger(_INST(width)) ) {
|
81
|
117 |
int _w = _intVal(_INST(width));
|
|
118 |
int _y = _intVal(y);
|
|
119 |
int _x = _intVal(x);
|
|
120 |
unsigned _byte;
|
|
121 |
_byte = _ByteArrayInstPtr(_INST(bytes))->ba_element[(_w + 7) / 8 * _y + (_x / 8)];
|
|
122 |
RETURN( (_byte & (0x80 >> (_x % 8))) ? _MKSMALLINT(1) : _MKSMALLINT(0) );
|
1
|
123 |
}
|
81
|
124 |
%}.
|
|
125 |
|
|
126 |
"the above is equivalent to:
|
|
127 |
(notice that the code below is evaluated if the bytes-collection is
|
|
128 |
not a byteArray, or the arguments are not integers)"
|
|
129 |
|
1
|
130 |
bytesPerRow := width // 8.
|
|
131 |
((width \\ 8) ~~ 0) ifTrue:[
|
81
|
132 |
bytesPerRow := bytesPerRow + 1
|
1
|
133 |
].
|
|
134 |
index := (bytesPerRow * y) + 1 + (x // 8).
|
|
135 |
|
|
136 |
"left pixel is in high bit"
|
|
137 |
byte := bytes at:index.
|
|
138 |
mask := #(16r80 16r40 16r20 16r10 16r08 16r04 16r02 16r01) at:((x \\ 8) + 1).
|
|
139 |
(byte bitAnd:mask) == 0 ifTrue:[^ 0].
|
|
140 |
^ 1
|
|
141 |
!
|
|
142 |
|
|
143 |
atX:x y:y
|
|
144 |
"retrieve a pixel at x/y; return a color.
|
|
145 |
Pixels start at x=0 , y=0 for upper left pixel, end at
|
|
146 |
x = width-1, y=height-1 for lower right pixel"
|
|
147 |
|
38
|
148 |
|lineIndex "{ Class: SmallInteger }"
|
|
149 |
byte "{ Class: SmallInteger }"
|
|
150 |
shift "{ Class: SmallInteger }"
|
|
151 |
value "{ Class: SmallInteger }"|
|
1
|
152 |
|
|
153 |
lineIndex := (self bytesPerRow * y) + 1.
|
|
154 |
|
|
155 |
"left pixel is in high bit"
|
|
156 |
byte := bytes at:(lineIndex + (x // 8)).
|
|
157 |
shift := #(-7 -6 -5 -4 -3 -2 -1 0) at:((x \\ 8) + 1).
|
|
158 |
value := (byte bitShift:shift) bitAnd:1.
|
|
159 |
photometric == #whiteIs0 ifTrue:[
|
81
|
160 |
(value == 0) ifTrue:[
|
|
161 |
^ Color white
|
|
162 |
].
|
|
163 |
^ Color black
|
1
|
164 |
].
|
|
165 |
photometric == #blackIs0 ifTrue:[
|
81
|
166 |
(value == 0) ifTrue:[
|
|
167 |
^ Color black
|
|
168 |
].
|
|
169 |
^ Color white
|
1
|
170 |
].
|
|
171 |
photometric ~~ #palette ifTrue:[
|
81
|
172 |
self error:'format not supported'.
|
|
173 |
^ nil
|
1
|
174 |
].
|
38
|
175 |
value := value + 1.
|
|
176 |
^ Color red:(((colorMap at:1) at:value) * (100.0 / 255.0))
|
81
|
177 |
green:(((colorMap at:2) at:value) * (100.0 / 255.0))
|
|
178 |
blue:(((colorMap at:3) at:value) * (100.0 / 255.0))
|
1
|
179 |
!
|
|
180 |
|
|
181 |
atX:x y:y putValue:aPixelValue
|
81
|
182 |
"set a pixels value at x/y to aPixelValue.
|
1
|
183 |
Pixels start at x=0 , y=0 for upper left pixel, end at
|
|
184 |
x = width-1, y=height-1 for lower right pixel"
|
|
185 |
|
|
186 |
|bytesPerRow "{Class: SmallInteger}"
|
|
187 |
index "{Class: SmallInteger}"
|
|
188 |
byte "{Class: SmallInteger}"
|
|
189 |
mask "{Class: SmallInteger}"|
|
|
190 |
|
|
191 |
%{ /* NOCONTEXT */
|
35
|
192 |
if (__isByteArray(_INST(bytes))
|
1
|
193 |
&& _isSmallInteger(x)
|
|
194 |
&& _isSmallInteger(y)
|
|
195 |
&& _isSmallInteger(_INST(width)) ) {
|
81
|
196 |
int _w = _intVal(_INST(width));
|
|
197 |
int _y = _intVal(y);
|
|
198 |
int _x = _intVal(x);
|
|
199 |
int _idx;
|
1
|
200 |
|
81
|
201 |
_idx = (_w + 7) / 8 * _y + (_x / 8);
|
|
202 |
if (aPixelValue == _MKSMALLINT(0)) {
|
|
203 |
_ByteArrayInstPtr(_INST(bytes))->ba_element[_idx] &= ~(0x80 >> (_x % 8));
|
|
204 |
} else {
|
|
205 |
_ByteArrayInstPtr(_INST(bytes))->ba_element[_idx] |= (0x80 >> (_x % 8));
|
|
206 |
}
|
|
207 |
RETURN( self );
|
1
|
208 |
}
|
81
|
209 |
%}.
|
|
210 |
"fall back code for nonByteArray or nonInteger arguments"
|
|
211 |
|
1
|
212 |
bytesPerRow := width // 8.
|
|
213 |
((width \\ 8) ~~ 0) ifTrue:[
|
81
|
214 |
bytesPerRow := bytesPerRow + 1
|
1
|
215 |
].
|
|
216 |
index := (bytesPerRow * y) + 1 + (x // 8).
|
|
217 |
|
|
218 |
"left pixel is in high bit"
|
|
219 |
byte := bytes at:index.
|
|
220 |
mask := #(16r80 16r40 16r20 16r10 16r08 16r04 16r02 16r01) at:((x \\ 8) + 1).
|
|
221 |
aPixelValue == 0 ifTrue:[
|
81
|
222 |
byte := byte bitAnd:(mask bitInvert)
|
1
|
223 |
] ifFalse:[
|
81
|
224 |
byte := byte bitOr:mask
|
1
|
225 |
].
|
|
226 |
bytes at:index put:byte
|
|
227 |
!
|
|
228 |
|
|
229 |
atX:x y:y put:aColor
|
|
230 |
"set the pixel at x/y to aColor.
|
|
231 |
Pixels start at x=0 , y=0 for upper left pixel, end at
|
|
232 |
x = width-1, y=height-1 for lower right pixel.
|
|
233 |
This method checks, if it is possible to store the color
|
|
234 |
in the image; i.e. for b/w images, the color MUST be black
|
|
235 |
or white; for palette images it must be present in the palette."
|
|
236 |
|
38
|
237 |
|clr0 clr1|
|
1
|
238 |
|
|
239 |
photometric == #whiteIs0 ifTrue:[
|
81
|
240 |
clr0 := Color white.
|
|
241 |
clr1 := Color black.
|
1
|
242 |
] ifFalse:[
|
81
|
243 |
photometric == #blackIs0 ifTrue:[
|
|
244 |
clr0 := Color black.
|
|
245 |
clr1 := Color white.
|
|
246 |
] ifFalse:[
|
|
247 |
photometric ~~ #palette ifTrue:[
|
|
248 |
self error:'format not supported'.
|
|
249 |
^ nil
|
|
250 |
].
|
|
251 |
clr0 := colorMap at:1.
|
|
252 |
clr1 := colorMap at:2.
|
|
253 |
]
|
1
|
254 |
].
|
38
|
255 |
aColor = clr0 ifTrue:[
|
81
|
256 |
self atX:x y:y putValue:0.
|
|
257 |
^ self
|
38
|
258 |
].
|
|
259 |
aColor = clr1 ifTrue:[
|
81
|
260 |
self atX:x y:y putValue:1.
|
|
261 |
^ self
|
38
|
262 |
].
|
|
263 |
"
|
81
|
264 |
the color to be stored is not in the images colormap
|
38
|
265 |
"
|
|
266 |
self error:'invalid color'
|
81
|
267 |
! !
|
|
268 |
|
|
269 |
!Depth1Image methodsFor:'enumeration'!
|
|
270 |
|
|
271 |
valueAtY:y from:xLow to:xHigh do:aBlock
|
|
272 |
"perform aBlock for each pixelValue from x1 to x2 in row y.
|
|
273 |
The block is passed the color at each pixel.
|
|
274 |
This method allows slighly faster processing of an
|
|
275 |
image than using atX:y:, since some processing can be
|
|
276 |
avoided when going from pixel to pixel. However, for
|
|
277 |
real image processing, specialized methods should be written."
|
|
278 |
|
|
279 |
|srcIndex "{ Class: SmallInteger }"
|
|
280 |
byte "{ Class: SmallInteger }"
|
|
281 |
mask "{ Class: SmallInteger }"
|
|
282 |
x1 "{ Class: SmallInteger }"
|
|
283 |
x2 "{ Class: SmallInteger }"
|
|
284 |
pixelValue|
|
|
285 |
|
|
286 |
"this method needs more tuning, if used heavily
|
|
287 |
(fetch 8 bits at once, unroll the loop over these 8 pixels)"
|
|
288 |
|
|
289 |
x1 := xLow.
|
|
290 |
x2 := xHigh.
|
|
291 |
srcIndex := (self bytesPerRow * y) + 1.
|
|
292 |
|
|
293 |
"left pixel is in high bit"
|
|
294 |
|
|
295 |
srcIndex := srcIndex + (x1 // 8).
|
|
296 |
mask := #[2r10000000
|
|
297 |
2r01000000
|
|
298 |
2r00100000
|
|
299 |
2r00010000
|
|
300 |
2r00001000
|
|
301 |
2r00000100
|
|
302 |
2r00000010
|
|
303 |
2r00000001] at:((x1 \\ 8) + 1).
|
|
304 |
|
|
305 |
x1 to:x2 do:[:x |
|
|
306 |
byte := bytes at:srcIndex.
|
|
307 |
(byte bitAnd:mask) == 0 ifTrue:[
|
|
308 |
pixelValue := 0
|
|
309 |
] ifFalse:[
|
|
310 |
pixelValue := 1
|
|
311 |
].
|
|
312 |
aBlock value:x value:pixelValue.
|
|
313 |
|
|
314 |
mask := mask bitShift:-1.
|
|
315 |
mask == 0 ifTrue:[
|
|
316 |
mask := 2r10000000.
|
|
317 |
srcIndex := srcIndex + 1
|
|
318 |
]
|
|
319 |
]
|
1
|
320 |
!
|
|
321 |
|
|
322 |
atY:y from:xLow to:xHigh do:aBlock
|
|
323 |
"perform aBlock for each pixel from x1 to x2 in row y.
|
|
324 |
The block is passed the color at each pixel.
|
|
325 |
This method allows slighly faster processing of an
|
|
326 |
image than using atX:y:, since some processing can be
|
|
327 |
avoided when going from pixel to pixel. However, for
|
|
328 |
real image processing, specialized methods should be written."
|
|
329 |
|
|
330 |
|srcIndex "{ Class: SmallInteger }"
|
|
331 |
byte "{ Class: SmallInteger }"
|
|
332 |
mask "{ Class: SmallInteger }"
|
|
333 |
x1 "{ Class: SmallInteger }"
|
|
334 |
x2 "{ Class: SmallInteger }"
|
|
335 |
color0 color1 color|
|
|
336 |
|
|
337 |
x1 := xLow.
|
|
338 |
x2 := xHigh.
|
|
339 |
srcIndex := (self bytesPerRow * y) + 1.
|
|
340 |
|
|
341 |
"left pixel is in high bit"
|
|
342 |
|
|
343 |
photometric == #whiteIs0 ifTrue:[
|
81
|
344 |
color0 := Color white.
|
|
345 |
color1 := Color black
|
1
|
346 |
] ifFalse:[
|
81
|
347 |
photometric == #blackIs0 ifTrue:[
|
|
348 |
color0 := Color black.
|
|
349 |
color1 := Color white
|
|
350 |
] ifFalse:[
|
|
351 |
photometric == #palette ifTrue:[
|
|
352 |
color0 := Color red:(((colorMap at:1) at:1) * 100 / 255)
|
|
353 |
green:(((colorMap at:2) at:1) * 100 / 255)
|
|
354 |
blue:(((colorMap at:3) at:1) * 100 / 255).
|
|
355 |
color1 := Color red:(((colorMap at:1) at:2) * 100 / 255)
|
|
356 |
green:(((colorMap at:2) at:2) * 100 / 255)
|
|
357 |
blue:(((colorMap at:3) at:2) * 100 / 255).
|
|
358 |
] ifFalse:[
|
|
359 |
self error:'format not supported'.
|
|
360 |
^ nil
|
|
361 |
]
|
|
362 |
]
|
1
|
363 |
].
|
|
364 |
|
|
365 |
srcIndex := srcIndex + (x1 // 8).
|
12
|
366 |
mask := #[2r10000000
|
81
|
367 |
2r01000000
|
|
368 |
2r00100000
|
|
369 |
2r00010000
|
|
370 |
2r00001000
|
|
371 |
2r00000100
|
|
372 |
2r00000010
|
|
373 |
2r00000001] at:((x1 \\ 8) + 1).
|
1
|
374 |
|
|
375 |
x1 to:x2 do:[:x |
|
81
|
376 |
byte := bytes at:srcIndex.
|
|
377 |
(byte bitAnd:mask) == 0 ifTrue:[
|
|
378 |
color := color0
|
|
379 |
] ifFalse:[
|
|
380 |
color := color1
|
|
381 |
].
|
|
382 |
aBlock value:x value:color.
|
1
|
383 |
|
81
|
384 |
mask := mask bitShift:-1.
|
|
385 |
mask == 0 ifTrue:[
|
|
386 |
mask := 2r10000000.
|
|
387 |
srcIndex := srcIndex + 1
|
|
388 |
]
|
1
|
389 |
]
|
|
390 |
! !
|
|
391 |
|
|
392 |
!Depth1Image methodsFor:'converting greyscale images'!
|
|
393 |
|
|
394 |
greyImageAsFormOn:aDevice
|
|
395 |
"convert a greyscale image to a device form"
|
|
396 |
|
|
397 |
|f|
|
|
398 |
|
|
399 |
f := Form width:width height:height fromArray:bytes on:aDevice.
|
|
400 |
photometric == #blackIs0 ifTrue:[
|
81
|
401 |
f function:#xor.
|
|
402 |
f paint:(Color colorId:1).
|
|
403 |
f fillRectangleX:0 y:0 width:width height:height
|
1
|
404 |
].
|
|
405 |
^ f
|
46
|
406 |
!
|
|
407 |
|
|
408 |
greyImageAsMonoFormOn:aDevice
|
|
409 |
"convert to a monochrome form - thats easy"
|
|
410 |
|
|
411 |
^ self greyImageAsFormOn:aDevice
|
1
|
412 |
! !
|
|
413 |
|
82
|
414 |
!Depth1Image methodsFor:'converting palette images'!
|
|
415 |
|
|
416 |
paletteImageAsPseudoFormOn:aDevice
|
|
417 |
"return a pseudo-deviceForm from the palette image."
|
|
418 |
|
|
419 |
|f|
|
|
420 |
|
|
421 |
"
|
|
422 |
this is easy, since Form already supports colorMaps
|
|
423 |
"
|
|
424 |
f := Form width:width
|
|
425 |
height:height
|
|
426 |
fromArray:bytes.
|
|
427 |
f colorMap:colorMap.
|
|
428 |
^ f
|
|
429 |
! !
|
|
430 |
|
1
|
431 |
!Depth1Image methodsFor:'magnification'!
|
|
432 |
|
|
433 |
magnifyRowFrom:srcBytes offset:srcStart
|
81
|
434 |
into:dstBytes offset:dstStart factor:mX
|
1
|
435 |
|
81
|
436 |
"magnify a single pixel row - can only magnify by integer factors.
|
|
437 |
This method has been specially tuned for magnification by 2 and 4."
|
1
|
438 |
|
|
439 |
%{
|
|
440 |
unsigned char *srcP, *dstP;
|
|
441 |
int _mag;
|
|
442 |
REGISTER int i;
|
|
443 |
REGISTER unsigned char _byte;
|
|
444 |
int _pixels, bpr;
|
|
445 |
REGISTER int outcnt, bits, bit, mask, incnt;
|
|
446 |
int shift;
|
|
447 |
unsigned char byte1, byte2, byte3, byte4;
|
|
448 |
|
|
449 |
/* helper for monochrome magnification by 2 */
|
|
450 |
static unsigned char mag1[16] = {0x00, 0x03, 0x0c, 0x0f, 0x30, 0x33, 0x3c, 0x3f,
|
81
|
451 |
0xc0, 0xc3, 0xcc, 0xcf, 0xf0, 0xf3, 0xfc, 0xff};
|
1
|
452 |
|
|
453 |
if (_isSmallInteger(srcStart) && _isSmallInteger(dstStart)
|
|
454 |
&& _isSmallInteger(_INST(width)) && _isSmallInteger(mX)
|
35
|
455 |
&& __isByteArray(srcBytes) && __isByteArray(dstBytes)) {
|
81
|
456 |
_mag = _intVal(mX);
|
|
457 |
srcP = _ByteArrayInstPtr(srcBytes)->ba_element - 1 + _intVal(srcStart);
|
|
458 |
dstP = _ByteArrayInstPtr(dstBytes)->ba_element - 1 + _intVal(dstStart);
|
|
459 |
_pixels = _intVal(_INST(width));
|
1
|
460 |
|
81
|
461 |
switch (_mag) {
|
|
462 |
case 1:
|
|
463 |
break;
|
1
|
464 |
|
81
|
465 |
case 2:
|
|
466 |
/* tuned for this common case */
|
|
467 |
while (_pixels > 0) {
|
|
468 |
_byte = *srcP++;
|
|
469 |
*dstP++ = mag1[ _byte >> 4 ];
|
|
470 |
if (_pixels > 4) {
|
|
471 |
*dstP++ = mag1[ _byte & 0x0F ];
|
|
472 |
}
|
|
473 |
_pixels -= 8;
|
|
474 |
}
|
|
475 |
break;
|
1
|
476 |
|
81
|
477 |
case 4:
|
|
478 |
/* tuned for this common case */
|
|
479 |
while (_pixels > 0) {
|
|
480 |
_byte = *srcP++;
|
|
481 |
byte1 = mag1[_byte >> 4];
|
|
482 |
byte2 = mag1[byte1 & 0xF];
|
|
483 |
byte1 = mag1[byte1 >> 4];
|
|
484 |
byte3 = mag1[ _byte & 0x0F ];
|
|
485 |
byte4 = mag1[byte3 & 0xF];
|
|
486 |
byte3 = mag1[byte3 >> 4];
|
1
|
487 |
|
81
|
488 |
*dstP++ = byte1;
|
|
489 |
if (_pixels > 2) {
|
|
490 |
*dstP++ = byte2;
|
|
491 |
if (_pixels > 4) {
|
|
492 |
*dstP++ = byte3;
|
|
493 |
if (_pixels > 6) {
|
|
494 |
*dstP++ = byte4;
|
|
495 |
}
|
|
496 |
}
|
|
497 |
}
|
|
498 |
_pixels -= 8;
|
|
499 |
}
|
|
500 |
break;
|
1
|
501 |
|
81
|
502 |
default:
|
|
503 |
bits = 0, incnt = 0, outcnt = 0;
|
|
504 |
mask = 0x80;
|
|
505 |
_byte = *srcP++;
|
|
506 |
while (_pixels--) {
|
|
507 |
if (_byte & mask)
|
|
508 |
bit = 1;
|
|
509 |
else
|
|
510 |
bit = 0;
|
|
511 |
incnt++;
|
|
512 |
if (incnt == 8) {
|
|
513 |
incnt = 0;
|
|
514 |
mask = 0x80;
|
|
515 |
_byte = *srcP++;
|
|
516 |
} else {
|
|
517 |
mask >>= 1;
|
|
518 |
}
|
1
|
519 |
|
81
|
520 |
for (i=_mag; i>0; i--) {
|
|
521 |
bits = (bits << 1) | bit;
|
|
522 |
outcnt++;
|
|
523 |
if (outcnt == 8) {
|
|
524 |
*dstP++ = bits;
|
|
525 |
bits = 0;
|
|
526 |
outcnt = 0;
|
|
527 |
}
|
|
528 |
}
|
|
529 |
}
|
|
530 |
break;
|
|
531 |
}
|
|
532 |
RETURN (self);
|
1
|
533 |
}
|
81
|
534 |
%}.
|
1
|
535 |
self primitiveFailed
|
|
536 |
! !
|