Depth48Image.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 26 Nov 2016 21:09:32 +0000
branchjv
changeset 7719 c2f802dd340a
parent 7515 5da614f4971d
child 7820 6aa5db2eb320
permissions -rw-r--r--
XFT: Forbid XFT rendering on bitmaps (depth-1 pixmaps) In theory it could work if XFT would just turn gray into either black or white. But XFT doesn't do it and simply draw nothing without failing in any way. To prevent this silent failures, forbid drawing XFT onto bitmaps (depth-1 pixmaps). After all, the while point of XFT is to use anti-aliased fonts.
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. 
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    bitsPerSample := #(16 16 16).
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
! !
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
!Depth48Image methodsFor:'queries'!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
bitsPerPixel
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    "return the number of bits per pixel"
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    ^ 48
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
bitsPerRow
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    "return the number of bits in one scanline of the image"
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    ^ width * 48
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
bytesPerRow
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    "return the number of bytes in one scanline of the image"
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    ^ width * 6.
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
! !
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
!Depth48Image class methodsFor:'documentation'!
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
version
7212
5793dbb7ff3f call the renamed basic methods for short access:
Claus Gittinger <cg@exept.de>
parents: 6304
diff changeset
   140
    ^ '$Header$'
5298
97c54512fe23 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
! !
6304
b39dfc65552b pixelfunction support
Claus Gittinger <cg@exept.de>
parents: 5298
diff changeset
   142