Depth64Image.st
author Claus Gittinger <cg@exept.de>
Wed, 22 Aug 2018 12:58:11 +0200
changeset 8451 6eafe0433763
parent 8200 b16bae6c33f6
permissions -rw-r--r--
#QUALITY by cg class: WindowSensor comment/format in: #basicAddDamage:view:

"
 COPYRIGHT (c) 2009 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libview' }"

"{ NameSpace: Smalltalk }"

Image subclass:#Depth64Image
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Graphics-Images'
!

!Depth64Image class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2009 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    this class represents 64 bit images as possibly provided by png 4x16bit rgba images.
    Such images are normally not used in real world applications, as humans cannot differentiate 
    more than roughly 200 distinct color tone values. However, in image processing (false-color) applications,
    such a fine grain image makes sense and is sometimes used.

    For now, the rest of the system (for example, the image editor) cannot reallydeal with
    such images. So some work may be required in the future.

    [author:]
        Claus Gittinger

    [see also:]
        Depth1Image Depth2Image Depth4Image Depth8Image Depth16Image Depth24Image Depth32Image
        ImageReader
"
! !

!Depth64Image class methodsFor:'queries'!

defaultPhotometric
    "return the default photometric pixel interpretation"

    ^ #rgba

    "Modified: / 22-08-2017 / 17:40:01 / cg"
!

imageDepth
    "return the depth of images represented by instances of
     this class - here we return 64"

    ^ 64
! !

!Depth64Image methodsFor:'accessing-pixels'!

pixelAtX:x y:y
    "retrieve a pixel at x/y; return a pixelValue.
     The interpretation of the returned value depends on the photometric
     and the colormap. See also Image>>atX:y:)
     Pixels start at x=0 , y=0 for upper left pixel, end at
     x = width-1, y=height-1 for lower right pixel.
     The pixel value contains r/g/b/a in msb order (i.e. r at high, a at low bits)"

    |pixelIndex "{ Class: SmallInteger }"|

    pixelFunction notNil ifTrue:[^ pixelFunction value:x value:y].

    pixelIndex := (width * 8 * y) + 1 + (x * 8).

    ^ ((bytes unsignedInt16At:pixelIndex MSB:true) bitShift:48)
    + ((bytes unsignedInt16At:pixelIndex+2 MSB:true) bitShift:32)
    + ((bytes unsignedInt16At:pixelIndex+4 MSB:true) bitShift:16)
    + (bytes unsignedInt16At:pixelIndex+6 MSB:true).
!

pixelAtX:x y:y put:aPixelValue
    "set the pixel at x/y to aPixelValue.
     The interpretation of the pixelValue depends on the photometric
     and the colormap. (see also: Image>>atX:y:put:)
     Pixels start at x=0 , y=0 for upper left pixel, end at
     x = width-1, y=height-1 for lower right pixel"

    |pixelIndex "{ Class: SmallInteger }"|

    bytes isNil ifTrue:[ self createPixelStore ].

    pixelIndex := (width * 8 * y) + 1 + (x * 8).
    bytes unsignedInt16At:pixelIndex put:((aPixelValue bitShift:-48) bitAnd:16rFFFF) MSB:true.
    bytes unsignedInt16At:pixelIndex+2 put:((aPixelValue bitShift:-32) bitAnd:16rFFFF) MSB:true.
    bytes unsignedInt16At:pixelIndex+4 put:((aPixelValue bitShift:-16) bitAnd:16rFFFF) MSB:true.
    bytes unsignedInt16At:pixelIndex+6 put:(aPixelValue bitAnd:16rFFFF) MSB:true.
! !

!Depth64Image methodsFor:'initialization'!

initialize
    super initialize.
    samplesPerPixel := 4. 
    bitsPerSample := #[16 16 16 16].

    "Modified: / 31-01-2017 / 13:11:33 / stefan"
! !

!Depth64Image methodsFor:'queries'!

bitsPerPixel
    "return the number of bits per pixel"

    ^ 64
!

bitsPerRow
    "return the number of bits in one scanline of the image"

    ^ width * 64
!

bytesPerRow
    "return the number of bytes in one scanline of the image"

    ^ width * 8.
!

hasAlphaChannel
    ^ true
! !

!Depth64Image class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !