Example usage for java.awt.image DataBufferByte getBankData

List of usage examples for java.awt.image DataBufferByte getBankData

Introduction

In this page you can find the example usage for java.awt.image DataBufferByte getBankData.

Prototype

public byte[][] getBankData() 

Source Link

Document

Returns the data arrays for all banks.

Usage

From source file:GraphicsUtil.java

protected static void mult_BYTE_COMP_Data(WritableRaster wr) {
    // System.out.println("Multiply Int: " + wr);

    ComponentSampleModel csm;/*w  w  w  .  ja v a 2  s . c o  m*/
    csm = (ComponentSampleModel) wr.getSampleModel();

    final int width = wr.getWidth();

    final int scanStride = csm.getScanlineStride();
    final int pixStride = csm.getPixelStride();
    final int[] bandOff = csm.getBandOffsets();

    DataBufferByte db = (DataBufferByte) wr.getDataBuffer();
    final int base = (db.getOffset() + csm.getOffset(wr.getMinX() - wr.getSampleModelTranslateX(),
            wr.getMinY() - wr.getSampleModelTranslateY()));

    int aOff = bandOff[bandOff.length - 1];
    int bands = bandOff.length - 1;

    // Access the pixel data array
    final byte[] pixels = db.getBankData()[0];
    for (int y = 0; y < wr.getHeight(); y++) {
        int sp = base + y * scanStride;
        final int end = sp + width * pixStride;
        while (sp < end) {
            int a = pixels[sp + aOff] & 0xFF;
            if (a != 0xFF)
                for (int b = 0; b < bands; b++) {
                    int i = sp + bandOff[b];
                    pixels[i] = (byte) (((pixels[i] & 0xFF) * a) >> 8);
                }
            sp += pixStride;
        }
    }
}

From source file:GraphicsUtil.java

protected static void divide_BYTE_COMP_Data(WritableRaster wr) {
    // System.out.println("Multiply Int: " + wr);

    ComponentSampleModel csm;//  w  ww .j  a  v  a  2  s. c o  m
    csm = (ComponentSampleModel) wr.getSampleModel();

    final int width = wr.getWidth();

    final int scanStride = csm.getScanlineStride();
    final int pixStride = csm.getPixelStride();
    final int[] bandOff = csm.getBandOffsets();

    DataBufferByte db = (DataBufferByte) wr.getDataBuffer();
    final int base = (db.getOffset() + csm.getOffset(wr.getMinX() - wr.getSampleModelTranslateX(),
            wr.getMinY() - wr.getSampleModelTranslateY()));

    int aOff = bandOff[bandOff.length - 1];
    int bands = bandOff.length - 1;

    // Access the pixel data array
    final byte[] pixels = db.getBankData()[0];
    for (int y = 0; y < wr.getHeight(); y++) {
        int sp = base + y * scanStride;
        final int end = sp + width * pixStride;
        while (sp < end) {
            int a = pixels[sp + aOff] & 0xFF;
            if (a == 0) {
                for (int b = 0; b < bands; b++)
                    pixels[sp + bandOff[b]] = (byte) 0xFF;
            } else if (a < 255) { // this does NOT include a == 255 (0xff) !
                int aFP = (0x00FF0000 / a);
                for (int b = 0; b < bands; b++) {
                    int i = sp + bandOff[b];
                    pixels[i] = (byte) (((pixels[i] & 0xFF) * aFP) >>> 16);
                }
            }
            sp += pixStride;
        }
    }
}

From source file:GraphicsUtil.java

protected static void mult_BYTE_COMP_Data(WritableRaster wr) {
    // System.out.println("Multiply Int: " + wr);

    ComponentSampleModel csm;/*from  ww  w . j a v  a  2  s . c o m*/
    csm = (ComponentSampleModel) wr.getSampleModel();

    final int width = wr.getWidth();

    final int scanStride = csm.getScanlineStride();
    final int pixStride = csm.getPixelStride();
    final int[] bandOff = csm.getBandOffsets();

    DataBufferByte db = (DataBufferByte) wr.getDataBuffer();
    final int base = (db.getOffset() + csm.getOffset(wr.getMinX() - wr.getSampleModelTranslateX(),
            wr.getMinY() - wr.getSampleModelTranslateY()));

    int a = 0;
    int aOff = bandOff[bandOff.length - 1];
    int bands = bandOff.length - 1;
    int b, i;

    // Access the pixel data array
    final byte pixels[] = db.getBankData()[0];
    for (int y = 0; y < wr.getHeight(); y++) {
        int sp = base + y * scanStride;
        final int end = sp + width * pixStride;
        while (sp < end) {
            a = pixels[sp + aOff] & 0xFF;
            if (a != 0xFF)
                for (b = 0; b < bands; b++) {
                    i = sp + bandOff[b];
                    pixels[i] = (byte) (((pixels[i] & 0xFF) * a) >> 8);
                }
            sp += pixStride;
        }
    }
}

From source file:GraphicsUtil.java

protected static void divide_BYTE_COMP_Data(WritableRaster wr) {
    // System.out.println("Multiply Int: " + wr);

    ComponentSampleModel csm;//from  w  w w .  j  a  v  a  2 s . c  om
    csm = (ComponentSampleModel) wr.getSampleModel();

    final int width = wr.getWidth();

    final int scanStride = csm.getScanlineStride();
    final int pixStride = csm.getPixelStride();
    final int[] bandOff = csm.getBandOffsets();

    DataBufferByte db = (DataBufferByte) wr.getDataBuffer();
    final int base = (db.getOffset() + csm.getOffset(wr.getMinX() - wr.getSampleModelTranslateX(),
            wr.getMinY() - wr.getSampleModelTranslateY()));

    int a = 0;
    int aOff = bandOff[bandOff.length - 1];
    int bands = bandOff.length - 1;
    int b, i;
    // Access the pixel data array
    final byte pixels[] = db.getBankData()[0];
    for (int y = 0; y < wr.getHeight(); y++) {
        int sp = base + y * scanStride;
        final int end = sp + width * pixStride;
        while (sp < end) {
            a = pixels[sp + aOff] & 0xFF;
            if (a == 0) {
                for (b = 0; b < bands; b++)
                    pixels[sp + bandOff[b]] = (byte) 0xFF;
            } else if (a < 255) {
                int aFP = (0x00FF0000 / a);
                for (b = 0; b < bands; b++) {
                    i = sp + bandOff[b];
                    pixels[i] = (byte) (((pixels[i] & 0xFF) * aFP) >>> 16);
                }
            }
            sp += pixStride;
        }
    }
}