13673 return the alpha component of a pixelValue as integer 0..maxAlphaValue. |
13673 return the alpha component of a pixelValue as integer 0..maxAlphaValue. |
13674 MaxAlphaValue is of course the largest integer representable by the number |
13674 MaxAlphaValue is of course the largest integer representable by the number |
13675 of alpha bits i.e. (1 bitShift:bitsAlpha)-1. |
13675 of alpha bits i.e. (1 bitShift:bitsAlpha)-1. |
13676 This has to be redefined by subclasses." |
13676 This has to be redefined by subclasses." |
13677 |
13677 |
13678 |redBits greenBits blueBits alphaBits| |
13678 |redBits greenBits blueBits alphaBits alphaMask| |
13679 |
13679 |
13680 samplesPerPixel >= 4 ifTrue:[ |
13680 samplesPerPixel >= 4 ifTrue:[ |
|
13681 alphaMask := (1 bitShift:alphaBits)-1. |
|
13682 |
13681 photometric == #rgba ifTrue:[ |
13683 photometric == #rgba ifTrue:[ |
13682 "/ alpha in low bits |
13684 "/ alpha in low bits |
13683 alphaBits := bitsPerSample at:4. |
13685 alphaBits := bitsPerSample at:4. |
13684 |
13686 |
13685 ^ pixel bitAnd:(1 bitShift:alphaBits)-1 |
13687 ^ pixel bitAnd:alphaMask |
13686 ]. |
13688 ]. |
13687 photometric == #argb ifTrue:[ |
13689 photometric == #argb ifTrue:[ |
13688 "/ alpha in high bits |
13690 "/ alpha in high bits |
13689 redBits := bitsPerSample at:1. |
13691 redBits := bitsPerSample at:1. |
13690 greenBits := bitsPerSample at:2. |
13692 greenBits := bitsPerSample at:2. |
13691 blueBits := bitsPerSample at:3. |
13693 blueBits := bitsPerSample at:3. |
13692 alphaBits := bitsPerSample at:4. |
13694 alphaBits := bitsPerSample at:4. |
13693 |
13695 |
13694 ^ (pixel bitShift:(redBits + greenBits + blueBits) negated) |
13696 ^ (pixel rightShift:(redBits + greenBits + blueBits)) |
13695 bitAnd:(1 bitShift:alphaBits)-1 |
13697 bitAnd:alphaMask |
13696 ]. |
13698 ]. |
13697 ^ 0 |
13699 ^ 0 |
13698 ]. |
13700 ]. |
13699 |
13701 |
13700 self subclassResponsibility |
13702 self subclassResponsibility |
13701 |
13703 |
13702 "Created: / 08-06-1996 / 09:44:51 / cg" |
13704 "Created: / 08-06-1996 / 09:44:51 / cg" |
13703 "Modified: / 22-08-2017 / 17:47:36 / cg" |
13705 "Modified: / 25-08-2017 / 12:24:21 / cg" |
13704 ! |
13706 ! |
13705 |
13707 |
13706 alphaMaskForPixelValue |
13708 alphaMaskForPixelValue |
13707 "return the mask used with translation from pixelValues to alphaBits" |
13709 "return the mask used with translation from pixelValues to alphaBits" |
13708 |
13710 |
13851 |
13853 |
13852 samplesPerPixel >= 3 ifTrue:[ |
13854 samplesPerPixel >= 3 ifTrue:[ |
13853 photometric == #rgba ifTrue:[ |
13855 photometric == #rgba ifTrue:[ |
13854 "/ alpha in low bits |
13856 "/ alpha in low bits |
13855 alphaBits := self numAlphaBits. |
13857 alphaBits := self numAlphaBits. |
13856 ^ (pixel bitShift:alphaBits negated) bitAnd:blueMask |
13858 ^ (pixel rightShift:alphaBits) bitAnd:blueMask |
13857 ]. |
13859 ]. |
13858 ^ pixel bitAnd:blueMask |
13860 ^ pixel bitAnd:blueMask |
13859 ]. |
13861 ]. |
13860 |
13862 |
13861 self subclassResponsibility |
13863 self subclassResponsibility |
13862 |
13864 |
13863 "Created: / 08-06-1996 / 09:44:21 / cg" |
13865 "Created: / 08-06-1996 / 09:44:21 / cg" |
13864 "Modified: / 22-08-2017 / 18:12:00 / cg" |
13866 "Modified: / 25-08-2017 / 12:23:20 / cg" |
13865 ! |
13867 ! |
13866 |
13868 |
13867 blueComponentOf:pixel |
13869 blueComponentOf:pixel |
13868 "if the receiver is an rgb-image: |
13870 "if the receiver is an rgb-image: |
13869 return the blue component scaled to a percentage (0 .. 100) of a pixelValue. |
13871 return the blue component scaled to a percentage (0 .. 100) of a pixelValue. |
14110 greenMask := (1 bitShift:greenBits)-1. |
14112 greenMask := (1 bitShift:greenBits)-1. |
14111 |
14113 |
14112 samplesPerPixel >= 3 ifTrue:[ |
14114 samplesPerPixel >= 3 ifTrue:[ |
14113 photometric == #rgba ifTrue:[ |
14115 photometric == #rgba ifTrue:[ |
14114 alphaBits := self numAlphaBits. |
14116 alphaBits := self numAlphaBits. |
14115 (pixel bitShift:(blueBits + alphaBits) negated) bitAnd:greenMask. |
14117 (pixel rightShift:(blueBits + alphaBits)) bitAnd:greenMask. |
14116 ]. |
14118 ]. |
14117 ^ (pixel bitShift:blueBits negated) bitAnd:greenMask |
14119 ^ (pixel bitShift:blueBits negated) bitAnd:greenMask |
14118 ]. |
14120 ]. |
14119 |
14121 |
14120 self subclassResponsibility |
14122 self subclassResponsibility |
14121 |
14123 |
14122 "Created: / 08-06-1996 / 09:44:37 / cg" |
14124 "Created: / 08-06-1996 / 09:44:37 / cg" |
14123 "Modified: / 22-08-2017 / 18:12:16 / cg" |
14125 "Modified: / 25-08-2017 / 12:23:29 / cg" |
14124 ! |
14126 ! |
14125 |
14127 |
14126 greenComponentOf:pixel |
14128 greenComponentOf:pixel |
14127 "if the receiver is an rgb-image: |
14129 "if the receiver is an rgb-image: |
14128 return the green component scaled to a percentage (0..100) of a pixelValue. |
14130 return the green component scaled to a percentage (0..100) of a pixelValue. |
14139 greenBits == 0 ifTrue:[^ 0]. |
14141 greenBits == 0 ifTrue:[^ 0]. |
14140 blueBits := bitsPerSample at:3. |
14142 blueBits := bitsPerSample at:3. |
14141 |
14143 |
14142 s := (1 bitShift:greenBits) - 1. |
14144 s := (1 bitShift:greenBits) - 1. |
14143 |
14145 |
14144 ^ 100.0 / s * ((pixel bitShift:blueBits negated) bitAnd:(1 bitShift:greenBits)-1) |
14146 ^ 100.0 / s * ((pixel rightShift:blueBits) bitAnd:(1 bitShift:greenBits)-1) |
14145 ]. |
14147 ]. |
14146 |
14148 |
14147 self subclassResponsibility |
14149 self subclassResponsibility |
14148 |
14150 |
14149 "Created: 8.6.1996 / 08:45:34 / cg" |
14151 "Created: / 08-06-1996 / 08:45:34 / cg" |
14150 "Modified: 10.6.1996 / 14:55:24 / cg" |
14152 "Modified: / 25-08-2017 / 12:24:33 / cg" |
14151 ! |
14153 ! |
14152 |
14154 |
14153 greenMaskForPixelValue |
14155 greenMaskForPixelValue |
14154 "return the mask used with translation from pixelValues to greenBits" |
14156 "return the mask used with translation from pixelValues to greenBits" |
14155 |
14157 |
14422 redMask := (1 bitShift:redBits)-1. |
14424 redMask := (1 bitShift:redBits)-1. |
14423 |
14425 |
14424 samplesPerPixel >= 3 ifTrue:[ |
14426 samplesPerPixel >= 3 ifTrue:[ |
14425 photometric == #rgba ifTrue:[ |
14427 photometric == #rgba ifTrue:[ |
14426 alphaBits := self numAlphaBits. |
14428 alphaBits := self numAlphaBits. |
14427 ^ (pixel bitShift:(greenBits+blueBits+alphaBits) negated) bitAnd:redMask. |
14429 ^ (pixel rightShift:(greenBits+blueBits+alphaBits)) bitAnd:redMask. |
14428 ]. |
14430 ]. |
14429 ^ (pixel bitShift:(greenBits+blueBits) negated) bitAnd:redMask. |
14431 ^ (pixel bitShift:(greenBits+blueBits) negated) bitAnd:redMask. |
14430 ]. |
14432 ]. |
14431 |
14433 |
14432 self subclassResponsibility |
14434 self subclassResponsibility |
14433 |
14435 |
14434 "Created: / 08-06-1996 / 09:44:51 / cg" |
14436 "Created: / 08-06-1996 / 09:44:51 / cg" |
14435 "Modified: / 22-08-2017 / 18:12:51 / cg" |
14437 "Modified: / 25-08-2017 / 12:24:40 / cg" |
14436 ! |
14438 ! |
14437 |
14439 |
14438 redComponentOf:pixel |
14440 redComponentOf:pixel |
14439 "if the receiver is an rgb-image: |
14441 "if the receiver is an rgb-image: |
14440 return the red component scaled to a percentage (0..100) of a pixelValue. |
14442 return the red component scaled to a percentage (0..100) of a pixelValue. |
14455 blueBits := bitsPerSample at:3. |
14457 blueBits := bitsPerSample at:3. |
14456 |
14458 |
14457 s := (1 bitShift:redBits) - 1. |
14459 s := (1 bitShift:redBits) - 1. |
14458 |
14460 |
14459 ^ 100.0 / s * |
14461 ^ 100.0 / s * |
14460 ((pixel bitShift:(greenBits + blueBits) negated) |
14462 ((pixel rightShift:(greenBits + blueBits)) |
14461 bitAnd:(1 bitShift:redBits)-1) |
14463 bitAnd:(1 bitShift:redBits)-1) |
14462 ]. |
14464 ]. |
14463 |
14465 |
14464 self subclassResponsibility |
14466 self subclassResponsibility |
14465 |
14467 |
14466 "Created: 8.6.1996 / 08:45:30 / cg" |
14468 "Created: / 08-06-1996 / 08:45:30 / cg" |
14467 "Modified: 14.6.1996 / 17:34:00 / cg" |
14469 "Modified: / 25-08-2017 / 12:24:46 / cg" |
14468 ! |
14470 ! |
14469 |
14471 |
14470 redMaskForPixelValue |
14472 redMaskForPixelValue |
14471 "return the mask used with translation from pixelValues to redBits" |
14473 "return the mask used with translation from pixelValues to redBits" |
14472 |
14474 |