Depth16Image.st
author Claus Gittinger <cg@exept.de>
Sat, 11 Nov 1995 16:54:10 +0100
changeset 219 9ff0660f447f
parent 193 3abcc2ee1641
child 281 4f04a56b1641
permissions -rw-r--r--
uff - version methods changed to return stings
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
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
	 instanceVariableNames:''
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	 classVariableNames:''
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	 poolDictionaries:''
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	 category:'Graphics-Images'
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
version
219
9ff0660f447f uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents: 193
diff changeset
    37
    ^ '$Header: /cvs/stx/stx/libview/Depth16Image.st,v 1.2 1995-11-11 15:49:03 cg Exp $'
193
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
documentation
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    this class represents 16 bit images.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    Only the minimum protocol is implemented here; much more is
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    needed for higher performance operations on depth16 images.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    (however, 16bit images are seldom used, so falling back into the
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    slow general methods from Image should not hurt too much ..)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
! !
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!Depth16Image class methodsFor:'queries'!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
imageDepth
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    ^ 16
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
! !
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
!Depth16Image methodsFor:'queries'!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
bitsPerPixel
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    "return the number of bits per pixel"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    ^ 16
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
bitsPerRow
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    "return the number of bits in one scanline of the image"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    ^  width * 16
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
bitsPerSample
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    "return the number of bits per sample.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
     The return value is an array of bits-per-plane."
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    ^  #(16)
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
bytesPerRow
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    "return the number of bytes in one scanline of the image"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    ^ width * 2.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
samplesPerPixel
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    "return the number of samples per pixel in the image."
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    ^ 1
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
! !
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
!Depth16Image methodsFor:'accessing'!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
valueAtX:x y:y
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    "retrieve a pixel at x/y; return a pixelValue.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
     Pixels start at x=0 , y=0 for upper left pixel, end at
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
     x = width-1, y=height-1 for lower right pixel"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    |lineIndex "{ Class: SmallInteger }"|
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    lineIndex := (width * 2 * y) + 1.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    "left pixel in high bits"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    ^ bytes wordAt:(lineIndex + (x * 2)) MSB:true.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
!
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
atX:x y:y putValue:aPixelValue
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    "set the pixel at x/y to aPixelValue.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
     Pixels start at x=0 , y=0 for upper left pixel, end at
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
     x = width-1, y=height-1 for lower right pixel"
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    |lineIndex "{ Class: SmallInteger }"|
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    lineIndex := (width * 2 * y) + 1.
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    bytes wordAt:(lineIndex + (x * 2)) put:aPixelValue MSB:true
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
! !