|
Class: Depth32Image
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
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).
copyrightCOPYRIGHT (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.
queries
-
defaultPhotometric
-
return the default photometric pixel interpretation
-
imageDepth
-
return the depth of images represented by instances of
this class - here we return 32
accessing-pixels
-
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
-
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.
-
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
-
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
-
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.
-
valueFromColor: aColor
-
get a color's pixel value.
-
valueFromRGB: anRGBValue
-
get the pixel value corresponding to an RGB value.
converting rgb images
-
computeAlphaValuesFromMask: aMaskImage
-
convert a mask into alpha values;
masked pixels get an alpha value of 0, unmasked of 255
-
rgbImageAsTrueColorFormOn: aDevice
-
return a truecolor form from the rgba or argb-picture.
image manipulations
-
negative
-
Modified (format): / 22-08-2017 / 17:13:38 / cg
initialization
-
initialize
-
magnification
-
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
|
-
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.
|
-
magnifyRowFrom: srcBytes offset: srcStart into: dstBytes offset: dstStart factor: mX
-
magnify a single pixel row - can only magnify by integer factors
queries
-
alphaBitsOf: pixel
-
given a pixel-value, return the alpha component as byteValue (0..255)
-
alphaComponentOf: pixel
-
given a pixel-value, return the alpha component in percent (0..100)
-
alphaMaskForPixelValue
-
return the mask used with translation from pixelValues to alphaBits.
Determines the number of bits of alpha
-
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.
-
bitsPerPixel
-
return the number of bits per pixel
-
bitsPerRow
-
return the number of bits in one scanline of the image
-
bitsPerSample
-
return the number of bits per sample.
The return value is an array of bits-per-plane.
-
blueBitsOf: pixel
-
given a pixel-value, return the blue component as byteValue (0..255)
-
blueComponentOf: pixel
-
given a pixel-value, return the blue component in percent (0..100)
-
blueMaskForPixelValue
-
return the mask used with translation from pixelValues to blueBits
-
blueShiftForPixelValue
-
return the shift amount used with translation from pixelValues to blueBits
-
bytesPerRow
-
return the number of bytes in one scanline of the image
-
greenBitsOf: pixel
-
given a pixel-value, return the green component as byteValue (0..255)
-
greenComponentOf: pixel
-
given a pixel-value, return the green component in percent (0..100)
-
greenMaskForPixelValue
-
return the mask used with translation from pixelValues to redBits
-
greenShiftForPixelValue
-
return the shift amount used with translation from pixelValues to greenBits
-
hasAlphaChannel
-
could be #rgb in 32 bits...
-
numAlphaBits
-
always 8 - even if ignored
-
numBlueBits
-
(comment from inherited method)
alpha in low bits
-
numGreenBits
-
(comment from inherited method)
alpha in low bits
-
numRedBits
-
(comment from inherited method)
alpha in low bits
-
redBitsOf: pixel
-
given a pixel-value, return the red component as byteValue (0..255)
-
redComponentOf: pixel
-
given a pixel-value, return the red component in percent (0..100)
-
redMaskForPixelValue
-
return the mask used with translation from pixelValues to redBits
-
redShiftForPixelValue
-
return the shift amount used with translation from pixelValues to redBits
-
rgbFromValue: pixelValue
-
given a pixel value, return the corresponding 24bit rgbValue (rrggbb, red is MSB).
-
samplesPerPixel
-
return the number of samples per pixel in the image.
-
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
-
valueFromRedBits: redBits greenBits: greenBits blueBits: blueBits alphaBits: alphaBits
-
alpha in low byte
|