Depth64Image.st
author Claus Gittinger <cg@exept.de>
Tue, 15 Mar 2016 22:47:35 +0100
changeset 7213 55e7421aab9d
parent 7211 1e72cd273ab3
child 7281 89956b990563
permissions -rw-r--r--
#REFACTORING class: Depth64Image changed: #pixelAtX:y:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7211
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
     1
"{ Encoding: utf8 }"
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
     2
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 2009 by eXept Software AG
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
              All Rights Reserved
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libview' }"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
7211
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
    16
"{ NameSpace: Smalltalk }"
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
    17
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
Image subclass:#Depth64Image
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:''
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Graphics-Images'
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
!Depth64Image class methodsFor:'documentation'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
copyright
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 2009 by eXept Software AG
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
              All Rights Reserved
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    this class represents 64 bit images as possibly provided by png 4x16bit rgba images.
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    Such images are normally not used in real world applications, as humans cannot differentiate 
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    more than roughly 200 distinct color tone values. However, in image processing (false-color) applications,
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    such a fine grain image makes sense and is sometimes used.
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    [author:]
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
        Claus Gittinger
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    [see also:]
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
        Depth1Image Depth2Image Depth4Image Depth8Image Depth16Image Depth24Image Depth32Image
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
        ImageReader
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
! !
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
!Depth64Image class methodsFor:'queries'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
defaultPhotometric
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    "return the default photometric pixel interpretation"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
5323
a90a212f9429 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5306
diff changeset
    62
    ^ #rgb
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
imageDepth
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    "return the depth of images represented by instances of
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
     this class - here we return 64"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    ^ 64
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
! !
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
!Depth64Image methodsFor:'accessing-pixels'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
pixelAtX:x y:y
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    "retrieve a pixel at x/y; return a pixelValue.
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
     Pixels start at x=0 , y=0 for upper left pixel, end at
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
     x = width-1, y=height-1 for lower right pixel"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    |pixelIndex "{ Class: SmallInteger }"|
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
6297
ea0fe952c3a5 pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
    81
    pixelFunction notNil ifTrue:[^ pixelFunction value:x value:y].
ea0fe952c3a5 pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
    82
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    pixelIndex := (width * 8 * y) + 1 + (x * 8).
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
7211
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
    85
    ^ ((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
    86
    + ((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
    87
    + ((bytes unsignedInt16At:pixelIndex+4 MSB:true) bitShift:16)
7213
55e7421aab9d #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 7211
diff changeset
    88
    + (bytes unsignedInt16At:pixelIndex+6 MSB:true).
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
pixelAtX:x y:y put:aPixelValue
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    "set the pixel at x/y to aPixelValue.
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
     Pixels start at x=0 , y=0 for upper left pixel, end at
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
     x = width-1, y=height-1 for lower right pixel"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    |pixelIndex "{ Class: SmallInteger }"|
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    pixelIndex := (width * 8 * y) + 1 + (x * 8).
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    bytes isNil ifTrue:[
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
        self createPixelStore
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    ].
7211
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
   102
    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
   103
    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
   104
    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
   105
    bytes unsignedInt16At:pixelIndex+6 put:(aPixelValue bitAnd:16rFFFF) MSB:true.
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
! !
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
!Depth64Image methodsFor:'initialization'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
initialize
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    super initialize.
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    samplesPerPixel := 4. 
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    bitsPerSample := #(16 16 16 16).
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
! !
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
!Depth64Image methodsFor:'queries'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
bitsPerPixel
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    "return the number of bits per pixel"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    ^ 64
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
bitsPerRow
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    "return the number of bits in one scanline of the image"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    ^ width * 64
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
bytesPerRow
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    "return the number of bytes in one scanline of the image"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    ^ width * 8.
5325
e213afc8874c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5323
diff changeset
   134
!
e213afc8874c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5323
diff changeset
   135
e213afc8874c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5323
diff changeset
   136
hasAlphaChannel
e213afc8874c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5323
diff changeset
   137
    ^ true
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
! !
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
!Depth64Image class methodsFor:'documentation'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
version
7211
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
   143
    ^ '$Header$'
7213
55e7421aab9d #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 7211
diff changeset
   144
!
55e7421aab9d #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 7211
diff changeset
   145
55e7421aab9d #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 7211
diff changeset
   146
version_CVS
55e7421aab9d #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 7211
diff changeset
   147
    ^ '$Header$'
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
! !
6297
ea0fe952c3a5 pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
   149