author | Stefan Vogel <sv@exept.de> |
Fri, 15 Jul 2016 13:57:43 +0200 | |
branch | delegated_gc |
changeset 7412 | d4b5f3114373 |
parent 6306 | a3bbe514829e |
child 7190 | 18fc47cc1ce6 |
permissions | -rw-r--r-- |
193 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
||
193 | 14 |
Image subclass:#Depth16Image |
579 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Graphics-Images' |
|
193 | 19 |
! |
20 |
||
21 |
!Depth16Image class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
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 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
this class represents 16 bit images. |
|
40 |
Only the minimum protocol is implemented here; much more is |
|
41 |
needed for higher performance operations on depth16 images. |
|
42 |
(however, 16bit images are seldom used, so falling back into the |
|
43 |
slow general methods from Image should not hurt too much ..) |
|
611 | 44 |
|
45 |
[author:] |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
46 |
Claus Gittinger |
611 | 47 |
|
48 |
[see also:] |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
49 |
Depth1Image Depth2Image Depth4Image Depth8Image Depth24Image |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
50 |
ImageReader |
193 | 51 |
" |
52 |
! ! |
|
53 |
||
54 |
!Depth16Image class methodsFor:'queries'! |
|
55 |
||
4759 | 56 |
defaultPhotometric |
57 |
"return the default photometric pixel interpretation" |
|
58 |
||
59 |
^ #rgb |
|
60 |
||
61 |
"Created: / 27-05-2007 / 14:04:11 / cg" |
|
62 |
! |
|
63 |
||
193 | 64 |
imageDepth |
579 | 65 |
"return the depth of images represented by instances of |
66 |
this class - here we return 16" |
|
67 |
||
193 | 68 |
^ 16 |
579 | 69 |
|
70 |
"Modified: 20.4.1996 / 23:40:01 / cg" |
|
193 | 71 |
! ! |
72 |
||
3263 | 73 |
!Depth16Image methodsFor:'accessing-pixels'! |
281 | 74 |
|
1659
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
75 |
pixelAtX:x y:y |
281 | 76 |
"retrieve a pixel at x/y; return a pixelValue. |
77 |
Pixels start at x=0 , y=0 for upper left pixel, end at |
|
78 |
x = width-1, y=height-1 for lower right pixel" |
|
79 |
||
80 |
|lineIndex "{ Class: SmallInteger }"| |
|
81 |
||
6306 | 82 |
pixelFunction notNil ifTrue:[^ pixelFunction value:x value:y]. |
83 |
||
281 | 84 |
lineIndex := (width * 2 * y) + 1. |
85 |
||
86 |
"left pixel in high bits" |
|
87 |
^ bytes wordAt:(lineIndex + (x * 2)) MSB:true. |
|
1659
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
88 |
|
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
89 |
"Created: 24.4.1997 / 16:06:19 / cg" |
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
90 |
! |
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
91 |
|
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
92 |
pixelAtX:x y:y put:aPixelValue |
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
93 |
"set the pixel at x/y to aPixelValue. |
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
94 |
Pixels start at x=0 , y=0 for upper left pixel, end at |
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
95 |
x = width-1, y=height-1 for lower right pixel" |
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
96 |
|
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
97 |
|lineIndex "{ Class: SmallInteger }"| |
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
98 |
|
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
99 |
lineIndex := (width * 2 * y) + 1. |
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
100 |
|
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
101 |
bytes wordAt:(lineIndex + (x * 2)) put:aPixelValue MSB:true |
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
102 |
|
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
103 |
"Created: 24.4.1997 / 17:06:21 / cg" |
2180 | 104 |
! |
105 |
||
3872 | 106 |
rowAt:y putAll:pixelArray startingAt:startIndex |
2180 | 107 |
"store a single rows bits from bits in the pixelArray argument; |
108 |
Return the pixelArray. |
|
3872 | 109 |
Notice: row coordinate starts at 0." |
2180 | 110 |
|
111 |
|dstIdx "{ Class: SmallInteger }" |
|
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3263
diff
changeset
|
112 |
pixel |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3263
diff
changeset
|
113 |
bytes| |
2180 | 114 |
|
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3263
diff
changeset
|
115 |
bytes := self bits. |
3872 | 116 |
dstIdx := (width * 2 * y) + 1. |
2180 | 117 |
1 to:width do:[:col | |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
118 |
pixel := pixelArray at:(startIndex + col - 1). |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
119 |
bytes at:dstIdx put:((pixel bitShift:-8) bitAnd:16rFF). |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
120 |
bytes at:dstIdx+1 put:(pixel bitAnd:16rFF). |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
121 |
dstIdx := dstIdx + 2. |
2180 | 122 |
]. |
123 |
^ pixelArray |
|
124 |
||
125 |
"Created: 24.4.1997 / 15:50:27 / cg" |
|
281 | 126 |
! ! |
127 |
||
4759 | 128 |
!Depth16Image methodsFor:'initialization'! |
129 |
||
130 |
initialize |
|
131 |
super initialize. |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
132 |
samplesPerPixel := 3. |
4759 | 133 |
bitsPerSample := #(5 5 5). |
134 |
||
135 |
"Created: / 27-05-2007 / 14:09:46 / cg" |
|
136 |
! ! |
|
137 |
||
5128
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
138 |
!Depth16Image methodsFor:'magnification'! |
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
139 |
|
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
140 |
magnifyRowFrom:srcBytes offset:srcStart |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
141 |
into:dstBytes offset:dstStart factor:mX |
5128
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
142 |
|
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
143 |
"magnify a single pixel row - can only magnify by integer factors" |
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
144 |
|
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
145 |
%{ |
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
146 |
unsigned char *srcP, *dstP; |
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
147 |
int _mag; |
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
148 |
REGISTER int i; |
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
149 |
REGISTER unsigned char byte1, byte2; |
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
150 |
int _pixels; |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
151 |
OBJ w = __INST(width); |
5128
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
152 |
|
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
153 |
if (__bothSmallInteger(srcStart, dstStart) |
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
154 |
&& __bothSmallInteger(w, mX) |
5477
8badcb37a2c0
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
5128
diff
changeset
|
155 |
&& __isByteArrayLike(srcBytes) && __isByteArray(dstBytes)) { |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
156 |
_mag = __intVal(mX); |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
157 |
srcP = __ByteArrayInstPtr(srcBytes)->ba_element - 1 + __intVal(srcStart); |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
158 |
dstP = __ByteArrayInstPtr(dstBytes)->ba_element - 1 + __intVal(dstStart); |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
159 |
_pixels = __intVal(w); |
5128
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
160 |
|
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
161 |
while (_pixels--) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
162 |
byte1 = *srcP; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
163 |
byte2 = *(srcP+1); |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
164 |
srcP += 2; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
165 |
for (i=_mag; i>0; i--) { |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
166 |
*dstP = byte1; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
167 |
*(dstP+1) = byte2; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
168 |
dstP += 2; |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
169 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
170 |
} |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
171 |
RETURN (self); |
5128
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
172 |
} |
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
173 |
%}. |
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
174 |
super |
6066
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
175 |
magnifyRowFrom:srcBytes offset:srcStart |
62426e8110ae
stx macros with 2 underlines
Claus Gittinger <cg@exept.de>
parents:
5477
diff
changeset
|
176 |
into:dstBytes offset:dstStart factor:mX |
5128
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
177 |
! ! |
6092105361d1
+magnifyRowFrom:offset:into:offset:factor:
Claus Gittinger <cg@exept.de>
parents:
4759
diff
changeset
|
178 |
|
193 | 179 |
!Depth16Image methodsFor:'queries'! |
180 |
||
181 |
bitsPerPixel |
|
182 |
"return the number of bits per pixel" |
|
183 |
||
184 |
^ 16 |
|
185 |
! |
|
186 |
||
187 |
bitsPerRow |
|
188 |
"return the number of bits in one scanline of the image" |
|
189 |
||
3868 | 190 |
^ width * 16 |
193 | 191 |
! |
192 |
||
193 |
bytesPerRow |
|
194 |
"return the number of bytes in one scanline of the image" |
|
195 |
||
196 |
^ width * 2. |
|
197 |
! ! |
|
198 |
||
281 | 199 |
!Depth16Image class methodsFor:'documentation'! |
193 | 200 |
|
281 | 201 |
version |
6306 | 202 |
^ '$Header: /cvs/stx/stx/libview/Depth16Image.st,v 1.17 2014-03-02 14:39:22 cg Exp $' |
5477
8badcb37a2c0
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
5128
diff
changeset
|
203 |
! |
8badcb37a2c0
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
5128
diff
changeset
|
204 |
|
8badcb37a2c0
__isByteArray() to __isByteArrayLike() in primitive code
Stefan Vogel <sv@exept.de>
parents:
5128
diff
changeset
|
205 |
version_CVS |
6306 | 206 |
^ '$Header: /cvs/stx/stx/libview/Depth16Image.st,v 1.17 2014-03-02 14:39:22 cg Exp $' |
193 | 207 |
! ! |
6306 | 208 |