author | Claus Gittinger <cg@exept.de> |
Tue, 29 May 2007 12:13:10 +0200 | |
changeset 4759 | 55e8bc994d61 |
parent 3872 | 390fabbc3036 |
child 5128 | 6092105361d1 |
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:] |
|
46 |
Claus Gittinger |
|
47 |
||
48 |
[see also:] |
|
49 |
Depth1Image Depth2Image Depth4Image Depth8Image Depth24Image |
|
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 |
||
82 |
lineIndex := (width * 2 * y) + 1. |
|
83 |
||
84 |
"left pixel in high bits" |
|
85 |
^ bytes wordAt:(lineIndex + (x * 2)) MSB:true. |
|
1659
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
86 |
|
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
87 |
"Created: 24.4.1997 / 16:06:19 / cg" |
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 |
|
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
90 |
pixelAtX:x y:y put:aPixelValue |
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
91 |
"set the pixel at x/y to aPixelValue. |
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
92 |
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
|
93 |
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
|
94 |
|
a38cf5be1aa8
pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents:
813
diff
changeset
|
95 |
|lineIndex "{ Class: SmallInteger }"| |
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 := (width * 2 * y) + 1. |
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 |
bytes wordAt:(lineIndex + (x * 2)) put:aPixelValue MSB:true |
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 |
"Created: 24.4.1997 / 17:06:21 / cg" |
2180 | 102 |
! |
103 |
||
3872 | 104 |
rowAt:y putAll:pixelArray startingAt:startIndex |
2180 | 105 |
"store a single rows bits from bits in the pixelArray argument; |
106 |
Return the pixelArray. |
|
3872 | 107 |
Notice: row coordinate starts at 0." |
2180 | 108 |
|
109 |
|dstIdx "{ Class: SmallInteger }" |
|
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3263
diff
changeset
|
110 |
pixel |
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3263
diff
changeset
|
111 |
bytes| |
2180 | 112 |
|
3866
c01473a90934
eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents:
3263
diff
changeset
|
113 |
bytes := self bits. |
3872 | 114 |
dstIdx := (width * 2 * y) + 1. |
2180 | 115 |
1 to:width do:[:col | |
116 |
pixel := pixelArray at:(startIndex + col - 1). |
|
117 |
bytes at:dstIdx put:((pixel bitShift:-8) bitAnd:16rFF). |
|
118 |
bytes at:dstIdx+1 put:(pixel bitAnd:16rFF). |
|
119 |
dstIdx := dstIdx + 2. |
|
120 |
]. |
|
121 |
^ pixelArray |
|
122 |
||
123 |
"Created: 24.4.1997 / 15:50:27 / cg" |
|
281 | 124 |
! ! |
125 |
||
4759 | 126 |
!Depth16Image methodsFor:'initialization'! |
127 |
||
128 |
initialize |
|
129 |
super initialize. |
|
130 |
samplesPerPixel := 3. |
|
131 |
bitsPerSample := #(5 5 5). |
|
132 |
||
133 |
"Created: / 27-05-2007 / 14:09:46 / cg" |
|
134 |
! ! |
|
135 |
||
193 | 136 |
!Depth16Image methodsFor:'queries'! |
137 |
||
138 |
bitsPerPixel |
|
139 |
"return the number of bits per pixel" |
|
140 |
||
141 |
^ 16 |
|
142 |
! |
|
143 |
||
144 |
bitsPerRow |
|
145 |
"return the number of bits in one scanline of the image" |
|
146 |
||
3868 | 147 |
^ width * 16 |
193 | 148 |
! |
149 |
||
150 |
bytesPerRow |
|
151 |
"return the number of bytes in one scanline of the image" |
|
152 |
||
153 |
^ width * 2. |
|
154 |
! ! |
|
155 |
||
281 | 156 |
!Depth16Image class methodsFor:'documentation'! |
193 | 157 |
|
281 | 158 |
version |
4759 | 159 |
^ '$Header: /cvs/stx/stx/libview/Depth16Image.st,v 1.13 2007-05-29 10:13:10 cg Exp $' |
193 | 160 |
! ! |