equal
deleted
inserted
replaced
38 this class represents 16-color (4 bit / pixel) images. |
38 this class represents 16-color (4 bit / pixel) images. |
39 Most images coming from the windows world are represented as Depth4Images. |
39 Most images coming from the windows world are represented as Depth4Images. |
40 It mainly consists of methods already implemented in Image, |
40 It mainly consists of methods already implemented in Image, |
41 reimplemented here for more performance. |
41 reimplemented here for more performance. |
42 |
42 |
43 Only #blackIs0 / #whiteIs0 and #palette formats are supported here |
|
44 (i.e. no single-bit r/g/b images) |
|
45 |
|
46 [author:] |
43 [author:] |
47 Claus Gittinger |
44 Claus Gittinger |
48 |
45 |
49 [see also:] |
46 [see also:] |
50 Depth1Image Depth2Image Depth8Image Depth16Image Depth24Image |
47 Depth1Image Depth2Image Depth8Image Depth16Image Depth24Image |
88 ]. |
85 ]. |
89 photometric == #blackIs0 ifTrue:[ |
86 photometric == #blackIs0 ifTrue:[ |
90 ^ Color gray:(100 / 15 * value) |
87 ^ Color gray:(100 / 15 * value) |
91 ]. |
88 ]. |
92 photometric ~~ #palette ifTrue:[ |
89 photometric ~~ #palette ifTrue:[ |
93 self error:'format not supported'. |
90 ^ self colorFromValue:value |
94 ^ nil |
|
95 ]. |
91 ]. |
96 ^ colorMap at:(value + 1) |
92 ^ colorMap at:(value + 1) |
97 |
93 |
98 "Modified: 28.5.1996 / 20:54:31 / cg" |
94 "Modified: 8.6.1996 / 10:52:43 / cg" |
99 ! |
95 ! |
100 |
96 |
101 atX:x y:y putValue:aPixelValue |
97 atX:x y:y putValue:aPixelValue |
102 "set the pixel at x/y to aPixelValue. |
98 "set the pixel at x/y to aPixelValue. |
103 Pixels start at x=0 , y=0 for upper left pixel, end at |
99 Pixels start at x=0 , y=0 for upper left pixel, end at |
164 monoBits := ByteArray uninitializedNew:(bytesPerMonoRow * h). |
160 monoBits := ByteArray uninitializedNew:(bytesPerMonoRow * h). |
165 (monoBits isNil or:[bytes isNil]) ifTrue:[ |
161 (monoBits isNil or:[bytes isNil]) ifTrue:[ |
166 ^ nil |
162 ^ nil |
167 ]. |
163 ]. |
168 |
164 |
169 greyMap := self greyMapForRange:nDither. |
165 greyMap := self greyByteMapForRange:nDither. |
170 |
166 |
171 %{ |
167 %{ |
172 int __dW = __intVal(dW); |
168 int __dW = __intVal(dW); |
173 int __dH = __intVal(dH); |
169 int __dH = __intVal(dH); |
174 int __byte; |
170 int __byte; |
271 colors p | |
267 colors p | |
272 |
268 |
273 (p := photometric) == #palette ifTrue:[ |
269 (p := photometric) == #palette ifTrue:[ |
274 colors := colorMap. |
270 colors := colorMap. |
275 ] ifFalse:[ |
271 ] ifFalse:[ |
276 colors := Array new:16. |
272 (p == #whiteIs0 or:[p == #blackIs0]) ifTrue:[ |
277 0 to:15 do:[:i | |
273 colors := Array new:16. |
278 colors at:(i+1) put:(Color gray:100 - (100 / 15 * i)) |
274 0 to:15 do:[:i | |
279 ]. |
275 colors at:(i+1) put:(Color gray:100 - (100 / 15 * i)) |
280 p == #whiteIs0 ifTrue:[ |
276 ]. |
281 "/ we are done |
|
282 ] ifFalse:[ |
|
283 p == #blackIs0 ifTrue:[ |
277 p == #blackIs0 ifTrue:[ |
284 colors reverse |
278 colors reverse |
285 ] ifFalse:[ |
|
286 self error:'format not supported'. |
|
287 ^ nil |
|
288 ] |
279 ] |
|
280 ] ifFalse:[ |
|
281 ^ super colorsAtY:y from:xLow to:xHigh do:aBlock. |
289 ] |
282 ] |
290 ]. |
283 ]. |
291 |
284 |
292 x1 := xLow. |
285 x1 := xLow. |
293 x2 := xHigh. |
286 x2 := xHigh. |
311 shift := 0 |
304 shift := 0 |
312 ]. |
305 ]. |
313 aBlock value:x value:(colors at:(value + 1)). |
306 aBlock value:x value:(colors at:(value + 1)). |
314 ] |
307 ] |
315 |
308 |
316 "Modified: 7.6.1996 / 12:13:24 / cg" |
|
317 "Created: 7.6.1996 / 19:12:33 / cg" |
309 "Created: 7.6.1996 / 19:12:33 / cg" |
|
310 "Modified: 8.6.1996 / 10:16:05 / cg" |
318 ! |
311 ! |
319 |
312 |
320 valuesAtY:y from:xLow to:xHigh do:aBlock |
313 valuesAtY:y from:xLow to:xHigh do:aBlock |
321 "perform aBlock for each pixelValue from x1 to x2 in row y. |
314 "perform aBlock for each pixelValue from x1 to x2 in row y. |
322 The block is passed the pixelValue at each pixel. |
315 The block is passed the pixelValue at each pixel. |
499 ! ! |
492 ! ! |
500 |
493 |
501 !Depth4Image class methodsFor:'documentation'! |
494 !Depth4Image class methodsFor:'documentation'! |
502 |
495 |
503 version |
496 version |
504 ^ '$Header: /cvs/stx/stx/libview/Depth4Image.st,v 1.18 1996-06-07 17:32:33 cg Exp $' |
497 ^ '$Header: /cvs/stx/stx/libview/Depth4Image.st,v 1.19 1996-06-08 11:03:32 cg Exp $' |
505 ! ! |
498 ! ! |