|
Class: Colormap
Object
|
+--Collection
|
+--SequenceableCollection
|
+--Colormap
|
+--ColorPalette
- Package:
- stx:libview
- Category:
- Graphics-Images-Support
- Version:
- rev:
1.55
date: 2022/02/23 08:07:36
- user: cg
- file: Colormap.st directory: libview
- module: stx stc-classLibrary: libview
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.)
copyrightCOPYRIGHT (c) 1994 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
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.
Usage example(s):
|map|
map := MappedPalette rgbBytesVector:#[0 0 0 127 127 127 255 0 0 255 255 255].
map atPixelValue:2
|
-
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
Usage example(s):
|map|
map := MappedPalette rgbValueVector:#(16r000000 16r7F7F7F 16r800000 16rFFFFFF).
map atPixelValue:2
|
-
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
-
(comment from inherited method)
return a new collection consisting of receiver's elements
between start and stop.
Returns an empty collection if startIndex is beyond the receiver's size.
Raise an error, if stopIndex is out of range.
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
-
-
isGrayscaleColormap
-
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).
-
isGreyscaleColormap
-
marked as obsolete by exept MBP at 20-09-2021
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
size
-
return the number of colors in the receiver
testing
-
isColormap
-
-
isMappedPalette
-
|