eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Colormap':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Colormap


Inheritance:

   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

Description:


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.)


Related information:

    Color
    Image
    Form

Class protocol:

instance creation
o  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) **

o  new: numColors
^ self withColors:(Array new:numColors withAll:Color black)

usage example(s):

     MappedPalette new:100

o  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]

o  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.

o  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

o  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)


Instance protocol:

accessing
o  at: index
return the color for a index.
Notice that the index range is 1...nColors

o  at: index put: aColor
set the color for a index. Return aColor (sigh).
Notice that the index range is 1...

o  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...

o  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...

o  atPixelValue: pixelValue
return the color for a pixelValue.
Notice that pixelValue range is 0...nColors-1

o  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...

o  colors
ST-80 compatibility: return a collection containing the colors I hold

o  colors: aCollectionOfColors
setup the receiver from colors given in a sequenceable collection of colors

o  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...

o  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
o  blueByteAt: index
return the blueByte component for some index.
The returned value is from the internal 0.. 255

o  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...

o  blueVector
return the blueVector

o  blueVector: something
set blueVector

o  greenByteAt: index
return the greenByte component for some index.
The returned value is from the internal 0.. 255

o  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...

o  greenVector
return greenVector

o  greenVector: something
set greenVector

o  redByteAt: index
return the redByte component for some index.
The returned value is from the internal 0.. 255

o  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...

o  redVector
return redVector

o  redVector: something
set redVector

o  redVector: r greenVector: g blueVector: b
set the red, green and blueVectors

converting
o  asArray
return the receiver as an array containing my colors

copying
o  copyFrom: start to: stop

copying-private
o  postCopy
must be called if redefined

misc
o  grow: howBig
change the receiver's size

o  scaleValuesBy: scaleFactor
multiply all values by scaleFactor; finally round to integer.
This can be used to brighten/darken an images colormap

printing & storing
o  storeOn: aStream
append a representation to aStream, from which the receiver
can be reconstructed

queries
o  colorNearestTo: aColor
a very questionable algorithm;
basing the distance on rgb values is very bad - better
do a distance in a cie color cone

o  indexOfColor: aColor

o  indexOfPaintNearest: color

o  isFixedPalette

o  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).

o  size
return the number of colors in the receiver

testing
o  isColormap

o  isMappedPalette



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 28 Mar 2024 16:50:29 GMT