|
Class: Colormap
Object
|
+--Collection
|
+--SequenceableCollection
|
+--Colormap
|
+--ColorPalette
- Package:
- stx:libview
- Category:
- Graphics-Images-Support
- Version:
- rev:
1.49
date: 2019/05/27 13:09:43
- user: cg
- file: Colormap.st directory: libview
- module: stx stc-classLibrary: libview
- Author:
- Claus Gittinger
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.
Notice: Colormap is going to be obsoleted, and the functionality will
move to subclasses (MappedPalette etc.)
Color
Image
Form
instance creation
-
fromColors: aColorArray
-
given a sequenceable collection of colors, return a new instance of myself.
Obsolete: use #withColors: for VW compatibility.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
new: numColors
-
^ self withColors:(Array new:numColors withAll:Color black)
usage example(s):
-
redVector: rV greenVector: gV blueVector: bV
-
given vectors of red/green/and blue pixelValues,
return a new instance of myself.
The values must be in the range 0..255.
usage example(s):
MappedPalette
redVector:#[0 127 255]
greenVector:#[0 127 255]
blueVector:#[0 127 255]
|
-
rgbBytesVector: rgbVector
-
given a single vector containing r-g-b byte values,
return a new instance of myself.
The values must be in the range 0..255.
-
rgbValueVector: rgbValueVector
-
given a single vector containing r-g-b pixel-values,
return a new instance of myself.
The values must be of the rgb-form i.e. 16rRRGGBB
-
withColors: aColorArray
-
given a sequenceable collection of colors, return a new instance
of myself. Renamed from #fromColors: for ST-80 compatibility.
usage example(s):
MappedPalette
withColors:(Array with:Color black
with:Color red
with:Color white)
|
accessing
-
at: index
-
return the color for a index.
Notice that the index range is 1...nColors
-
at: index put: aColor
-
set the color for a index. Return aColor (sigh).
Notice that the index range is 1...
-
at: index putRGB: rgbValue
-
set the color for an index, given rrggbb as an integer (8bits each, red in high bits).
Notice that the index range is 1...
-
at: index putRGBTriple: aTriple
-
set the color for an index from an rgb triple.
The components are r,g,b; each 0..1.
Notice that the index range is 1...
-
atPixelValue: pixelValue
-
return the color for a pixelValue.
Notice that pixelValue range is 0...nColors-1
-
blueAt: index
-
return the blue component for some index.
The returned value is scaled from the internal 0.. 255 to
a percentage value 0..100.
Notice that index range is 1...
-
colors
-
ST-80 compatibility: return a collection containing the colors I hold
-
colors: aCollectionOfColors
-
setup the receiver from colors given in a sequenceable collection of colors
-
greenAt: index
-
return the green component for some index.
The returned value is scaled from the internal 0.. 255 to
a percentage value 0..100.
Notice that index range is 1...
-
redAt: index
-
return the red component for some index.
The returned value is scaled from the internal 0.. 255 to
a percentage value 0..100.
Notice that index range is 1...
accessing-internals
-
blueByteAt: index
-
return the blueByte component for some index.
The returned value is from the internal 0.. 255
-
blueByteAt: index put: anInteger
-
change the internal blueByte component for some index.
The argument, anInteger should be from the internal 0.. 255.
Notice that index range is 1...
-
blueVector
-
return the blueVector
-
blueVector: something
-
set blueVector
-
greenByteAt: index
-
return the greenByte component for some index.
The returned value is from the internal 0.. 255
-
greenByteAt: index put: anInteger
-
change the internal greenByte component for some index.
The argument, anInteger should be from the internal 0.. 255.
Notice that index range is 1...
-
greenVector
-
return greenVector
-
greenVector: something
-
set greenVector
-
redByteAt: index
-
return the redByte component for some index.
The returned value is from the internal 0.. 255
-
redByteAt: index put: anInteger
-
change the internal redByte component for some index.
The argument, anInteger should be from the internal 0.. 255.
Notice that index range is 1...
-
redVector
-
return redVector
-
redVector: something
-
set redVector
-
redVector: r greenVector: g blueVector: b
-
set the red, green and blueVectors
converting
-
asArray
-
return the receiver as an array containing my colors
copying
-
copyFrom: start to: stop
-
copying-private
-
postCopy
-
must be called if redefined
misc
-
grow: howBig
-
change the receiver's size
-
scaleValuesBy: scaleFactor
-
multiply all values by scaleFactor; finally round to integer.
This can be used to brighten/darken an images colormap
printing & storing
-
storeOn: aStream
-
append a representation to aStream, from which the receiver
can be reconstructed
queries
-
colorNearestTo: aColor
-
a very questionable algorithm;
basing the distance on rgb values is very bad - better
do a distance in a cie color cone
-
indexOfColor: aColor
-
-
indexOfPaintNearest: color
-
-
isFixedPalette
-
-
isGreyscaleColormap
-
return true, if the receiver is actually a greymap.
Could be used to convert images as read from imageFiles
(for example, GIF-files) automatically to greyScale (which is not yet done).
-
size
-
return the number of colors in the receiver
testing
-
isColormap
-
-
isMappedPalette
-
|