Example usage for java.awt.image SinglePixelPackedSampleModel getBitMasks

List of usage examples for java.awt.image SinglePixelPackedSampleModel getBitMasks

Introduction

In this page you can find the example usage for java.awt.image SinglePixelPackedSampleModel getBitMasks.

Prototype

public int[] getBitMasks() 

Source Link

Document

Returns the bit masks for all bands.

Usage

From source file:GraphicsUtil.java

public static boolean is_INT_PACK_Data(SampleModel sm, boolean requireAlpha) {
    // Check ColorModel is of type DirectColorModel
    if (!(sm instanceof SinglePixelPackedSampleModel))
        return false;

    // Check transfer type
    if (sm.getDataType() != DataBuffer.TYPE_INT)
        return false;

    SinglePixelPackedSampleModel sppsm;
    sppsm = (SinglePixelPackedSampleModel) sm;

    int[] masks = sppsm.getBitMasks();
    if (masks.length == 3) {
        if (requireAlpha)
            return false;
    } else if (masks.length != 4)
        return false;

    if (masks[0] != 0x00ff0000)
        return false;
    if (masks[1] != 0x0000ff00)
        return false;
    if (masks[2] != 0x000000ff)
        return false;
    if ((masks.length == 4) && (masks[3] != 0xff000000))
        return false;

    return true;/* w  w  w.j  a v a2s  .c  o  m*/
}