Package net.algart.external.awt
Class MatrixToBufferedImage.MonochromeToIndexed
java.lang.Object
net.algart.external.awt.MatrixToBufferedImage
net.algart.external.awt.MatrixToBufferedImage.InterleavedRGBToInterleaved
net.algart.external.awt.MatrixToBufferedImage.MonochromeToIndexed
- Enclosing class:
MatrixToBufferedImage
public static class MatrixToBufferedImage.MonochromeToIndexed
extends MatrixToBufferedImage.InterleavedRGBToInterleaved
-
Nested Class Summary
Nested classes/interfaces inherited from class net.algart.external.awt.MatrixToBufferedImage
MatrixToBufferedImage.InterleavedBGRToInterleaved, MatrixToBufferedImage.InterleavedRGBToInterleaved, MatrixToBufferedImage.InterleavedToBandedRGB, MatrixToBufferedImage.MonochromeToIndexed
-
Constructor Summary
ConstructorDescriptionMonochromeToIndexed
(double[] baseColor0, double[] baseColor255) MonochromeToIndexed
(Color baseColor0, Color baseColor255) -
Method Summary
Modifier and TypeMethodDescriptionlong
colorValue
(Matrix<? extends PArray> interleavedMatrix, Color color, int bankIndex) Converts the color into a form, stored in the data buffer, returned byMatrixToBufferedImage.toDataBuffer(Matrix)
.byte[][]
palette()
Returns the palette (byte[4][256]) if the indexed image is supposed.protected DataBuffer
toDataBuffer
(PArray interleavedArray, int bandCount) Actual method, on whichMatrixToBufferedImage.toDataBuffer(Matrix)
is based.toString()
Methods inherited from class net.algart.external.awt.MatrixToBufferedImage.InterleavedRGBToInterleaved
isAlwaysAddAlpha, rgbAlphaMasks, setAlwaysAddAlpha
Methods inherited from class net.algart.external.awt.MatrixToBufferedImage
bytesRequired, getBandCount, getDataArray, getHeight, getWidth, isUnsignedInt32, setUnsignedInt32, toBufferedImage, toBufferedImage, toDataBuffer, toDataBufferBand0Filter
-
Constructor Details
-
MonochromeToIndexed
-
MonochromeToIndexed
public MonochromeToIndexed(double[] baseColor0, double[] baseColor255)
-
-
Method Details
-
colorValue
Description copied from class:MatrixToBufferedImage
Converts the color into a form, stored in the data buffer, returned byMatrixToBufferedImage.toDataBuffer(Matrix)
.The default implementation is suitable for monochrome, indexed and multi-bank data buffers.
Note: if the interleaved matrix is monochrome or indexed, i.e.
getBandCount
(interleavedMatrix)==1, this method returnsMath.round(0.3 * color.getRed() + 0.59 * color.getGreen() + 0.11 * color.getBlue())
The good idea is to provide identical R, G, B color components in such cases (if this method is not overridden).
- Overrides:
colorValue
in classMatrixToBufferedImage.InterleavedRGBToInterleaved
- Parameters:
interleavedMatrix
- the interleaved data.color
- some color.bankIndex
- index of the bank in terms of java.awt.image.DataBuffer.- Returns:
- the corresponded component of this color or interleaved RGB-Alpha value, depending on the structure of the data buffer.
-
palette
public byte[][] palette()Description copied from class:MatrixToBufferedImage
Returns the palette (byte[4][256]) if the indexed image is supposed.The default implementation returns null, that means non-indexed image.
- Overrides:
palette
in classMatrixToBufferedImage
- Returns:
- the palette or null if the image should be not indexed.
-
toString
- Overrides:
toString
in classMatrixToBufferedImage.InterleavedRGBToInterleaved
-
toDataBuffer
Description copied from class:MatrixToBufferedImage
Actual method, on whichMatrixToBufferedImage.toDataBuffer(Matrix)
is based.The passed AlgART array must be
direct accessible
.- Overrides:
toDataBuffer
in classMatrixToBufferedImage.InterleavedRGBToInterleaved
- Parameters:
interleavedArray
- the interleaved data.bandCount
- the number of bands: if called fromMatrixToBufferedImage.toDataBuffer(Matrix)
, it is 1 for 2-dimensional matrix anddim(0)
for 3-dimensional matrix.- Returns:
- the newly allocated DataBuffer with the same data.
-