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