Depth48Image.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 08 Dec 2017 09:10:33 +0000
branchjv
changeset 8232 ddbaa22b9352
parent 7820 6aa5db2eb320
child 7901 b9172b06ac27
child 8426 e2051b1553f0
permissions -rw-r--r--
Issue #186: Win32: use inline C in `#setForegroundWindow:` ...rather than FFI. It's much faster and uses lot less stack. The latter is also important since `#setForegroundWindow:` is called when opening debugger. In case a debugger is opened due to a recursion interrupt, stack space is very limited so better save every byte. https://swing.fit.cvut.cz/projects/stx-jv/ticket/186
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
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
    [author:]
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
        Claus Gittinger
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    [see also:]
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
        Depth1Image Depth2Image Depth4Image Depth8Image Depth16Image Depth24Image Depth32Image
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
        ImageReader
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
"
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
! !
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
!Depth48Image class methodsFor:'queries'!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
defaultPhotometric
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    "return the default photometric pixel interpretation"
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    ^ #rgb
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
imageDepth
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    "return the depth of images represented by instances of
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
     this class - here we return 48"
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    ^ 48
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
! !
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
!Depth48Image methodsFor:'accessing-pixels'!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
pixelAtX:x y:y
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    "retrieve a pixel at x/y; return a pixelValue.
7515
5da614f4971d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7280
diff changeset
    74
     The interpretation of the returned value depends on the photometric
5da614f4971d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7280
diff changeset
    75
     and the colormap. See also Image>>atX:y:)
5298
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
     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
    77
     x = width-1, y=height-1 for lower right pixel.
b1898f640286 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7212
diff changeset
    78
     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
    79
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    |pixelIndex "{ Class: SmallInteger }"|
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
6304
b39dfc65552b pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 5298
diff changeset
    82
    pixelFunction notNil ifTrue:[^ pixelFunction value:x value:y].
b39dfc65552b pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 5298
diff changeset
    83
5298
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    pixelIndex := (width * 6 * y) + 1 + (x * 6).
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
7212
5793dbb7ff3f call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6304
diff changeset
    86
    ^ ((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
    87
    + ((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
    88
    + (bytes unsignedInt16At:pixelIndex+4 MSB:true).
5298
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
pixelAtX:x y:y put:aPixelValue
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    "set the pixel at x/y to aPixelValue.
7515
5da614f4971d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7280
diff changeset
    93
     The interpretation of the pixelValue depends on the photometric
5da614f4971d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 7280
diff changeset
    94
     and the colormap. (see also: Image>>atX:y:put:)
5298
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
     Pixels start at x=0 , y=0 for upper left pixel, end at
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
     x = width-1, y=height-1 for lower right pixel"
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    |pixelIndex "{ Class: SmallInteger }"|
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    pixelIndex := (width * 6 * y) + 1 + (x * 6).
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    bytes isNil ifTrue:[
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
        self createPixelStore
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    ].
7212
5793dbb7ff3f call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6304
diff changeset
   104
    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
   105
    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
   106
    bytes unsignedInt16At:pixelIndex+4 put:(aPixelValue bitAnd:16rFFFF) MSB:true.
5298
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
! !
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
!Depth48Image methodsFor:'initialization'!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
initialize
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    super initialize.
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    samplesPerPixel := 3. 
7820
6aa5db2eb320 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
   114
    bitsPerSample := #[16 16 16].
6aa5db2eb320 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
   115
6aa5db2eb320 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
   116
    "Modified: / 30-01-2017 / 19:32:29 / stefan"
5298
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
! !
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
!Depth48Image methodsFor:'queries'!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
bitsPerPixel
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    "return the number of bits per pixel"
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    ^ 48
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
bitsPerRow
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    "return the number of bits in one scanline of the image"
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    ^ width * 48
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
bytesPerRow
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    "return the number of bytes in one scanline of the image"
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    ^ width * 6.
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
! !
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
!Depth48Image class methodsFor:'documentation'!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
version
7212
5793dbb7ff3f call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6304
diff changeset
   142
    ^ '$Header$'
5298
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
! !
6304
b39dfc65552b pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 5298
diff changeset
   144