eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Depth32Image':

Home

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

Class: Depth32Image


Inheritance:

   Object
   |
   +--Image
      |
      +--Depth32Image

Package:
stx:libview
Category:
Graphics-Images
Version:
rev: 1.54 date: 2023/08/28 09:24:33
user: cg
file: Depth32Image.st directory: libview
module: stx stc-classLibrary: libview

Description:


this class represents 32 bit (eg. rgb+alpha) images.

Only the minimum protocol is implemented here; much more is
needed for higher performance operations on depth32 images.

with #rgb, #rgba, #rgbx, photometrics 
pixels are internally stored byte-wise in rgba order.
(i.e. r at low-address byte, a at high-address byte). 
For rgb, a zero is always retrieved as alpha; 255 for rgbx.

When reading pixel values, photometric argb is returned as aarrggbb,
photometric rgb is returned as 00rrggbb,
photometric rgba is returned as rrggbb00,
both on LSB and on MSB machines.
(i.e. blue in lower bits of the returned 32bit integer, alpha in the high bits for argb,
 and in the low bits for rgba)
Thus, pixelValues and rgbValues are identical, simulating MSB on all
architectures.
(this should be transparent, if you use the rgbValueAt
 accessors; however, some old code uses pixelValueAt:, assuming that the
returned pixel value is rrggbb - which it would not be without this hack).

This also makes depth24Image's rgbValues compatible with depth32Image's rgbValues.

For argb and xrgb formats, alpha (or dummy alpha) is in the first byte 
(which are the high bits, as we present pixel values always MSB).

copyright

COPYRIGHT (c) 1995 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  defaultPhotometric
return the default photometric pixel interpretation

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


Instance protocol:

accessing-pixels
o  colorAtX: x y: y
retrieve a pixel at x/y; return a color.
Pixels start at x=0 , y=0 for upper left pixel,
end at x = width-1, y=height-1 for lower right pixel

o  colorAtX: x y: y put: aColor
set the pixel at x/y to aColor.
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
retrieve a pixel at x/y; return a pixelValue.
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.
With rgba photometric, the pixel value contains r/g/b/a in lsb order
(i.e. r at low, a at high bits);
with argb, alpha is in the low byte

o  pixelAtX: x y: y put: aPixelValue
set the pixel at x/y to aPixelValue.
The interpretation of the pixelValue depends on the photometric.
Pixels start at x=0 , y=0 for upper left pixel, end at
x = width-1, y=height-1 for lower right pixel.
With rgba photometric, the pixel value contains r/g/b/a in lsb order
(i.e. r at low, a at high bits);
with argb, alpha is in the low byte

o  rowAt: y putAll: pixelArray startingAt: startIndex
store a single rows bits from bits in the pixelArray argument;
The interpretation of the pixel values depends on the photometric.
Notice: row coordinate starts at 0.

o  valueFromColor: aColor
get a color's pixel value.

o  valueFromRGB: anRGBValue
get the pixel value corresponding to an RGB value.

converting rgb images
o  computeAlphaValuesFromMask: aMaskImage
convert a mask into alpha values;
masked pixels get an alpha value of 0, unmasked of 255

o  rgbImageAsTrueColorFormOn: aDevice
return a truecolor form from the rgba or argb-picture.

image manipulations
o  negative
Modified (format): / 22-08-2017 / 17:13:38 / cg

initialization
o  initialize

magnification
o  hardAntiAliasedMagnifiedBy: scaleArg
return a new image magnified by scalePoint, aPoint.
This interpolates pixels and is therefore much slower,
but generates nicer looking magnifications.

Usage example(s):

     |i|
     i := Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif'.
     i := Depth32Image fromImage:i.
     i hardAntiAliasedMagnifiedBy:2@2.
     i hardAntiAliasedMagnifiedBy:0.65@0.65.
     i hardAntiAliasedMagnifiedBy:0.3@0.3.

Usage example(s):

     |i|
     i := Depth32Image width:3 height:3 fromArray:#[ 0 0 0 127   0 0 0 127  0 0 0 127
                                                     0 0 0 127  255 255 255 127  0 0 0 127
                                                     0 0 0 127   0 0 0 127  0 0 0 127].
     i hardAntiAliasedMagnifiedBy:8@8

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.

Usage example(s):

     |i|
     i := Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif'.
     i := Depth32Image fromImage:i.
     i hardMagnifiedBy:2@2.
     i hardMagnifiedBy:0.65@0.65.
     i hardMagnifiedBy:0.3@0.3.

o  magnifyRowFrom: srcBytes offset: srcStart into: dstBytes offset: dstStart factor: mX
magnify a single pixel row - can only magnify by integer factors

queries
o  alphaBitsOf: pixel
given a pixel-value, return the alpha component as byteValue (0..255)

o  alphaComponentOf: pixel
given a pixel-value, return the alpha component in percent (0..100)

o  alphaMaskForPixelValue
return the mask used with translation from pixelValues to alphaBits.
Determines the number of bits of alpha

o  alphaShiftForPixelValue
return the shift amount used with translation from pixelValues to alphaBits.
That is the number of bits to shift the alpha value into the pixel value.

o  bitsPerPixel
return the number of bits per pixel

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

o  bitsPerSample
return the number of bits per sample.
The return value is an array of bits-per-plane.

o  blueBitsOf: pixel
given a pixel-value, return the blue component as byteValue (0..255)

o  blueComponentOf: pixel
given a pixel-value, return the blue component in percent (0..100)

o  blueMaskForPixelValue
return the mask used with translation from pixelValues to blueBits

o  blueShiftForPixelValue
return the shift amount used with translation from pixelValues to blueBits

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

o  greenBitsOf: pixel
given a pixel-value, return the green component as byteValue (0..255)

o  greenComponentOf: pixel
given a pixel-value, return the green component in percent (0..100)

o  greenMaskForPixelValue
return the mask used with translation from pixelValues to redBits

o  greenShiftForPixelValue
return the shift amount used with translation from pixelValues to greenBits

o  hasAlphaChannel
could be #rgb in 32 bits...

o  numAlphaBits
always 8 - even if ignored

o  numBlueBits
(comment from inherited method)
alpha in low bits

o  numGreenBits
(comment from inherited method)
alpha in low bits

o  numRedBits
(comment from inherited method)
alpha in low bits

o  redBitsOf: pixel
given a pixel-value, return the red component as byteValue (0..255)

o  redComponentOf: pixel
given a pixel-value, return the red component in percent (0..100)

o  redMaskForPixelValue
return the mask used with translation from pixelValues to redBits

o  redShiftForPixelValue
return the shift amount used with translation from pixelValues to redBits

o  rgbFromValue: pixelValue
given a pixel value, return the corresponding 24bit rgbValue (rrggbb, red is MSB).

o  samplesPerPixel
return the number of samples per pixel in the image.

o  valueFromRedBits: redBits greenBits: greenBits blueBits: blueBits
given the rgb bits, each in 0..maxXXXValue (i.e. according to
r/g/b channels number of bits, return the corresponding pixel value.
For now, only useful with RGB images

o  valueFromRedBits: redBits greenBits: greenBits blueBits: blueBits alphaBits: alphaBits
alpha in low byte



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 17:46:12 GMT