--- a/Depth24Image.st Thu Sep 13 11:01:07 2001 +0200
+++ b/Depth24Image.st Thu Sep 13 17:16:22 2001 +0200
@@ -1482,7 +1482,8 @@
^ form
- "Modified: 21.10.1995 / 19:30:11 / cg"! !
+ "Modified: 21.10.1995 / 19:30:11 / cg"
+! !
!Depth24Image methodsFor:'dither helpers'!
@@ -2424,6 +2425,18 @@
"Modified: 8.6.1996 / 09:57:41 / cg"
!
+blueMaskForPixelValue
+ "return the mask used with translation from pixelValues to blueBits"
+
+ ^ 16rFF
+!
+
+blueShiftForPixelValue
+ "return the shift amount used with translation from pixelValues to blueBits"
+
+ ^ 0
+!
+
bytesPerRow
"return the number of bytes in one scanline of the image"
@@ -2448,6 +2461,18 @@
"Modified: 8.6.1996 / 09:57:32 / cg"
!
+greenMaskForPixelValue
+ "return the mask used with translation from pixelValues to redBits"
+
+ ^ 16rFF
+!
+
+greenShiftForPixelValue
+ "return the shift amount used with translation from pixelValues to greenBits"
+
+ ^ -8
+!
+
redBitsOf:pixel
"given a pixel-value, return the red component as byteValue (0..255)"
@@ -2466,6 +2491,18 @@
"Modified: 8.6.1996 / 09:57:23 / cg"
!
+redMaskForPixelValue
+ "return the mask used with translation from pixelValues to redBits"
+
+ ^ 16rFF
+!
+
+redShiftForPixelValue
+ "return the shift amount used with translation from pixelValues to redBits"
+
+ ^ -16
+!
+
samplesPerPixel
"return the number of samples per pixel in the image."
@@ -2473,10 +2510,14 @@
^ 3
"Modified: 10.6.1996 / 18:03:09 / cg"
+!
+
+valueFromRedBits:redBits greenBits:greenBits blueBits:blueBits
+ ^ (((redBits bitShift:8) bitOr:greenBits) bitShift:8) bitOr:blueBits
! !
!Depth24Image class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.73 2000-11-01 13:26:16 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Depth24Image.st,v 1.74 2001-09-13 15:16:04 cg Exp $'
! !
--- a/Image.st Thu Sep 13 11:01:07 2001 +0200
+++ b/Image.st Thu Sep 13 17:16:22 2001 +0200
@@ -10989,6 +10989,60 @@
!Image methodsFor:'queries'!
+alphaBitsOf:pixel
+ "if the receiver is an rgb-image:
+ return the alpha component of a pixelValue as integer 0..maxAlphaValue.
+ MaxAlphaValue is of course the largest integer representable by the number
+ of alpha bits i.e. (1 bitShift:bitsAlpha)-1.
+ This has to be redefined by subclasses."
+
+ |redBits greenBits blueBits alphaBits|
+
+ samplesPerPixel >= 4 ifTrue:[
+ redBits := bitsPerSample at:1.
+ greenBits := bitsPerSample at:2.
+ blueBits := bitsPerSample at:3.
+ alphaBits := bitsPerSample at:4.
+
+ ^ (pixel bitShift:(redBits + greenBits + blueBits) negated)
+ bitAnd:(1 bitShift:alphaBits)-1
+ ].
+
+ self subclassResponsibility
+
+ "Created: 8.6.1996 / 09:44:51 / cg"
+ "Modified: 10.6.1996 / 14:59:05 / cg"
+!
+
+alphaMaskForPixelValue
+ "return the mask used with translation from pixelValues to alphaBits"
+
+ |alphaBits|
+
+ samplesPerPixel >= 4 ifTrue:[
+ alphaBits := bitsPerSample at:4.
+ ^ (1 bitShift:alphaBits)-1
+ ].
+
+ self subclassResponsibility
+!
+
+alphaShiftForPixelValue
+ "return the shift amount used with translation from pixelValues to alphaBits"
+
+ |redBits greenBits blueBits|
+
+ samplesPerPixel >= 3 ifTrue:[
+ redBits := bitsPerSample at:1.
+ greenBits := bitsPerSample at:2.
+ blueBits := bitsPerSample at:3.
+
+ ^ (greenBits + blueBits + redBits) negated
+ ].
+
+ self subclassResponsibility
+!
+
averageColor
"return the average color of the image.
This usually only makes sense for textures and patterns
@@ -11065,12 +11119,8 @@
|blueBits|
samplesPerPixel >= 3 ifTrue:[
- "/ assume that the red bits are the leftMost bits
-
- blueBits := bitsPerSample at:3.
- blueBits == 0 ifTrue:[^ 0].
-
- ^ pixel bitAnd:(1 bitShift:blueBits)-1
+ blueBits := bitsPerSample at:3.
+ ^ pixel bitAnd:(1 bitShift:blueBits)-1
].
self subclassResponsibility
@@ -11104,6 +11154,29 @@
"Modified: 10.6.1996 / 14:55:39 / cg"
!
+blueMaskForPixelValue
+ "return the mask used with translation from pixelValues to blueBits"
+
+ |blueBits|
+
+ samplesPerPixel >= 3 ifTrue:[
+ blueBits := bitsPerSample at:3.
+ ^ (1 bitShift:blueBits)-1
+ ].
+
+ self subclassResponsibility
+!
+
+blueShiftForPixelValue
+ "return the shift amount used with translation from pixelValues to blueBits"
+
+ samplesPerPixel >= 3 ifTrue:[
+ ^ 0
+ ].
+
+ self subclassResponsibility
+!
+
bounds
"return my bounds (added to make images usable as VisualComponents)"
@@ -11263,13 +11336,10 @@
|blueBits greenBits|
samplesPerPixel >= 3 ifTrue:[
- "/ assume that the red bits are the leftMost bits
-
- greenBits := bitsPerSample at:2.
- greenBits == 0 ifTrue:[^ 0].
- blueBits := bitsPerSample at:3.
-
- ^ (pixel bitShift:blueBits negated) bitAnd:(1 bitShift:greenBits)-1
+ greenBits := bitsPerSample at:2.
+ blueBits := bitsPerSample at:3.
+
+ ^ (pixel bitShift:blueBits negated) bitAnd:(1 bitShift:greenBits)-1
].
self subclassResponsibility
@@ -11305,6 +11375,33 @@
"Modified: 10.6.1996 / 14:55:24 / cg"
!
+greenMaskForPixelValue
+ "return the mask used with translation from pixelValues to greenBits"
+
+ |greenBits|
+
+ samplesPerPixel >= 3 ifTrue:[
+ greenBits := bitsPerSample at:2.
+ ^ (1 bitShift:greenBits)-1
+ ].
+
+ self subclassResponsibility
+!
+
+greenShiftForPixelValue
+ "return the shift amount used with translation from pixelValues to greenBits"
+
+ |greenBits blueBits|
+
+ samplesPerPixel >= 3 ifTrue:[
+ blueBits := bitsPerSample at:3.
+
+ ^ (blueBits) negated
+ ].
+
+ self subclassResponsibility
+!
+
heightOn:aGC
"return my height, if displayed on aGC;
since my height is independent of the device (the number of pixels),
@@ -11459,15 +11556,12 @@
|redBits greenBits blueBits|
samplesPerPixel >= 3 ifTrue:[
- "/ assume that the red bits are the leftMost bits
-
- redBits := bitsPerSample at:1.
- redBits == 0 ifTrue:[^ 0].
- 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
@@ -11508,6 +11602,37 @@
"Modified: 14.6.1996 / 17:34:00 / cg"
!
+redMaskForPixelValue
+ "return the mask used with translation from pixelValues to redBits"
+
+ |redBits|
+
+ samplesPerPixel >= 3 ifTrue:[
+ redBits := bitsPerSample at:1.
+ ^ (1 bitShift:redBits)-1
+ ].
+
+ self subclassResponsibility
+
+ "Created: 8.6.1996 / 09:44:51 / cg"
+ "Modified: 10.6.1996 / 14:59:05 / cg"
+!
+
+redShiftForPixelValue
+ "return the shift amount used with translation from pixelValues to redBits"
+
+ |greenBits blueBits|
+
+ samplesPerPixel >= 3 ifTrue:[
+ greenBits := bitsPerSample at:2.
+ blueBits := bitsPerSample at:3.
+
+ ^ (greenBits + blueBits) negated
+ ].
+
+ self subclassResponsibility
+!
+
usedColors
"return a collection of colors used in the receiver."
@@ -12295,6 +12420,6 @@
!Image class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.310 2001-09-05 15:40:22 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.311 2001-09-13 15:16:22 cg Exp $'
! !
Image initialize!
--- a/ShadowView.st Thu Sep 13 11:01:07 2001 +0200
+++ b/ShadowView.st Thu Sep 13 17:16:22 2001 +0200
@@ -125,14 +125,16 @@
shadowClr := StyleSheet at:#popUpShadowColor.
"the length of the shadow from myView"
- shadowLength := (device pixelPerMillimeter * 1.0) rounded
+ shadowLength := (device pixelPerMillimeter * 1.0) rounded.
+ "/ shadowLength := (device pixelPerMillimeter * 2.0) rounded.
!
realize
"realize the shadowView some distance away from myView,
get the pixels under the shadow from the screen"
- |root shW shH right bot kludge clr1 clr0 org blackIs0 img|
+ |root shW shH right bot kludge clr1 clr0 org blackIs0 img
+ rS gS bS rM gM bM rSN gSN bSN pix r g b|
myView notNil ifTrue:[
@@ -176,30 +178,47 @@
grey out the image (by darkening the pixels)
(thats expensive ...)
"
+
img := Image fromForm:imageUnderShadow.
- 0 to:height-1-shH do:[:y |
- right to:right+shW-1 do:[:x | |pix r g b|
+
+ rS := img redShiftForPixelValue.
+ gS := img greenShiftForPixelValue.
+ bS := img blueShiftForPixelValue.
+ rSN := rS negated.
+ gSN := gS negated.
+ bSN := bS negated.
+ rM := img redMaskForPixelValue.
+ gM := img greenMaskForPixelValue.
+ bM := img blueMaskForPixelValue.
+
+ right to:right+shW-1 do:[:x |
+ 0 to:height-1-shH do:[:y |
pix := img pixelAtX:x y:y.
- r := img redBitsOf:pix.
- g := img greenBitsOf:pix.
- b := img blueBitsOf:pix.
- r := r // 2.
- g := g // 2.
- b := b // 2.
- pix := img valueFromRedBits:r greenBits:g blueBits:b.
+ r := (pix bitShift:rS) bitAnd:rM. "/ img redBitsOf:pix.
+ g := (pix bitShift:gS) bitAnd:gM. "/ img greenBitsOf:pix.
+ b := (pix bitShift:bS) bitAnd:bM. "/ img blueBitsOf:pix.
+ r := (r * 0.7) rounded.
+ g := (g * 0.7) rounded.
+ b := (b * 0.7) rounded.
+ pix := ((r bitShift:rSN) "/ pix := img valueFromRedBits:r greenBits:g blueBits:b.
+ bitOr:(g bitShift:gSN))
+ bitOr:(b bitShift:bSN).
+
img pixelAtX:x y:y put:pix.
].
].
- 0 to:width-1 do:[:x |
- bot to:bot+shH-1 do:[:y | |pix r g b|
+ bot to:bot+shH-1 do:[:y |
+ 0 to:width-1 do:[:x |
pix := img pixelAtX:x y:y.
- r := img redBitsOf:pix.
- g := img greenBitsOf:pix.
- b := img blueBitsOf:pix.
- r := r // 2.
- g := g // 2.
- b := b // 2.
- pix := img valueFromRedBits:r greenBits:g blueBits:b.
+ r := (pix bitShift:rS) bitAnd:rM. "/ img redBitsOf:pix.
+ g := (pix bitShift:gS) bitAnd:gM. "/ img greenBitsOf:pix.
+ b := (pix bitShift:bS) bitAnd:bM. "/ img blueBitsOf:pix.
+ r := (r * 0.7) rounded.
+ g := (g * 0.7) rounded.
+ b := (b * 0.7) rounded.
+ pix := ((r bitShift:rSN) "/ pix := img valueFromRedBits:r greenBits:g blueBits:b.
+ bitOr:(g bitShift:gSN))
+ bitOr:(b bitShift:bSN).
img pixelAtX:x y:y put:pix.
].
].
@@ -268,5 +287,5 @@
!ShadowView class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/ShadowView.st,v 1.32 2000-09-06 13:50:08 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/ShadowView.st,v 1.33 2001-09-13 15:15:32 cg Exp $'
! !