author | mawalch |
Thu, 09 Nov 2017 09:17:41 +0100 | |
changeset 8215 | a7e0abee3cb8 |
parent 8202 | 7b3f069ae406 |
permissions | -rw-r--r-- |
5298 | 1 |
" |
2 |
COPYRIGHT (c) 2009 by eXept Software AG |
|
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 |
" |
|
12 |
"{ Package: 'stx:libview' }" |
|
13 |
||
7212
5793dbb7ff3f
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6304
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
5793dbb7ff3f
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6304
diff
changeset
|
15 |
|
5298 | 16 |
Image subclass:#Depth48Image |
17 |
instanceVariableNames:'' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Graphics-Images' |
|
21 |
! |
|
22 |
||
23 |
!Depth48Image class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2009 by eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
this class represents 48 bit images as possibly provided by png 3x16bit rgb images. |
|
42 |
Such images are normally not used in real world applications, as humans cannot differentiate |
|
43 |
more than roughly 200 distinct color tone values. However, in image processing (false-color) applications, |
|
44 |
such a fine grain image makes sense and is sometimes used. |
|
45 |
||
7901 | 46 |
For now, the rest of the system (for example, the image editor) cannot reallydeal with |
47 |
such images. So some work may be required in the future. |
|
48 |
||
5298 | 49 |
[author:] |
50 |
Claus Gittinger |
|
51 |
||
52 |
[see also:] |
|
53 |
Depth1Image Depth2Image Depth4Image Depth8Image Depth16Image Depth24Image Depth32Image |
|
54 |
ImageReader |
|
55 |
" |
|
56 |
! ! |
|
57 |
||
58 |
!Depth48Image class methodsFor:'queries'! |
|
59 |
||
60 |
defaultPhotometric |
|
61 |
"return the default photometric pixel interpretation" |
|
62 |
||
63 |
^ #rgb |
|
64 |
! |
|
65 |
||
66 |
imageDepth |
|
67 |
"return the depth of images represented by instances of |
|
68 |
this class - here we return 48" |
|
69 |
||
70 |
^ 48 |
|
71 |
! ! |
|
72 |
||
73 |
!Depth48Image methodsFor:'accessing-pixels'! |
|
74 |
||
75 |
pixelAtX:x y:y |
|
76 |
"retrieve a pixel at x/y; return a pixelValue. |
|
7515 | 77 |
The interpretation of the returned value depends on the photometric |
78 |
and the colormap. See also Image>>atX:y:) |
|
5298 | 79 |
Pixels start at x=0 , y=0 for upper left pixel, end at |
7280 | 80 |
x = width-1, y=height-1 for lower right pixel. |
81 |
The pixel value contains r/g/b in msb order (i.e. r at high, a at low bits)" |
|
5298 | 82 |
|
83 |
|pixelIndex "{ Class: SmallInteger }"| |
|
84 |
||
6304 | 85 |
pixelFunction notNil ifTrue:[^ pixelFunction value:x value:y]. |
86 |
||
5298 | 87 |
pixelIndex := (width * 6 * y) + 1 + (x * 6). |
88 |
||
7212
5793dbb7ff3f
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6304
diff
changeset
|
89 |
^ ((bytes unsignedInt16At:pixelIndex MSB:true) bitShift:32) |
5793dbb7ff3f
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6304
diff
changeset
|
90 |
+ ((bytes unsignedInt16At:pixelIndex+2 MSB:true) bitShift:16) |
5793dbb7ff3f
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6304
diff
changeset
|
91 |
+ (bytes unsignedInt16At:pixelIndex+4 MSB:true). |
5298 | 92 |
! |
93 |
||
94 |
pixelAtX:x y:y put:aPixelValue |
|
95 |
"set the pixel at x/y to aPixelValue. |
|
7515 | 96 |
The interpretation of the pixelValue depends on the photometric |
97 |
and the colormap. (see also: Image>>atX:y:put:) |
|
5298 | 98 |
Pixels start at x=0 , y=0 for upper left pixel, end at |
99 |
x = width-1, y=height-1 for lower right pixel" |
|
100 |
||
101 |
|pixelIndex "{ Class: SmallInteger }"| |
|
102 |
||
8202 | 103 |
bytes isNil ifTrue:[ self createPixelStore ]. |
104 |
||
5298 | 105 |
pixelIndex := (width * 6 * y) + 1 + (x * 6). |
7212
5793dbb7ff3f
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6304
diff
changeset
|
106 |
bytes unsignedInt16At:pixelIndex put:((aPixelValue bitShift:-32) bitAnd:16rFFFF) MSB:true. |
5793dbb7ff3f
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6304
diff
changeset
|
107 |
bytes unsignedInt16At:pixelIndex+2 put:((aPixelValue bitShift:-16) bitAnd:16rFFFF) MSB:true. |
5793dbb7ff3f
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6304
diff
changeset
|
108 |
bytes unsignedInt16At:pixelIndex+4 put:(aPixelValue bitAnd:16rFFFF) MSB:true. |
5298 | 109 |
! ! |
110 |
||
111 |
!Depth48Image methodsFor:'initialization'! |
|
112 |
||
113 |
initialize |
|
114 |
super initialize. |
|
115 |
samplesPerPixel := 3. |
|
7820 | 116 |
bitsPerSample := #[16 16 16]. |
117 |
||
118 |
"Modified: / 30-01-2017 / 19:32:29 / stefan" |
|
5298 | 119 |
! ! |
120 |
||
121 |
!Depth48Image methodsFor:'queries'! |
|
122 |
||
123 |
bitsPerPixel |
|
124 |
"return the number of bits per pixel" |
|
125 |
||
126 |
^ 48 |
|
127 |
! |
|
128 |
||
129 |
bitsPerRow |
|
130 |
"return the number of bits in one scanline of the image" |
|
131 |
||
132 |
^ width * 48 |
|
133 |
! |
|
134 |
||
135 |
bytesPerRow |
|
136 |
"return the number of bytes in one scanline of the image" |
|
137 |
||
138 |
^ width * 6. |
|
139 |
! ! |
|
140 |
||
141 |
!Depth48Image class methodsFor:'documentation'! |
|
142 |
||
143 |
version |
|
7212
5793dbb7ff3f
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6304
diff
changeset
|
144 |
^ '$Header$' |
5298 | 145 |
! ! |
6304 | 146 |