--- a/Colormap.st Tue Apr 23 22:12:21 1996 +0200
+++ b/Colormap.st Tue Apr 23 22:16:07 1996 +0200
@@ -37,14 +37,23 @@
"
Colormaps are used with images (and Forms) to keep the byte-to-color
mapping.
+ Externally, either colors or pixel values can be accessed.
Internally, the values are stored as 3 separate byte-arrays
(i.e. individual components can be 0..255).
+ This was done to avoid overhead due to allocation of many color
+ instances.
+
+ [see also:]
+ Color
"
! !
!Colormap class methodsFor:'instance creation'!
fromColors:aColorArray
+ "given a collection of real colors, return a new instance
+ of myself"
+
|n rV gV bV|
n := aColorArray size.
@@ -52,32 +61,40 @@
gV := ByteArray new:n.
bV := ByteArray new:n.
1 to:n do:[:i |
- |clr|
+ |clr|
- clr := aColorArray at:i.
- rV at:i put:(clr red * 255 / 100) rounded.
- bV at:i put:(clr green * 255 / 100) rounded.
- gV at:i put:(clr blue * 255 / 100) rounded.
+ clr := aColorArray at:i.
+ rV at:i put:(clr red * 255 / 100) rounded.
+ bV at:i put:(clr green * 255 / 100) rounded.
+ gV at:i put:(clr blue * 255 / 100) rounded.
].
^ self new redVector:rV greenVector:gV blueVector:bV
"
Colormap
- fromColors:(Array with:Color black
- with:Color red
- with:Color white)
+ fromColors:(Array with:Color black
+ with:Color red
+ with:Color white)
"
+
+ "Modified: 23.4.1996 / 22:15:22 / cg"
!
redVector:r greenVector:g blueVector:b
+ "given vectors of red/green/and blue pixelValues,
+ return a new instance of myself.
+ The values must be in the range 0..255."
+
^ self new redVector:r greenVector:g blueVector:b
"
Colormap
- redVector:#[0 127 255]
- greenVector:#[0 127 255]
- blueVector:#[0 127 255]
+ redVector:#[0 127 255]
+ greenVector:#[0 127 255]
+ blueVector:#[0 127 255]
"
+
+ "Modified: 23.4.1996 / 22:16:00 / cg"
! !
!Colormap methodsFor:'accessing'!
@@ -186,13 +203,21 @@
!
redVector:r greenVector:g blueVector:b
+ "set the red, green and blueVectors"
+
redVector := r.
greenVector := g.
blueVector := b.
+
+ "Modified: 23.4.1996 / 22:13:31 / cg"
!
size
+ "return the number of colors in the receiver"
+
^ redVector size
+
+ "Modified: 23.4.1996 / 22:13:43 / cg"
! !
!Colormap methodsFor:'misc'!
@@ -211,5 +236,5 @@
!Colormap class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Colormap.st,v 1.6 1996-04-19 10:45:59 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Colormap.st,v 1.7 1996-04-23 20:16:07 cg Exp $'
! !