#REFACTORING by cg
class: Image
changed:
#alphaBitsOf:
#blueBitsOf:
#greenBitsOf:
#greenComponentOf:
#redBitsOf:
#redComponentOf:
--- a/Image.st Fri Aug 25 12:38:12 2017 +0200
+++ b/Image.st Fri Aug 25 12:38:44 2017 +0200
@@ -13675,14 +13675,16 @@
of alpha bits i.e. (1 bitShift:bitsAlpha)-1.
This has to be redefined by subclasses."
- |redBits greenBits blueBits alphaBits|
+ |redBits greenBits blueBits alphaBits alphaMask|
samplesPerPixel >= 4 ifTrue:[
+ alphaMask := (1 bitShift:alphaBits)-1.
+
photometric == #rgba ifTrue:[
"/ alpha in low bits
alphaBits := bitsPerSample at:4.
- ^ pixel bitAnd:(1 bitShift:alphaBits)-1
+ ^ pixel bitAnd:alphaMask
].
photometric == #argb ifTrue:[
"/ alpha in high bits
@@ -13691,8 +13693,8 @@
blueBits := bitsPerSample at:3.
alphaBits := bitsPerSample at:4.
- ^ (pixel bitShift:(redBits + greenBits + blueBits) negated)
- bitAnd:(1 bitShift:alphaBits)-1
+ ^ (pixel rightShift:(redBits + greenBits + blueBits))
+ bitAnd:alphaMask
].
^ 0
].
@@ -13700,7 +13702,7 @@
self subclassResponsibility
"Created: / 08-06-1996 / 09:44:51 / cg"
- "Modified: / 22-08-2017 / 17:47:36 / cg"
+ "Modified: / 25-08-2017 / 12:24:21 / cg"
!
alphaMaskForPixelValue
@@ -13853,7 +13855,7 @@
photometric == #rgba ifTrue:[
"/ alpha in low bits
alphaBits := self numAlphaBits.
- ^ (pixel bitShift:alphaBits negated) bitAnd:blueMask
+ ^ (pixel rightShift:alphaBits) bitAnd:blueMask
].
^ pixel bitAnd:blueMask
].
@@ -13861,7 +13863,7 @@
self subclassResponsibility
"Created: / 08-06-1996 / 09:44:21 / cg"
- "Modified: / 22-08-2017 / 18:12:00 / cg"
+ "Modified: / 25-08-2017 / 12:23:20 / cg"
!
blueComponentOf:pixel
@@ -14112,7 +14114,7 @@
samplesPerPixel >= 3 ifTrue:[
photometric == #rgba ifTrue:[
alphaBits := self numAlphaBits.
- (pixel bitShift:(blueBits + alphaBits) negated) bitAnd:greenMask.
+ (pixel rightShift:(blueBits + alphaBits)) bitAnd:greenMask.
].
^ (pixel bitShift:blueBits negated) bitAnd:greenMask
].
@@ -14120,7 +14122,7 @@
self subclassResponsibility
"Created: / 08-06-1996 / 09:44:37 / cg"
- "Modified: / 22-08-2017 / 18:12:16 / cg"
+ "Modified: / 25-08-2017 / 12:23:29 / cg"
!
greenComponentOf:pixel
@@ -14141,13 +14143,13 @@
s := (1 bitShift:greenBits) - 1.
- ^ 100.0 / s * ((pixel bitShift:blueBits negated) bitAnd:(1 bitShift:greenBits)-1)
+ ^ 100.0 / s * ((pixel rightShift:blueBits) bitAnd:(1 bitShift:greenBits)-1)
].
self subclassResponsibility
- "Created: 8.6.1996 / 08:45:34 / cg"
- "Modified: 10.6.1996 / 14:55:24 / cg"
+ "Created: / 08-06-1996 / 08:45:34 / cg"
+ "Modified: / 25-08-2017 / 12:24:33 / cg"
!
greenMaskForPixelValue
@@ -14424,7 +14426,7 @@
samplesPerPixel >= 3 ifTrue:[
photometric == #rgba ifTrue:[
alphaBits := self numAlphaBits.
- ^ (pixel bitShift:(greenBits+blueBits+alphaBits) negated) bitAnd:redMask.
+ ^ (pixel rightShift:(greenBits+blueBits+alphaBits)) bitAnd:redMask.
].
^ (pixel bitShift:(greenBits+blueBits) negated) bitAnd:redMask.
].
@@ -14432,7 +14434,7 @@
self subclassResponsibility
"Created: / 08-06-1996 / 09:44:51 / cg"
- "Modified: / 22-08-2017 / 18:12:51 / cg"
+ "Modified: / 25-08-2017 / 12:24:40 / cg"
!
redComponentOf:pixel
@@ -14457,14 +14459,14 @@
s := (1 bitShift:redBits) - 1.
^ 100.0 / s *
- ((pixel bitShift:(greenBits + blueBits) negated)
+ ((pixel rightShift:(greenBits + blueBits))
bitAnd:(1 bitShift:redBits)-1)
].
self subclassResponsibility
- "Created: 8.6.1996 / 08:45:30 / cg"
- "Modified: 14.6.1996 / 17:34:00 / cg"
+ "Created: / 08-06-1996 / 08:45:30 / cg"
+ "Modified: / 25-08-2017 / 12:24:46 / cg"
!
redMaskForPixelValue