eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Depth1Image':

Home

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

Class: Depth1Image


Inheritance:

   Object
   |
   +--Image
      |
      +--Depth1Image
         |
         +--ImageMask

Package:
stx:libview
Category:
Graphics-Images
Version:
rev: 1.76 date: 2018/03/27 13:40:58
user: cg
file: Depth1Image.st directory: libview
module: stx stc-classLibrary: libview
Author:
Claus Gittinger

Description:


this class represents bilevel (1 bit / pixel) images.
It mainly consists of methods which are already implemented in Image,
but reimplemented here for more performance. If you plan to do heavy
image processing on bilevel images, you may want to add more
specialized methods here.

#blackIs0 / #whiteIs0 and #palette formats are supported here.


Related information:

    Depth2Image
    Depth4Image
    Depth8Image
    Depth16Image
    Depth24Image
    ImageReader

Class protocol:

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


Instance protocol:

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

o  pixelAtX: x y: y put: aPixelValue
set a pixel's value at x/y to aPixelValue (0 or 1).
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 the upper left pixel,
and end at x = width-1, y=height-1 for the lower right pixel

converting
o  asFormOn: aDevice
convert a monochrome image to a device form

o  clearMaskedPixels
this works only for b/w images

o  greyImageAsFormOn: aDevice
convert a greyscale image to a device form

o  greyImageAsMonoFormOn: aDevice
convert to a monochrome form - that's easy

o  paletteImageAsMonoFormOn: aDevice
convert a palette image to a b&w monochrome device form

o  paletteImageAsTrueColorFormOn: aDevice
since all devices must support monochrome images, and
a 2-entry colormap is implemented by ST/X's drawForm methods,
we can do this on all color devices as a palette image.

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

magnification
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.
This method has been specially tuned for magnification by 2 and 4.

private
o  anyImageAsFormOn: aDevice
convert a 1-bit (possibly monochrome) image to a device form

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  rgbFromValue: pixelValue
given a pixel value, return the corresponding 24bit rgbValue (rrggbb, red is MSB).
Pixel values start with 0.

o  usedColors
return a collection of colors used in the receiver.
For depth1 images, we return the colorMap here, assuming all
pixels are used ...
... which is not really true - it could be all-white or all-black

usage example(s):

     (Image fromFile:'bitmaps/garfield.gif') usedColors
     (Image fromFile:'bitmaps/SBrowser.xbm') usedColors

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

o  valueFromColor: aColor
given a color, return the corresponding pixel value.
Non-representable colors return nil.



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 28 Mar 2024 09:00:20 GMT