7188
|
1 |
"{ Package: 'stx:libview' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Smalltalk }"
|
|
4 |
|
|
5 |
FixedPalette subclass:#FixedPaletteWithAlpha
|
|
6 |
instanceVariableNames:'alphaShift alphaMask'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Graphics-Images-Support'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
7199
|
13 |
!FixedPaletteWithAlpha methodsFor:'accessing'!
|
|
14 |
|
|
15 |
alphaShift:alphaShiftArg alphaMask:alphaMaskArg
|
|
16 |
alphaShift := alphaShiftArg.
|
|
17 |
alphaMask := alphaMaskArg.
|
|
18 |
! !
|
|
19 |
|
7188
|
20 |
!FixedPaletteWithAlpha methodsFor:'printing & storing'!
|
|
21 |
|
|
22 |
storeInstVarsOn:aStream
|
|
23 |
super storeInstVarsOn:aStream.
|
|
24 |
aStream nextPutAll:' alphaShift:'. alphaShift storeOn:aStream.
|
|
25 |
aStream nextPutAll:' alphaMask:'. alphaMask storeOn:aStream.
|
|
26 |
! !
|
|
27 |
|
|
28 |
!FixedPaletteWithAlpha methodsFor:'queries'!
|
|
29 |
|
|
30 |
alphaByteAt:index
|
|
31 |
"return the (simulated) alphaByte at index.
|
|
32 |
Notice that index is 1.."
|
|
33 |
|
|
34 |
|a aa|
|
|
35 |
|
|
36 |
alphaMask == 0 ifTrue:[^ 0]. "/ no alpha component
|
|
37 |
|
|
38 |
a := ((index-1 bitShift:alphaShift negated) bitAnd:alphaMask).
|
|
39 |
aa := (a * 255.0 / (alphaMask)) rounded.
|
|
40 |
^ aa
|
|
41 |
|
|
42 |
"
|
|
43 |
(FixedPalette redShift:16 redMask:16rFF greenShift:8 greenMask:16rFF blueShift:0 blueMask:16rFF) blueByteAt:16rFFFFFF+1
|
|
44 |
(FixedPalette redShift:10 redMask:16r1F greenShift:5 greenMask:16r1F blueShift:0 blueMask:16r1F) blueByteAt:16r7FFF+1
|
|
45 |
(FixedPalette redShift:11 redMask:16r1F greenShift:5 greenMask:16r3F blueShift:0 blueMask:16r1F) blueByteAt:16rFFFF+1
|
|
46 |
|
|
47 |
(FixedPalette redShift:11 redMask:16r1F greenShift:5 greenMask:16r3F blueShift:0 blueMask:16r1F) blueByteAt:0+1
|
|
48 |
(FixedPalette redShift:11 redMask:16r1F greenShift:5 greenMask:16r3F blueShift:0 blueMask:16r1F) blueByteAt:16r7FFF+1
|
|
49 |
"
|
|
50 |
!
|
|
51 |
|
|
52 |
bitsAlpha
|
|
53 |
^ alphaMask highBit
|
|
54 |
! !
|
|
55 |
|
|
56 |
!FixedPaletteWithAlpha class methodsFor:'documentation'!
|
|
57 |
|
|
58 |
version
|
|
59 |
^ '$Header$'
|
|
60 |
!
|
|
61 |
|
|
62 |
version_CVS
|
|
63 |
^ '$Header$'
|
|
64 |
! !
|
|
65 |
|