Example usage for java.awt.image BufferedImage TYPE_4BYTE_ABGR_PRE

List of usage examples for java.awt.image BufferedImage TYPE_4BYTE_ABGR_PRE

Introduction

In this page you can find the example usage for java.awt.image BufferedImage TYPE_4BYTE_ABGR_PRE.

Prototype

int TYPE_4BYTE_ABGR_PRE

To view the source code for java.awt.image BufferedImage TYPE_4BYTE_ABGR_PRE.

Click Source Link

Document

Represents an image with 8-bit RGBA color components with the colors Blue, Green, and Red stored in 3 bytes and 1 byte of alpha.

Usage

From source file:org.codice.alliance.imaging.chip.transformer.CatalogOutputAdapter.java

private void setImageDataFields(BufferedImage chip, ImageSegment chipImageSegment) throws IOException {

    int[] componentSizes = chip.getColorModel().getComponentSize();
    int pixelSize = chip.getColorModel().getPixelSize();

    switch (chip.getType()) {
    case BufferedImage.TYPE_BYTE_GRAY:
    case BufferedImage.TYPE_USHORT_GRAY:
    case BufferedImage.TYPE_BYTE_BINARY:
        setMonochrome(chipImageSegment, componentSizes[0], pixelSize);
        break;//from   www . j a  v a 2 s . c  o  m
    case BufferedImage.TYPE_3BYTE_BGR:
    case BufferedImage.TYPE_INT_BGR:
        setImageFieldHelper(chipImageSegment, PixelValueType.INTEGER, ImageRepresentation.RGBTRUECOLOUR,
                componentSizes[0], pixelSize / 3, new String[] { "B", "G", "R" });
        break;
    case BufferedImage.TYPE_4BYTE_ABGR:
    case BufferedImage.TYPE_4BYTE_ABGR_PRE:
        setImageFieldHelper(chipImageSegment, PixelValueType.INTEGER, ImageRepresentation.RGBTRUECOLOUR,
                componentSizes[0], pixelSize / 4, new String[] { "B", "G", "R" });
        break;
    case BufferedImage.TYPE_INT_ARGB_PRE:
    case BufferedImage.TYPE_INT_ARGB:
        setARGB(chipImageSegment, componentSizes[0], pixelSize);
        break;
    case BufferedImage.TYPE_INT_RGB:
    case BufferedImage.TYPE_USHORT_555_RGB:
        setRGB(chipImageSegment, componentSizes[0], pixelSize);
        break;
    case BufferedImage.TYPE_CUSTOM:
        if (componentSizes.length == 1) {
            setMonochrome(chipImageSegment, componentSizes[0], pixelSize);
        } else if (componentSizes.length == 3) {
            setRGB(chipImageSegment, componentSizes[0], pixelSize);
        } else if (componentSizes.length == 4) {
            setARGB(chipImageSegment, componentSizes[0], pixelSize);
        } else {
            throw new IOException(
                    "unsupported color model for image type CUSTOM, only monochrome and 32-bit argb are supported");
        }
        break;
    case BufferedImage.TYPE_BYTE_INDEXED:
        setImageFieldHelper(chipImageSegment, PixelValueType.INTEGER, ImageRepresentation.RGBLUT,
                componentSizes[0], pixelSize, new String[] { "LU" });
        break;
    case BufferedImage.TYPE_USHORT_565_RGB:
        // don't know how to handle this one, since the bitsPerPixelPerBand is not consistent
        break;
    default:
        throw new IOException("unsupported image data type: type=" + chip.getType());
    }
}