eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Depth8Image':

Home

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

Class: Depth8Image


Inheritance:

   Object
   |
   +--Image
      |
      +--Depth8Image

Package:
stx:libview
Category:
Graphics-Images
Version:
rev: 1.141 date: 2018/03/27 13:41:23
user: cg
file: Depth8Image.st directory: libview
module: stx stc-classLibrary: libview
Author:
Claus Gittinger

Description:


this class represents 256-color (8 bit / pixel) images (palette, greyscale ...).
It mainly consists of methods already implemented in Image,
reimplemented here for more performance.


Related information:

    Depth1Image
    Depth2Image
    Depth4Image
    Depth16Image
    Depth24Image
    ImageReader

Class protocol:

queries
o  defaultPhotometric
return the default photometric pixel interpretation.
This may be a somewhat old leftover from times, when tiff was the first image file type to be read.
Much better would be to always have some (possibly fake and virtual) colormap around, and ask that one.
However, in the meantime, many other classes depend on that, so that it should be kept as an API
- even when the internal representation will be replaced by something better in the future.

o  imageDepth
return the depth of images represented by instances of
this class - here we return 8


Instance protocol:

accessing-pixels
o  pixelAtX: x y: y
retrieve a pixel at x/y; return a pixelValue. (0..255)
The interpretation of the returned value depends on the photometric
and the colormap. See also Image>>atX:y:)
Pixels start at x=0 , y=0 for upper left pixel, end at
x = width-1, y=height-1 for lower right pixel

o  pixelAtX: x y: y put: aPixelValue
set the pixel at x/y to aPixelValue (0..255).
The interpretation of the pixelValue depends on the photometric
and the colormap. (see also: Image>>atX:y:put:)
Pixels start at x=0 , y=0 for upper left pixel, end at
x = width-1, y=height-1 for lower right pixel

o  rowAt: y into: aPixelBuffer startingAt: startIndex
fill aPixelBuffer with pixel values from a single row.
Notice: row/column coordinates start at 0.

o  rowAt: y putAll: pixelArray startingAt: startIndex
store a single row's bits from bits in the pixelArray argument;
The interpretation of the pixel values depends on the photometric.
Notice: row/column coordinates start at 0.

converting
o  fromImage: anImage
setup the receiver from another image.
The code here is tuned for depth 1, 2 and 4 source images;
other conversions are done in the superclasses fallBack method.

converting images
o  anyImageAsPseudoFormOn: aDevice
return a pseudoForm from the palette picture.
The main work is in color reduction, when not all colors can be acquired.
This method works for any photometric.

o  anyImageAsTrueColorFormOn: aDevice
return a true-color device-form for the receiver.
Supports true color devices with depths: 8, 16, 24 and 32

o  asGray8FormOn: aDevice
return an 8-bit greyForm from the 8-bit receiver image.
Redefined, since only a translation has to be done here.

o  asGrayFormOn: aDevice
get a gray device form.
Redefined, since we can do it with simple translate,
if the depth matches my depth.

o  greyImageAsPseudoFormOn: aDevice
return a pseudoForm from the gray picture. The main work is
in color reduction, when not all colors can be acquired.

o  greyImageAsTrueColorFormOn: aDevice
return a true-color device-form for the grey-image receiver.
Supports true color devices with depths: 8, 16, 24 and 32

o  paletteImageAsPseudoFormOn: aDevice
return a pseudoForm from the palette picture. The main work is
in color reduction, when not all colors can be acquired.

o  paletteImageAsTrueColorFormOn: aDevice
return a true-color device-form for the palette-image receiver.
Supports true color devices with depths: 8, 16, 24 and 32

o  rgbImageAsTrueColorFormOn: aDevice
return a true-color device-form for the rgb-image receiver.
Supports true color devices with depths: 8, 16, 24 and 32

dither helpers
o  floydSteinbergDitheredDepth8BitsColors: colors map: aMapOrNil
return a floyd-steinberg dithered bitmap from the receiver picture,
which must be a depth-8 image.
This method expects an array of colors to be used for dithering
(which need not be a colorCubes colors).

o  orderedDitheredGrayBitsWithDitherMatrix: ditherMatrix ditherWidth: dW depth: depth
return the bitmap for a dithered depth-bitmap from the image;
with a constant ditherMatrix, this can be used for thresholding.
Redefined to make use of knowing that pixels are 8-bit values.

o  orderedDitheredMonochromeBitsWithDitherMatrix: ditherMatrix ditherWidth: dW
return the dithered monochrome bits for the receiver image;
with a constant ditherMatrix, this can be used for thresholding.
Redefined to make use of knowing that pixels are 8-bit values.

enumerating
o  colorsAtY: y from: xLow to: xHigh do: aBlock
perform aBlock for each pixel from x1 to x2 in row y.
The block is passed the color at each pixel.
This method allows slighly faster processing of an
image than using atX:y:, since some processing can be
avoided when going from pixel to pixel. However, for
real image processing, specialized methods should be written.

o  colorsFromX: xStart y: yStart toX: xEnd y: yEnd do: aBlock
perform aBlock for each pixel in the rectangle
yStart..yEnd / xStart..xEnd.
The block is passed the color at each pixel.
This method allows slighly faster processing of an
image than using individual atX:y: accesses,
both since some processing can be avoided when going from pixel to pixel,
and since the color composition is done outside of the pixel loop.
However, for real high performance image processing, specialized methods
should be written which know how to deal with specific photometric interpretations.

o  valuesAtY: y from: xLow to: xHigh do: aBlock
WARNING: this enumerates pixel values which need photometric interpretation
Do not confuse with #rgbValuesAtY:from:to:do:

Perform aBlock for each pixelValue from x1 to x2 in row y.

Notice the difference between rgbValue and pixelValue: rgbValues are always
the rgb bytes; pixelvalues depend on the photometric interpretation, and may be
indices into a colormap or be non-byte-sized rgb values.

The block is passed the pixelValue at each pixel.
This method allows slighly faster processing of an
image than using valueAtX:y:, since some processing can be
avoided when going from pixel to pixel. However, for
real image processing, specialized methods should be written.

o  valuesFromX: xStart y: yStart toX: xEnd y: yEnd do: aBlock
WARNING: this enumerates pixel values which need photometric interpretation
Do not confuse with #rgbValuesAtY:from:to:do:

Perform aBlock for each pixelValue in a rectangular area of the image.

Notice the difference between rgbValue and pixelValue: rgbValues are always
the rgb bytes; pixelvalues depend on the photometric interpretation, and may be
indices into a colormap or be non-byte-sized rgb values.

The block is passed the pixelValue at each pixel.
This method allows slighly faster processing of an
image than using individual valueAtX:y: accesses,
since some processing can be avoided when going from pixel to pixel..
However, for real high performance image processing, specialized methods
should be written which know how to deal with specific photometric interpretations.

image manipulations
o  easyRotateBitsInto: destinationImage angle: degrees
tuned helper for rotation - does the actual pixel shuffling, by degrees clockwise.
Here, only 90, 180 and 270 degrees are implemented.
Hard angles are done in #hardRotate:.
The code here a tuned version of the inherited for more performance

o  hardMagnifiedBy: scaleArg
return a new image magnified by scalePoint, aPoint.
This is the general magnification method, handling non-integral values.
It is slower than the integral magnification method.

Notice: this is a naive algorithm, which simply samples the pixel value
at the corresponding original pixel's point, without taking neighbors into
consideration (i.e. it does not compute an average of those pixels).
As a consequence, this will generate bad shrunk images when the original contains
sharp lines.

o  magnifyRowFrom: srcBytes offset: srcStart into: dstBytes offset: dstStart factor: mX
magnify a single pixel row - can only magnify by integer factors.
Specially tuned for factors 2,3 and 4.

private
o  dither1PlaneUsingMap: map on: aDevice
a helper for dithering palette and greyscale images

o  dither2PlaneUsingMap: map on: aDevice
a helper for dithering palette and greyscale images

queries
o  bitsPerPixel
return the number of bits per pixel

o  bitsPerRow
return the number of bits in one scanline of the image

o  bytesPerRow
return the number of bytes in one scanline of the image

o  colorFromValue: pixelValue
given a pixel value, return the corresponding color.
Pixel values start with 0.

o  nColorsUsed
wrong and misleading...

o  realUsedValues
return a collection of color values used in the receiver.

o  usedValues
return a collection of color values used in the receiver.



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