Depth16Image.st
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--
defaultPhotometric
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
3263
bd92a12c9316 category changes
Claus Gittinger <cg@exept.de>
parents: 2180
diff changeset
    12
"{ Package: 'stx:libview' }"
bd92a12c9316 category changes
Claus Gittinger <cg@exept.de>
parents: 2180
diff changeset
    13
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
Image subclass:#Depth16Image
579
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    15
	instanceVariableNames:''
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    16
	classVariableNames:''
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    17
	poolDictionaries:''
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    18
	category:'Graphics-Images'
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!Depth16Image class methodsFor:'documentation'!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 COPYRIGHT (c) 1995 by Claus Gittinger
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
	      All Rights Reserved
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
documentation
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    this class represents 16 bit images.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    Only the minimum protocol is implemented here; much more is
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    needed for higher performance operations on depth16 images.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    (however, 16bit images are seldom used, so falling back into the
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    slow general methods from Image should not hurt too much ..)
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    44
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    45
    [author:]
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    46
        Claus Gittinger
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    47
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    48
    [see also:]
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    49
        Depth1Image Depth2Image Depth4Image Depth8Image Depth24Image
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    50
        ImageReader
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
! !
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
!Depth16Image class methodsFor:'queries'!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
4759
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
    56
defaultPhotometric
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
    57
    "return the default photometric pixel interpretation"
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
    58
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
    59
    ^ #rgb
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
    60
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
    61
    "Created: / 27-05-2007 / 14:04:11 / cg"
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
    62
!
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
    63
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
imageDepth
579
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    65
    "return the depth of images represented by instances of
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    66
     this class - here we return 16"
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    67
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    ^ 16
579
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    69
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    70
    "Modified: 20.4.1996 / 23:40:01 / cg"
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
! !
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
3263
bd92a12c9316 category changes
Claus Gittinger <cg@exept.de>
parents: 2180
diff changeset
    73
!Depth16Image methodsFor:'accessing-pixels'!
281
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    74
1659
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    75
pixelAtX:x y:y
281
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    76
    "retrieve a pixel at x/y; return a pixelValue.
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    77
     Pixels start at x=0 , y=0 for upper left pixel, end at
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    78
     x = width-1, y=height-1 for lower right pixel"
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    79
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    80
    |lineIndex "{ Class: SmallInteger }"|
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    81
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    82
    lineIndex := (width * 2 * y) + 1.
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    83
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    84
    "left pixel in high bits"
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    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
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   102
!
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   103
3872
390fabbc3036 comments and slight cleanup
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
   104
rowAt:y putAll:pixelArray startingAt:startIndex
2180
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   105
    "store a single rows bits from bits in the pixelArray argument;
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   106
     Return the pixelArray.
3872
390fabbc3036 comments and slight cleanup
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
   107
     Notice: row coordinate starts at 0."
2180
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   108
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   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
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   112
3866
c01473a90934 eliminated most references to bytes
Claus Gittinger <cg@exept.de>
parents: 3263
diff changeset
   113
    bytes := self bits.
3872
390fabbc3036 comments and slight cleanup
Claus Gittinger <cg@exept.de>
parents: 3868
diff changeset
   114
    dstIdx := (width * 2 * y) + 1.
2180
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   115
    1 to:width do:[:col |
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   116
        pixel := pixelArray at:(startIndex + col - 1).
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   117
        bytes at:dstIdx put:((pixel bitShift:-8) bitAnd:16rFF).
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   118
        bytes at:dstIdx+1 put:(pixel bitAnd:16rFF).
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   119
        dstIdx := dstIdx + 2.
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   120
    ].
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   121
    ^ pixelArray
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   122
c6b09d67eb40 tuned rowAt:putAll
tz
parents: 1659
diff changeset
   123
    "Created: 24.4.1997 / 15:50:27 / cg"
281
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   124
! !
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   125
4759
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
   126
!Depth16Image methodsFor:'initialization'!
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
   127
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
   128
initialize
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
   129
    super initialize.
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
   130
    samplesPerPixel := 3. 
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
   131
    bitsPerSample := #(5 5 5).
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
   132
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
   133
    "Created: / 27-05-2007 / 14:09:46 / cg"
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
   134
! !
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
   135
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
!Depth16Image methodsFor:'queries'!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
bitsPerPixel
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    "return the number of bits per pixel"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    ^ 16
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
bitsPerRow
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    "return the number of bits in one scanline of the image"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
3868
e47cf114c824 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3866
diff changeset
   147
    ^ width * 16
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
bytesPerRow
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    "return the number of bytes in one scanline of the image"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    ^ width * 2.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
! !
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
281
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   156
!Depth16Image class methodsFor:'documentation'!
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
281
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   158
version
4759
55e8bc994d61 defaultPhotometric
Claus Gittinger <cg@exept.de>
parents: 3872
diff changeset
   159
    ^ '$Header: /cvs/stx/stx/libview/Depth16Image.st,v 1.13 2007-05-29 10:13:10 cg Exp $'
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
! !