author | Patrik Svestka <patrik.svestka@gmail.com> |
Wed, 11 Jul 2018 16:58:29 +0200 | |
branch | jv |
changeset 8426 | e2051b1553f0 |
parent 7822 | ecb148190095 |
permissions | -rw-r--r-- |
5306 | 1 |
" |
2 |
COPYRIGHT (c) 2009 by eXept Software AG |
|
8426
e2051b1553f0
Issue #126: Removing hack, correctly calculating masDisplayBuffer and having fallback maxDisplayBuffer is set to 107 characters.
Patrik Svestka <patrik.svestka@gmail.com>
parents:
7822
diff
changeset
|
3 |
COPYRIGHT (c) 2018 Patrik Svestka |
5306 | 4 |
All Rights Reserved |
5 |
||
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
13 |
"{ Package: 'stx:libview' }" |
|
14 |
||
7211
1e72cd273ab3
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6297
diff
changeset
|
15 |
"{ NameSpace: Smalltalk }" |
1e72cd273ab3
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6297
diff
changeset
|
16 |
|
5306 | 17 |
Image subclass:#Depth64Image |
18 |
instanceVariableNames:'' |
|
19 |
classVariableNames:'' |
|
20 |
poolDictionaries:'' |
|
21 |
category:'Graphics-Images' |
|
22 |
! |
|
23 |
||
24 |
!Depth64Image class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 2009 by eXept Software AG |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
this class represents 64 bit images as possibly provided by png 4x16bit rgba images. |
|
43 |
Such images are normally not used in real world applications, as humans cannot differentiate |
|
44 |
more than roughly 200 distinct color tone values. However, in image processing (false-color) applications, |
|
45 |
such a fine grain image makes sense and is sometimes used. |
|
46 |
||
47 |
[author:] |
|
48 |
Claus Gittinger |
|
49 |
||
50 |
[see also:] |
|
51 |
Depth1Image Depth2Image Depth4Image Depth8Image Depth16Image Depth24Image Depth32Image |
|
52 |
ImageReader |
|
53 |
" |
|
54 |
! ! |
|
55 |
||
56 |
!Depth64Image class methodsFor:'queries'! |
|
57 |
||
58 |
defaultPhotometric |
|
59 |
"return the default photometric pixel interpretation" |
|
60 |
||
5323 | 61 |
^ #rgb |
5306 | 62 |
! |
63 |
||
64 |
imageDepth |
|
65 |
"return the depth of images represented by instances of |
|
66 |
this class - here we return 64" |
|
67 |
||
68 |
^ 64 |
|
69 |
! ! |
|
70 |
||
71 |
!Depth64Image methodsFor:'accessing-pixels'! |
|
72 |
||
73 |
pixelAtX:x y:y |
|
74 |
"retrieve a pixel at x/y; return a pixelValue. |
|
7517 | 75 |
The interpretation of the returned value depends on the photometric |
76 |
and the colormap. See also Image>>atX:y:) |
|
5306 | 77 |
Pixels start at x=0 , y=0 for upper left pixel, end at |
7281 | 78 |
x = width-1, y=height-1 for lower right pixel. |
79 |
The pixel value contains r/g/b/a in msb order (i.e. r at high, a at low bits)" |
|
5306 | 80 |
|
81 |
|pixelIndex "{ Class: SmallInteger }"| |
|
82 |
||
6297 | 83 |
pixelFunction notNil ifTrue:[^ pixelFunction value:x value:y]. |
84 |
||
5306 | 85 |
pixelIndex := (width * 8 * y) + 1 + (x * 8). |
86 |
||
7211
1e72cd273ab3
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6297
diff
changeset
|
87 |
^ ((bytes unsignedInt16At:pixelIndex MSB:true) bitShift:48) |
1e72cd273ab3
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6297
diff
changeset
|
88 |
+ ((bytes unsignedInt16At:pixelIndex+2 MSB:true) bitShift:32) |
1e72cd273ab3
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6297
diff
changeset
|
89 |
+ ((bytes unsignedInt16At:pixelIndex+4 MSB:true) bitShift:16) |
7213 | 90 |
+ (bytes unsignedInt16At:pixelIndex+6 MSB:true). |
5306 | 91 |
! |
92 |
||
93 |
pixelAtX:x y:y put:aPixelValue |
|
94 |
"set the pixel at x/y to aPixelValue. |
|
7517 | 95 |
The interpretation of the pixelValue depends on the photometric |
96 |
and the colormap. (see also: Image>>atX:y:put:) |
|
5306 | 97 |
Pixels start at x=0 , y=0 for upper left pixel, end at |
98 |
x = width-1, y=height-1 for lower right pixel" |
|
99 |
||
100 |
|pixelIndex "{ Class: SmallInteger }"| |
|
101 |
||
102 |
pixelIndex := (width * 8 * y) + 1 + (x * 8). |
|
103 |
bytes isNil ifTrue:[ |
|
104 |
self createPixelStore |
|
105 |
]. |
|
7211
1e72cd273ab3
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6297
diff
changeset
|
106 |
bytes unsignedInt16At:pixelIndex put:((aPixelValue bitShift:-48) bitAnd:16rFFFF) MSB:true. |
1e72cd273ab3
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6297
diff
changeset
|
107 |
bytes unsignedInt16At:pixelIndex+2 put:((aPixelValue bitShift:-32) bitAnd:16rFFFF) MSB:true. |
1e72cd273ab3
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6297
diff
changeset
|
108 |
bytes unsignedInt16At:pixelIndex+4 put:((aPixelValue bitShift:-16) bitAnd:16rFFFF) MSB:true. |
1e72cd273ab3
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6297
diff
changeset
|
109 |
bytes unsignedInt16At:pixelIndex+6 put:(aPixelValue bitAnd:16rFFFF) MSB:true. |
5306 | 110 |
! ! |
111 |
||
112 |
!Depth64Image methodsFor:'initialization'! |
|
113 |
||
114 |
initialize |
|
115 |
super initialize. |
|
116 |
samplesPerPixel := 4. |
|
7822 | 117 |
bitsPerSample := #[16 16 16 16]. |
118 |
||
119 |
"Modified: / 31-01-2017 / 13:11:33 / stefan" |
|
5306 | 120 |
! ! |
121 |
||
122 |
!Depth64Image methodsFor:'queries'! |
|
123 |
||
124 |
bitsPerPixel |
|
125 |
"return the number of bits per pixel" |
|
126 |
||
127 |
^ 64 |
|
128 |
! |
|
129 |
||
130 |
bitsPerRow |
|
131 |
"return the number of bits in one scanline of the image" |
|
132 |
||
133 |
^ width * 64 |
|
134 |
! |
|
135 |
||
136 |
bytesPerRow |
|
137 |
"return the number of bytes in one scanline of the image" |
|
138 |
||
139 |
^ width * 8. |
|
5325 | 140 |
! |
141 |
||
142 |
hasAlphaChannel |
|
143 |
^ true |
|
8426
e2051b1553f0
Issue #126: Removing hack, correctly calculating masDisplayBuffer and having fallback maxDisplayBuffer is set to 107 characters.
Patrik Svestka <patrik.svestka@gmail.com>
parents:
7822
diff
changeset
|
144 |
! |
e2051b1553f0
Issue #126: Removing hack, correctly calculating masDisplayBuffer and having fallback maxDisplayBuffer is set to 107 characters.
Patrik Svestka <patrik.svestka@gmail.com>
parents:
7822
diff
changeset
|
145 |
|
e2051b1553f0
Issue #126: Removing hack, correctly calculating masDisplayBuffer and having fallback maxDisplayBuffer is set to 107 characters.
Patrik Svestka <patrik.svestka@gmail.com>
parents:
7822
diff
changeset
|
146 |
isDepth64Image |
e2051b1553f0
Issue #126: Removing hack, correctly calculating masDisplayBuffer and having fallback maxDisplayBuffer is set to 107 characters.
Patrik Svestka <patrik.svestka@gmail.com>
parents:
7822
diff
changeset
|
147 |
"return true if the image is instance of Depth64Image" |
e2051b1553f0
Issue #126: Removing hack, correctly calculating masDisplayBuffer and having fallback maxDisplayBuffer is set to 107 characters.
Patrik Svestka <patrik.svestka@gmail.com>
parents:
7822
diff
changeset
|
148 |
(self bitsPerPixel == 64) ifTrue:[^ true]. |
e2051b1553f0
Issue #126: Removing hack, correctly calculating masDisplayBuffer and having fallback maxDisplayBuffer is set to 107 characters.
Patrik Svestka <patrik.svestka@gmail.com>
parents:
7822
diff
changeset
|
149 |
^ false |
e2051b1553f0
Issue #126: Removing hack, correctly calculating masDisplayBuffer and having fallback maxDisplayBuffer is set to 107 characters.
Patrik Svestka <patrik.svestka@gmail.com>
parents:
7822
diff
changeset
|
150 |
|
e2051b1553f0
Issue #126: Removing hack, correctly calculating masDisplayBuffer and having fallback maxDisplayBuffer is set to 107 characters.
Patrik Svestka <patrik.svestka@gmail.com>
parents:
7822
diff
changeset
|
151 |
"Created: / 16-04-2018 / 17:01:31 / svestkap" |
5306 | 152 |
! ! |
153 |
||
154 |
!Depth64Image class methodsFor:'documentation'! |
|
155 |
||
156 |
version |
|
7211
1e72cd273ab3
call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents:
6297
diff
changeset
|
157 |
^ '$Header$' |
7213 | 158 |
! |
159 |
||
160 |
version_CVS |
|
161 |
^ '$Header$' |
|
5306 | 162 |
! ! |
6297 | 163 |