initial checkin
authorClaus Gittinger <cg@exept.de>
Mon, 03 Aug 2009 11:45:50 +0200
changeset 5298 97c54512fe23
parent 5297 e1e2793072ad
child 5299 6b1d1dcf5c85
initial checkin
Depth48Image.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Depth48Image.st	Mon Aug 03 11:45:50 2009 +0200
@@ -0,0 +1,132 @@
+"
+ 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' }"
+
+Image subclass:#Depth48Image
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Graphics-Images'
+!
+
+!Depth48Image 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 48 bit images as possibly provided by png 3x16bit rgb 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.
+
+    [author:]
+        Claus Gittinger
+
+    [see also:]
+        Depth1Image Depth2Image Depth4Image Depth8Image Depth16Image Depth24Image Depth32Image
+        ImageReader
+"
+! !
+
+!Depth48Image class methodsFor:'queries'!
+
+defaultPhotometric
+    "return the default photometric pixel interpretation"
+
+    ^ #rgb
+!
+
+imageDepth
+    "return the depth of images represented by instances of
+     this class - here we return 48"
+
+    ^ 48
+! !
+
+!Depth48Image methodsFor:'accessing-pixels'!
+
+pixelAtX:x y:y
+    "retrieve a pixel at x/y; return a pixelValue.
+     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 }"|
+
+    pixelIndex := (width * 6 * y) + 1 + (x * 6).
+
+    ^ ((bytes wordAt:pixelIndex MSB:true) bitShift:32)
+    + ((bytes wordAt:pixelIndex+2 MSB:true) bitShift:16)
+    + (bytes wordAt:pixelIndex+4 MSB:true).
+!
+
+pixelAtX:x y:y put:aPixelValue
+    "set the pixel at x/y to aPixelValue.
+     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 }"|
+
+    pixelIndex := (width * 6 * y) + 1 + (x * 6).
+    bytes isNil ifTrue:[
+        self createPixelStore
+    ].
+    bytes wordAt:pixelIndex put:((aPixelValue bitShift:-32) bitAnd:16rFFFF) MSB:true.
+    bytes wordAt:pixelIndex+2 put:((aPixelValue bitShift:-16) bitAnd:16rFFFF) MSB:true.
+    bytes wordAt:pixelIndex+4 put:(aPixelValue bitAnd:16rFFFF) MSB:true.
+! !
+
+!Depth48Image methodsFor:'initialization'!
+
+initialize
+    super initialize.
+    samplesPerPixel := 3. 
+    bitsPerSample := #(16 16 16).
+! !
+
+!Depth48Image methodsFor:'queries'!
+
+bitsPerPixel
+    "return the number of bits per pixel"
+
+    ^ 48
+!
+
+bitsPerRow
+    "return the number of bits in one scanline of the image"
+
+    ^ width * 48
+!
+
+bytesPerRow
+    "return the number of bytes in one scanline of the image"
+
+    ^ width * 6.
+! !
+
+!Depth48Image class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/libview/Depth48Image.st,v 1.1 2009-08-03 09:45:50 cg Exp $'
+! !