--- a/Image.st Tue Dec 02 11:55:43 2008 +0100
+++ b/Image.st Tue Dec 02 21:22:36 2008 +0100
@@ -506,7 +506,43 @@
inspect
[exEnd]
+ [exBegin]
+ ((Depth8Image
+ width:4
+ height:4
+ fromArray:#[
+ 16r30 16r0C 16r03 16r3F
+ 16r20 16r08 16r02 16r2A
+ 16r10 16r04 16r01 16r15
+ 16r00 16r00 16r00 16r00
+ ])
+ photometric:#rgb;
+ samplesPerPixel:3;
+ bitsPerSample:#(2 2 2);
+ magnifiedBy:30)
+ inspect
+ [exEnd]
+
trueColor image:
+ remember: bytes are MSB
+ [exBegin]
+ ((Depth16Image
+ width:4
+ height:5
+ fromArray:#[
+ 2r01111100 2r00000000 2r00000011 2r11100000 2r00000000 2r00011111 2r01111111 2r11111111
+ 2r00111100 2r00000000 2r00000001 2r11100000 2r00000000 2r00001111 2r00111101 2r11101111
+ 2r00011100 2r00000000 2r00000000 2r11100000 2r00000000 2r00000111 2r00011100 2r11100111
+ 2r00001100 2r00000000 2r00000000 2r01100000 2r00000000 2r00000001 2r00001100 2r01100011
+ 2r00000100 2r00000000 2r00000000 2r00100000 2r00000000 2r00000001 2r00000100 2r00100001
+ ])
+ photometric:#rgb;
+ samplesPerPixel:3;
+ bitsPerSample:#(5 5 5);
+ magnifiedBy:30)
+ inspect
+ [exEnd]
+
[exBegin]
((Depth24Image
width:4
@@ -1758,11 +1794,19 @@
bitsPerRow := width * bitsPerPixel.
paddedUnitsPerRow := bitsPerRow // padding.
((bitsPerRow \\ padding) ~~ 0) ifTrue:[
- paddedUnitsPerRow := paddedUnitsPerRow + 1
+ paddedUnitsPerRow := paddedUnitsPerRow + 1
].
^ paddedUnitsPerRow * (padding // 8)
-
+ "
+ self bytesPerRowForWidth:7 depth:1 padding:8
+ self bytesPerRowForWidth:7 depth:1 padding:16
+ self bytesPerRowForWidth:7 depth:1 padding:32
+
+ self bytesPerRowForWidth:15 depth:1 padding:8
+ self bytesPerRowForWidth:15 depth:1 padding:16
+ self bytesPerRowForWidth:15 depth:1 padding:32
+ "
!
defaultPhotometric
@@ -5998,8 +6042,10 @@
"/ be done in concrete subclasses (see D24Image)
"/
self bitsPerPixel == usedDeviceBitsPerPixel ifFalse:[
- 'Image [warning]: unimplemented trueColor depth in rgbImageAsTrueColorFormOn: ' errorPrint. self bitsPerPixel errorPrintCR.
- ^ self asMonochromeFormOn:aDevice
+ "/ kludge - convert to a deep image first, then to a form.
+ ^ ((Image implementorForDepth:usedDeviceBitsPerPixel) fromImage:self) asFormOn:aDevice
+"/ 'Image [warning]: unimplemented trueColor depth in rgbImageAsTrueColorFormOn: ' errorPrint. self bitsPerPixel errorPrintCR.
+"/ ^ self asMonochromeFormOn:aDevice
].
form := Form width:width height:height depth:usedDeviceDepth onDevice:aDevice.
@@ -12226,7 +12272,8 @@
The implementation below is generic and slow
- this method is typically redefined in subclasses."
- |p maxPixel clr r g b c m y k a|
+ |p maxPixel clr r g b c m y k a
+ numRedBits numGreenBits numBlueBits numAlphaBits|
p := photometric.
p isNil ifTrue:[
@@ -12263,11 +12310,13 @@
r := self redBitsOf:pixelValue.
g := self greenBitsOf:pixelValue.
b := self blueBitsOf:pixelValue.
- "/ must scale to byte value...
- r := r bitShift:(8 - (bitsPerSample at:1)).
- g := g bitShift:(8 - (bitsPerSample at:2)).
- b := b bitShift:(8 - (bitsPerSample at:3)).
- ^ Color redByte:r greenByte:g blueByte:b
+ "/ must scale...
+ numRedBits := bitsPerSample at:1.
+ numGreenBits := bitsPerSample at:2.
+ numBlueBits := bitsPerSample at:3.
+ ^ Color redPercent:(100 / ((1 bitShift:numRedBits)-1) * r)
+ greenPercent:(100 / ((1 bitShift:numGreenBits)-1) * g)
+ bluePercent:(100 / ((1 bitShift:numBlueBits)-1) * b)
].
p == #rgba ifTrue:[
@@ -12275,12 +12324,16 @@
g := self greenBitsOf:pixelValue.
b := self blueBitsOf:pixelValue.
a := self alphaBitsOf:pixelValue.
- "/ must scale to byte value...
- r := r bitShift:(8 - (bitsPerSample at:1)).
- g := g bitShift:(8 - (bitsPerSample at:2)).
- b := b bitShift:(8 - (bitsPerSample at:3)).
- a := a bitShift:(8 - (bitsPerSample at:4)).
- ^ Color redByte:r greenByte:g blueByte:b alphaByte:a
+ "/ must scale...
+ numRedBits := bitsPerSample at:1.
+ numGreenBits := bitsPerSample at:2.
+ numBlueBits := bitsPerSample at:3.
+ numAlphaBits := bitsPerSample at:4.
+ "/ must scale...
+ ^ Color redPercent:(100 / ((1 bitShift:numRedBits)-1) * r)
+ greenPercent:(100 / ((1 bitShift:numGreenBits)-1) * g)
+ bluePercent:(100 / ((1 bitShift:numBlueBits)-1) * b)
+ alphaPercent:(100 / ((1 bitShift:numAlphaBits)-1) * a)
].
p == #cmyk ifTrue:[
@@ -12574,19 +12627,19 @@
redBitsOf:pixel
"if the receiver is an rgb-image:
return the red component of a pixelValue as integer 0..maxRedValue.
- MaxRedValue is of course the largest integer representable by the number
+ MaxRedValue is the largest integer representable by the number
of red bits i.e. (1 bitShift:bitsRed)-1.
This has to be redefined by subclasses."
|redBits greenBits blueBits|
samplesPerPixel >= 3 ifTrue:[
- redBits := bitsPerSample at:1.
- greenBits := bitsPerSample at:2.
- blueBits := bitsPerSample at:3.
-
- ^ (pixel bitShift:(greenBits + blueBits) negated)
- bitAnd:(1 bitShift:redBits)-1
+ redBits := bitsPerSample at:1.
+ greenBits := bitsPerSample at:2.
+ blueBits := bitsPerSample at:3.
+
+ ^ (pixel bitShift:(greenBits + blueBits) negated)
+ bitAnd:(1 bitShift:redBits)-1
].
self subclassResponsibility
@@ -13745,7 +13798,7 @@
!Image class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.414 2008-11-03 11:21:01 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.415 2008-12-02 20:22:36 cg Exp $'
! !
Image initialize!