Depth64Image.st
author matilk
Wed, 13 Sep 2017 09:40:34 +0200
changeset 8174 2704c965b97b
parent 8084 95a21362ceba
child 8200 b16bae6c33f6
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:
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2009 by eXept Software AG
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libview' }"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
7211
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
    14
"{ NameSpace: Smalltalk }"
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
    15
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Image subclass:#Depth64Image
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:''
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:''
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Graphics-Images'
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!Depth64Image class methodsFor:'documentation'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
copyright
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 (c) 2009 by eXept Software AG
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
              All Rights Reserved
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 This software is furnished under a license and may be used
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 hereby transferred.
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    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
    42
    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
    43
    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
    44
    such a fine grain image makes sense and is sometimes used.
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
7900
071c5d996122 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7822
diff changeset
    46
    For now, the rest of the system (for example, the image editor) cannot reallydeal with
071c5d996122 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7822
diff changeset
    47
    such images. So some work may be required in the future.
071c5d996122 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 7822
diff changeset
    48
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    [author:]
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
        Claus Gittinger
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    [see also:]
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
        Depth1Image Depth2Image Depth4Image Depth8Image Depth16Image Depth24Image Depth32Image
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
        ImageReader
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
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
!Depth64Image class methodsFor:'queries'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
defaultPhotometric
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    "return the default photometric pixel interpretation"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
8084
95a21362ceba #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7900
diff changeset
    63
    ^ #rgba
95a21362ceba #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7900
diff changeset
    64
95a21362ceba #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 7900
diff changeset
    65
    "Modified: / 22-08-2017 / 17:40:01 / cg"
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
imageDepth
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    "return the depth of images represented by instances of
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
     this class - here we return 64"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    ^ 64
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
! !
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
!Depth64Image methodsFor:'accessing-pixels'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
pixelAtX:x y:y
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    "retrieve a pixel at x/y; return a pixelValue.
7517
c41855f2c494 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7281
diff changeset
    79
     The interpretation of the returned value depends on the photometric
c41855f2c494 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7281
diff changeset
    80
     and the colormap. See also Image>>atX:y:)
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
     Pixels start at x=0 , y=0 for upper left pixel, end at
7281
89956b990563 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7213
diff changeset
    82
     x = width-1, y=height-1 for lower right pixel.
89956b990563 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7213
diff changeset
    83
     The pixel value contains r/g/b/a in msb order (i.e. r at high, a at low bits)"
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    |pixelIndex "{ Class: SmallInteger }"|
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
6297
ea0fe952c3a5 pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
    87
    pixelFunction notNil ifTrue:[^ pixelFunction value:x value:y].
ea0fe952c3a5 pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
    88
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    pixelIndex := (width * 8 * y) + 1 + (x * 8).
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
7211
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
    91
    ^ ((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
    92
    + ((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
    93
    + ((bytes unsignedInt16At:pixelIndex+4 MSB:true) bitShift:16)
7213
55e7421aab9d #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 7211
diff changeset
    94
    + (bytes unsignedInt16At:pixelIndex+6 MSB:true).
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
pixelAtX:x y:y put:aPixelValue
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    "set the pixel at x/y to aPixelValue.
7517
c41855f2c494 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7281
diff changeset
    99
     The interpretation of the pixelValue depends on the photometric
c41855f2c494 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7281
diff changeset
   100
     and the colormap. (see also: Image>>atX:y:put:)
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
     Pixels start at x=0 , y=0 for upper left pixel, end at
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
     x = width-1, y=height-1 for lower right pixel"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    |pixelIndex "{ Class: SmallInteger }"|
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    pixelIndex := (width * 8 * y) + 1 + (x * 8).
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    bytes isNil ifTrue:[
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
        self createPixelStore
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    ].
7211
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
   110
    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
   111
    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
   112
    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
   113
    bytes unsignedInt16At:pixelIndex+6 put:(aPixelValue bitAnd:16rFFFF) MSB:true.
5306
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:'initialization'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
initialize
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    super initialize.
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    samplesPerPixel := 4. 
7822
ecb148190095 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7517
diff changeset
   121
    bitsPerSample := #[16 16 16 16].
ecb148190095 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7517
diff changeset
   122
ecb148190095 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7517
diff changeset
   123
    "Modified: / 31-01-2017 / 13:11:33 / stefan"
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
! !
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
!Depth64Image methodsFor:'queries'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
bitsPerPixel
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    "return the number of bits per pixel"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    ^ 64
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
bitsPerRow
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    "return the number of bits in one scanline of the image"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    ^ width * 64
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
bytesPerRow
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    "return the number of bytes in one scanline of the image"
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    ^ width * 8.
5325
e213afc8874c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5323
diff changeset
   144
!
e213afc8874c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5323
diff changeset
   145
e213afc8874c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5323
diff changeset
   146
hasAlphaChannel
e213afc8874c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5323
diff changeset
   147
    ^ true
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
! !
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
!Depth64Image class methodsFor:'documentation'!
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
version
7211
1e72cd273ab3 call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6297
diff changeset
   153
    ^ '$Header$'
7213
55e7421aab9d #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 7211
diff changeset
   154
!
55e7421aab9d #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 7211
diff changeset
   155
55e7421aab9d #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 7211
diff changeset
   156
version_CVS
55e7421aab9d #REFACTORING
Claus Gittinger <cg@exept.de>
parents: 7211
diff changeset
   157
    ^ '$Header$'
5306
2f2855e29c04 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
! !
6297
ea0fe952c3a5 pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 5325
diff changeset
   159