Class MatrixToBufferedImage.InterleavedRGBToInterleaved

java.lang.Object
net.algart.external.awt.MatrixToBufferedImage
net.algart.external.awt.MatrixToBufferedImage.InterleavedRGBToInterleaved
Direct Known Subclasses:
MatrixToBufferedImage.InterleavedBGRToInterleaved, MatrixToBufferedImage.MonochromeToIndexed
Enclosing class:
MatrixToBufferedImage

public static class MatrixToBufferedImage.InterleavedRGBToInterleaved extends MatrixToBufferedImage
  • Constructor Details

    • InterleavedRGBToInterleaved

      public InterleavedRGBToInterleaved()
  • Method Details

    • isAlwaysAddAlpha

      public boolean isAlwaysAddAlpha()
    • setAlwaysAddAlpha

      public MatrixToBufferedImage.InterleavedRGBToInterleaved setAlwaysAddAlpha(boolean alwaysAddAlpha)
    • colorValue

      public long colorValue(Matrix<? extends PArray> interleavedMatrix, Color color, int bankIndex)
      Description copied from class: MatrixToBufferedImage
      Converts the color into a form, stored in the data buffer, returned by MatrixToBufferedImage.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 returns

       Math.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 class MatrixToBufferedImage
      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.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toDataBuffer

      protected DataBuffer toDataBuffer(PArray interleavedArray, int bandCount)
      Description copied from class: MatrixToBufferedImage
      Actual method, on which MatrixToBufferedImage.toDataBuffer(Matrix) is based.

      The passed AlgART array must be direct accessible.

      Specified by:
      toDataBuffer in class MatrixToBufferedImage
      Parameters:
      interleavedArray - the interleaved data.
      bandCount - the number of bands: if called from MatrixToBufferedImage.toDataBuffer(Matrix), it is 1 for 2-dimensional matrix and dim(0) for 3-dimensional matrix.
      Returns:
      the newly allocated DataBuffer with the same data.
    • rgbAlphaMasks

      protected int[] rgbAlphaMasks(int bandCount)
      Description copied from class: MatrixToBufferedImage
      Returns the band masks, which will be passed to Raster.createPackedRaster method, if you want to convert data into a packed BufferedImage. The resulting array may be null, that means an unpacked form of the raster (Raster.createBandedRaster), or an array containing bandCount elements: red, green, blue and (if necessary) alpha masks.
      Overrides:
      rgbAlphaMasks in class MatrixToBufferedImage
      Parameters:
      bandCount - the number of masks (3 or 4, in other cases null is returned).
      Returns:
      the bit masks for storing bands in the packed int values.