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.81 date: 2022/08/12 06:40:15
user: matilk
file: Depth1Image.st directory: libview
module: stx stc-classLibrary: libview

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.

copyright

COPYRIGHT (c) 1993 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:

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  fromAlphaInImage: anImage threshold: alphaThreshold
setup the receiver from the alpha channel of another image.
WARNING:
This implementation is a slow fallback (the loop over the
source pixels is very slow). If this method is used heavily, you
may want to redefine it in concrete subclasses for common source images.

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

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

o  greyImageAsMonoFormOn: aDevice
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  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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:47:56 GMT