Depth16Image.st
author Claus Gittinger <cg@exept.de>
Thu, 24 Apr 1997 18:03:30 +0200
changeset 1659 a38cf5be1aa8
parent 813 8bc17dba7a02
child 2180 c6b09d67eb40
permissions -rw-r--r--
pixel accessing methods cleaned up
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
"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
Image subclass:#Depth16Image
579
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    14
	instanceVariableNames:''
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    15
	classVariableNames:''
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    16
	poolDictionaries:''
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    17
	category:'Graphics-Images'
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!Depth16Image class methodsFor:'documentation'!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
copyright
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
 COPYRIGHT (c) 1995 by Claus Gittinger
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
	      All Rights Reserved
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
 This software is furnished under a license and may be used
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 only in accordance with the terms of that license and with the
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 be provided or otherwise made available to, or used by, any
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 other person.  No title to or ownership of the software is
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 hereby transferred.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
"
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
documentation
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
    this class represents 16 bit images.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    Only the minimum protocol is implemented here; much more is
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    needed for higher performance operations on depth16 images.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    (however, 16bit images are seldom used, so falling back into the
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    slow general methods from Image should not hurt too much ..)
611
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    43
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    44
    [author:]
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    45
        Claus Gittinger
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    46
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    47
    [see also:]
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    48
        Depth1Image Depth2Image Depth4Image Depth8Image Depth24Image
e0442439a3c6 documentation
Claus Gittinger <cg@exept.de>
parents: 579
diff changeset
    49
        ImageReader
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
"
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
!Depth16Image class methodsFor:'queries'!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
imageDepth
579
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    56
    "return the depth of images represented by instances of
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    57
     this class - here we return 16"
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    58
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    ^ 16
579
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    60
e381761190c4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 281
diff changeset
    61
    "Modified: 20.4.1996 / 23:40:01 / cg"
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
! !
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
1659
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    64
!Depth16Image methodsFor:'accessing - pixels'!
281
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    65
1659
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    66
pixelAtX:x y:y
281
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    67
    "retrieve a pixel at x/y; return a pixelValue.
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    68
     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
    69
     x = width-1, y=height-1 for lower right pixel"
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    70
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    71
    |lineIndex "{ Class: SmallInteger }"|
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    72
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    73
    lineIndex := (width * 2 * y) + 1.
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    74
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    75
    "left pixel in high bits"
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    76
    ^ bytes wordAt:(lineIndex + (x * 2)) MSB:true.
1659
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    77
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    78
    "Created: 24.4.1997 / 16:06:19 / cg"
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    79
!
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    80
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    81
pixelAtX:x y:y put:aPixelValue
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    82
    "set the pixel at x/y to aPixelValue.
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    83
     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
    84
     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
    85
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    86
    |lineIndex "{ Class: SmallInteger }"|
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    87
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
    88
    lineIndex := (width * 2 * y) + 1.
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
    bytes wordAt:(lineIndex + (x * 2)) put:aPixelValue MSB:true
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
    "Created: 24.4.1997 / 17:06:21 / cg"
281
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    93
! !
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    94
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
!Depth16Image methodsFor:'queries'!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
bitsPerPixel
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    "return the number of bits per pixel"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    ^ 16
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
bitsPerRow
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    "return the number of bits in one scanline of the image"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    ^  width * 16
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
bytesPerRow
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    "return the number of bytes in one scanline of the image"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    ^ width * 2.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
! !
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
281
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   115
!Depth16Image class methodsFor:'documentation'!
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
281
4f04a56b1641 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   117
version
1659
a38cf5be1aa8 pixel accessing methods cleaned up
Claus Gittinger <cg@exept.de>
parents: 813
diff changeset
   118
    ^ '$Header: /cvs/stx/stx/libview/Depth16Image.st,v 1.7 1997-04-24 16:03:30 cg Exp $'
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
! !