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.55 date: 2022/02/23 08:07:36
user: cg
file: Colormap.st directory: libview
module: stx stc-classLibrary: libview

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

copyright

COPYRIGHT (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.

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.

Usage example(s):

     |map|

     map := MappedPalette rgbBytesVector:#[0 0 0 127 127 127 255 0 0 255 255 255].
     map atPixelValue:2    

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

Usage example(s):

     |map|

     map := MappedPalette rgbValueVector:#(16r000000 16r7F7F7F 16r800000 16rFFFFFF).
     map atPixelValue:2    

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

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

o  size
return the number of colors in the receiver

testing
o  isColormap

o  isMappedPalette



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Tue, 10 Dec 2024 21:19:50 GMT