7200
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2016 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
7188
|
12 |
"{ Package: 'stx:libview' }"
|
|
13 |
|
|
14 |
"{ NameSpace: Smalltalk }"
|
|
15 |
|
|
16 |
FixedPalette subclass:#FixedPaletteWithAlpha
|
|
17 |
instanceVariableNames:'alphaShift alphaMask'
|
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Graphics-Images-Support'
|
|
21 |
!
|
|
22 |
|
7200
|
23 |
!FixedPaletteWithAlpha class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 2016 by Claus Gittinger
|
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
"
|
|
37 |
! !
|
7188
|
38 |
|
7199
|
39 |
!FixedPaletteWithAlpha methodsFor:'accessing'!
|
|
40 |
|
|
41 |
alphaShift:alphaShiftArg alphaMask:alphaMaskArg
|
|
42 |
alphaShift := alphaShiftArg.
|
|
43 |
alphaMask := alphaMaskArg.
|
|
44 |
! !
|
|
45 |
|
7188
|
46 |
!FixedPaletteWithAlpha methodsFor:'printing & storing'!
|
|
47 |
|
7200
|
48 |
size
|
|
49 |
"return the number of (simulated) colors in this colormap"
|
|
50 |
|
|
51 |
^ ((alphaMask bitShift:alphaShift)
|
|
52 |
+ (redMask bitShift:redShift)
|
|
53 |
+ (greenMask bitShift:greenShift)
|
|
54 |
+ (blueMask bitShift:blueShift)) + 1
|
|
55 |
!
|
|
56 |
|
7188
|
57 |
storeInstVarsOn:aStream
|
|
58 |
super storeInstVarsOn:aStream.
|
|
59 |
aStream nextPutAll:' alphaShift:'. alphaShift storeOn:aStream.
|
|
60 |
aStream nextPutAll:' alphaMask:'. alphaMask storeOn:aStream.
|
|
61 |
! !
|
|
62 |
|
|
63 |
!FixedPaletteWithAlpha methodsFor:'queries'!
|
|
64 |
|
|
65 |
alphaByteAt:index
|
|
66 |
"return the (simulated) alphaByte at index.
|
|
67 |
Notice that index is 1.."
|
|
68 |
|
|
69 |
|a aa|
|
|
70 |
|
|
71 |
alphaMask == 0 ifTrue:[^ 0]. "/ no alpha component
|
|
72 |
|
8104
|
73 |
a := ((index-1 rightShift:alphaShift) bitAnd:alphaMask).
|
7188
|
74 |
aa := (a * 255.0 / (alphaMask)) rounded.
|
|
75 |
^ aa
|
|
76 |
|
|
77 |
"
|
|
78 |
(FixedPalette redShift:16 redMask:16rFF greenShift:8 greenMask:16rFF blueShift:0 blueMask:16rFF) blueByteAt:16rFFFFFF+1
|
|
79 |
(FixedPalette redShift:10 redMask:16r1F greenShift:5 greenMask:16r1F blueShift:0 blueMask:16r1F) blueByteAt:16r7FFF+1
|
|
80 |
(FixedPalette redShift:11 redMask:16r1F greenShift:5 greenMask:16r3F blueShift:0 blueMask:16r1F) blueByteAt:16rFFFF+1
|
|
81 |
|
|
82 |
(FixedPalette redShift:11 redMask:16r1F greenShift:5 greenMask:16r3F blueShift:0 blueMask:16r1F) blueByteAt:0+1
|
|
83 |
(FixedPalette redShift:11 redMask:16r1F greenShift:5 greenMask:16r3F blueShift:0 blueMask:16r1F) blueByteAt:16r7FFF+1
|
|
84 |
"
|
8104
|
85 |
|
|
86 |
"Modified: / 25-08-2017 / 12:22:59 / cg"
|
7188
|
87 |
!
|
|
88 |
|
|
89 |
bitsAlpha
|
|
90 |
^ alphaMask highBit
|
|
91 |
! !
|
|
92 |
|
|
93 |
!FixedPaletteWithAlpha class methodsFor:'documentation'!
|
|
94 |
|
|
95 |
version
|
|
96 |
^ '$Header$'
|
|
97 |
!
|
|
98 |
|
|
99 |
version_CVS
|
|
100 |
^ '$Header$'
|
|
101 |
! !
|
|
102 |
|