java.awt.image.ComponentColorModel

Here are the examples of the java api class java.awt.image.ComponentColorModel taken from open source projects.

1. ImageFactory#createCCMImage()

Project: openjdk
File: ImageFactory.java
public static BufferedImage createCCMImage(int cs, int dataType) {
    ColorSpace cSpace = ColorSpace.getInstance(cs);
    ComponentColorModel ccm = null;
    if (dataType == DataBuffer.TYPE_INT) {
        ccm = new ComponentColorModel(cSpace, ((cs == ColorSpace.CS_GRAY) ? new int[] { 8 } : new int[] { 8, 8, 8 }), false, false, Transparency.OPAQUE, dataType);
    } else {
        ccm = new ComponentColorModel(cSpace, false, false, Transparency.OPAQUE, dataType);
    }
    SampleModel sm = ccm.createCompatibleSampleModel(WIDTH, HEIGHT);
    WritableRaster raster = ccm.createCompatibleWritableRaster(WIDTH, HEIGHT);
    DataBuffer data = raster.getDataBuffer();
    fillCCM(data, sm, cSpace);
    return new BufferedImage(ccm, raster, false, null);
}

2. ImageFactory#createCCMImage()

Project: jdk7u-jdk
File: ImageFactory.java
public static BufferedImage createCCMImage(int cs, int dataType) {
    ColorSpace cSpace = ColorSpace.getInstance(cs);
    ComponentColorModel ccm = null;
    if (dataType == DataBuffer.TYPE_INT) {
        ccm = new ComponentColorModel(cSpace, ((cs == ColorSpace.CS_GRAY) ? new int[] { 8 } : new int[] { 8, 8, 8 }), false, false, Transparency.OPAQUE, dataType);
    } else {
        ccm = new ComponentColorModel(cSpace, false, false, Transparency.OPAQUE, dataType);
    }
    SampleModel sm = ccm.createCompatibleSampleModel(WIDTH, HEIGHT);
    WritableRaster raster = ccm.createCompatibleWritableRaster(WIDTH, HEIGHT);
    DataBuffer data = raster.getDataBuffer();
    fillCCM(data, sm, cSpace);
    return new BufferedImage(ccm, raster, false, null);
}

3. ImageEncoderPNGTestCase#testGetImplicitFilterWithComponentColorModel()

Project: fop
File: ImageEncoderPNGTestCase.java
@Test
public void testGetImplicitFilterWithComponentColorModel() {
    ImageSize is = RawPNGTestUtil.getImageSize();
    ComponentColorModel cm = mock(ComponentColorModel.class);
    when(cm.getNumComponents()).thenReturn(3);
    ImageRawPNG irpng = mock(ImageRawPNG.class);
    when(irpng.getColorModel()).thenReturn(cm);
    when(irpng.getBitDepth()).thenReturn(8);
    when(irpng.getSize()).thenReturn(is);
    ImageEncoderPNG iepng = new ImageEncoderPNG(irpng);
    String expectedFilter = "<< /Predictor 15 /Columns 32 /Colors 3 /BitsPerComponent 8 >> /FlateDecode";
    assertEquals(expectedFilter, iepng.getImplicitFilter());
}

4. ImageEncoderPNGTestCase#testWriteToWithGRGBAPNG()

Project: fop
File: ImageEncoderPNGTestCase.java
private void testWriteToWithGRGBAPNG(int gray, int red, int green, int blue, int alpha) throws IOException {
    int numComponents = (gray > -1 ? 1 : 3) + (alpha > -1 ? 1 : 0);
    ImageSize is = RawPNGTestUtil.getImageSize();
    ComponentColorModel cm = mock(ComponentColorModel.class);
    when(cm.getNumComponents()).thenReturn(numComponents);
    ImageRawPNG irpng = mock(ImageRawPNG.class);
    when(irpng.getColorModel()).thenReturn(cm);
    when(irpng.getSize()).thenReturn(is);
    ImageEncoderPNG iepng = new ImageEncoderPNG(irpng);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] data = RawPNGTestUtil.buildGRGBAData(gray, red, green, blue, alpha);
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    when(irpng.createInputStream()).thenReturn(bais);
    iepng.writeTo(baos);
    if (alpha > -1) {
        byte[] expected = RawPNGTestUtil.buildGRGBAData(gray, red, green, blue, -1);
        assertArrayEquals(expected, baos.toByteArray());
    } else {
        assertArrayEquals(data, baos.toByteArray());
    }
}

5. ImageRawPNGAdapterTestCase#testPopulateXObjectDictionaryWithComponentColorModelAndsRGB()

Project: fop
File: ImageRawPNGAdapterTestCase.java
@Test
public void testPopulateXObjectDictionaryWithComponentColorModelAndsRGB() {
    ComponentColorModel cm = mock(ComponentColorModel.class);
    ImageRawPNG irpng = mock(ImageRawPNG.class);
    PDFDictionary pdfDic = mock(PDFDictionary.class);
    ImageRawPNGAdapter irpnga = new ImageRawPNGAdapter(irpng, "mock");
    when(irpng.getColorModel()).thenReturn(cm);
    when(irpng.getRenderingIntent()).thenReturn(0);
    irpnga.populateXObjectDictionary(pdfDic);
    verify(pdfDic).put("Intent", new PDFName("Perceptual"));
    when(irpng.getRenderingIntent()).thenReturn(1);
    irpnga.populateXObjectDictionary(pdfDic);
    verify(pdfDic).put("Intent", new PDFName("RelativeColorimetric"));
    when(irpng.getRenderingIntent()).thenReturn(2);
    irpnga.populateXObjectDictionary(pdfDic);
    verify(pdfDic).put("Intent", new PDFName("Saturation"));
    when(irpng.getRenderingIntent()).thenReturn(3);
    irpnga.populateXObjectDictionary(pdfDic);
    verify(pdfDic).put("Intent", new PDFName("AbsoluteColorimetric"));
}

6. ImageRawPNGAdapterTestCase#testSetupWithComponentColorModel()

Project: fop
File: ImageRawPNGAdapterTestCase.java
@Test
public void testSetupWithComponentColorModel() throws IOException {
    ComponentColorModel cm = mock(ComponentColorModel.class);
    ImageRawPNG irpng = mock(ImageRawPNG.class);
    PDFDocument doc = mock(PDFDocument.class);
    PDFProfile profile = mock(PDFProfile.class);
    ImageRawPNGAdapter irpnga = new ImageRawPNGAdapter(irpng, "mock");
    ImageSize is = RawPNGTestUtil.getImageSize();
    when(irpng.getColorModel()).thenReturn(cm);
    when(irpng.getRenderingIntent()).thenReturn(-1);
    when(cm.getNumComponents()).thenReturn(3);
    // when(cm.hasAlpha()).thenReturn(false);
    when(doc.getProfile()).thenReturn(profile);
    when(profile.getPDFAMode()).thenReturn(PDFAMode.PDFA_1A);
    when(irpng.getSize()).thenReturn(is);
    irpnga.setup(doc);
    FlateFilter filter = (FlateFilter) irpnga.getPDFFilter();
    assertEquals(3, filter.getColors());
}

7. TIFFImage#createAlphaComponentColorModel()

Project: xml-graphics-commons
File: TIFFImage.java
// Need a createColorModel().
// Create ComponentColorModel for TYPE_RGB images
private ComponentColorModel createAlphaComponentColorModel(int dataType, int numBands, boolean isAlphaPremultiplied, int transparency) {
    ComponentColorModel ccm = null;
    int[] rgbBits = null;
    ColorSpace cs = null;
    switch(numBands) {
        case // gray+alpha
        2:
            cs = ColorSpace.getInstance(ColorSpace.CS_GRAY);
            break;
        case // RGB+alpha
        4:
            cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
            break;
        default:
            throw new IllegalArgumentException(PropertyUtil.getString("TIFFImage19") + ": " + numBands);
    }
    int componentSize = 0;
    switch(dataType) {
        case DataBuffer.TYPE_BYTE:
            componentSize = 8;
            break;
        case DataBuffer.TYPE_USHORT:
        case DataBuffer.TYPE_SHORT:
            componentSize = 16;
            break;
        case DataBuffer.TYPE_INT:
            componentSize = 32;
            break;
        default:
            throw new IllegalArgumentException(PropertyUtil.getString("TIFFImage20") + ": " + dataType);
    }
    rgbBits = new int[numBands];
    for (int i = 0; i < numBands; i++) {
        rgbBits[i] = componentSize;
    }
    ccm = new ComponentColorModel(cs, rgbBits, true, isAlphaPremultiplied, transparency, dataType);
    return ccm;
}

8. EqualHashCodeTest#main()

Project: openjdk
File: EqualHashCodeTest.java
public static void main(String[] args) throws Exception {
    boolean passed = true;
    try {
        df1 = new DataFlavor("application/postscript");
        df2 = new DataFlavor("application/*");
    } catch (ClassNotFoundException e1) {
        throw new RuntimeException("Could not create DataFlavors. This should never happen.");
    } catch (IllegalArgumentException e2) {
        passed = false;
    }
    if (df1.hashCode() != df2.hashCode()) {
        passed = false;
    }
    dim1 = new Dimension(3, 18);
    dim2 = new Dimension(3, 18);
    if (dim1.hashCode() != dim2.hashCode()) {
        passed = false;
    }
    insets1 = new Insets(3, 4, 7, 11);
    insets2 = new Insets(3, 4, 7, 11);
    if (insets1.hashCode() != insets2.hashCode()) {
        passed = false;
    }
    cm1 = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), ColorModelBits, true, true, Transparency.OPAQUE, 0);
    cm2 = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), ColorModelBits, true, true, Transparency.OPAQUE, 0);
    if (cm1.hashCode() != cm2.hashCode()) {
        passed = false;
    }
    if (!passed)
        throw new RuntimeException("Test FAILED");
}

9. PNGRed#createComponentColorModel()

Project: xml-graphics-commons
File: PNGRed.java
/**
     * A convenience method to create an instance of
     * <code>ComponentColorModel</code> suitable for use with the
     * given <code>SampleModel</code>.  The <code>SampleModel</code>
     * should have a data type of <code>DataBuffer.TYPE_BYTE</code>,
     * <code>TYPE_USHORT</code>, or <code>TYPE_INT</code> and between
     * 1 and 4 bands.  Depending on the number of bands of the
     * <code>SampleModel</code>, either a gray, gray+alpha, rgb, or
     * rgb+alpha <code>ColorModel</code> is returned.
     */
public static ColorModel createComponentColorModel(SampleModel sm) {
    int type = sm.getDataType();
    int bands = sm.getNumBands();
    ComponentColorModel cm = null;
    if (type == DataBuffer.TYPE_BYTE) {
        switch(bands) {
            case 1:
                cm = colorModelGray8;
                break;
            case 2:
                cm = colorModelGrayAlpha8;
                break;
            case 3:
                cm = colorModelRGB8;
                break;
            case 4:
                cm = colorModelRGBA8;
                break;
        }
    } else if (type == DataBuffer.TYPE_USHORT) {
        switch(bands) {
            case 1:
                cm = colorModelGray16;
                break;
            case 2:
                cm = colorModelGrayAlpha16;
                break;
            case 3:
                cm = colorModelRGB16;
                break;
            case 4:
                cm = colorModelRGBA16;
                break;
        }
    } else if (type == DataBuffer.TYPE_INT) {
        switch(bands) {
            case 1:
                cm = colorModelGray32;
                break;
            case 2:
                cm = colorModelGrayAlpha32;
                break;
            case 3:
                cm = colorModelRGB32;
                break;
            case 4:
                cm = colorModelRGBA32;
                break;
        }
    }
    return cm;
}

10. PNGImageDecoder#createComponentColorModel()

Project: xml-graphics-commons
File: PNGImageDecoder.java
/**
     * A convenience method to create an instance of
     * <code>ComponentColorModel</code> suitable for use with the
     * given <code>SampleModel</code>.  The <code>SampleModel</code>
     * should have a data type of <code>DataBuffer.TYPE_BYTE</code>,
     * <code>TYPE_USHORT</code>, or <code>TYPE_INT</code> and between
     * 1 and 4 bands.  Depending on the number of bands of the
     * <code>SampleModel</code>, either a gray, gray+alpha, rgb, or
     * rgb+alpha <code>ColorModel</code> is returned.
     */
public static ColorModel createComponentColorModel(SampleModel sm) {
    int type = sm.getDataType();
    int bands = sm.getNumBands();
    ComponentColorModel cm = null;
    if (type == DataBuffer.TYPE_BYTE) {
        switch(bands) {
            case 1:
                cm = colorModelGray8;
                break;
            case 2:
                cm = colorModelGrayAlpha8;
                break;
            case 3:
                cm = colorModelRGB8;
                break;
            case 4:
                cm = colorModelRGBA8;
                break;
        }
    } else if (type == DataBuffer.TYPE_USHORT) {
        switch(bands) {
            case 1:
                cm = colorModelGray16;
                break;
            case 2:
                cm = colorModelGrayAlpha16;
                break;
            case 3:
                cm = colorModelRGB16;
                break;
            case 4:
                cm = colorModelRGBA16;
                break;
        }
    } else if (type == DataBuffer.TYPE_INT) {
        switch(bands) {
            case 1:
                cm = colorModelGray32;
                break;
            case 2:
                cm = colorModelGrayAlpha32;
                break;
            case 3:
                cm = colorModelRGB32;
                break;
            case 4:
                cm = colorModelRGBA32;
                break;
        }
    }
    return cm;
}

11. VlcjDirectTest#convert()

Project: webcam-capture
File: VlcjDirectTest.java
private static BufferedImage convert(Memory[] buffers, BufferFormat format) {
    if (buffers.length == 0) {
        throw new RuntimeException("No memory elements found!");
    }
    final Memory memory = buffers[0];
    if (memory == null) {
        throw new RuntimeException("Null memory!");
    }
    final int width = format.getWidth();
    final int height = format.getHeight();
    final int dataType = DataBuffer.TYPE_BYTE;
    final int pixelStride = 4;
    final int scanlineStride = width * pixelStride;
    final int[] bgrBandOffsets = new int[] { 2, 1, 0 };
    final int[] bits = { 8, 8, 8 };
    final int[] offsets = new int[] { 0 };
    final int transparency = Transparency.OPAQUE;
    final byte[] bytes = new byte[scanlineStride * height];
    final byte[][] data = new byte[][] { bytes };
    memory.getByteBuffer(0, memory.size()).get(bytes);
    ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
    ComponentSampleModel sampleModel = new ComponentSampleModel(dataType, width, height, pixelStride, scanlineStride, bgrBandOffsets);
    ComponentColorModel colorModel = new ComponentColorModel(colorSpace, bits, false, false, transparency, dataType);
    DataBufferByte dataBuffer = new DataBufferByte(data, bytes.length, offsets);
    WritableRaster raster = Raster.createWritableRaster(sampleModel, dataBuffer, null);
    BufferedImage image = new BufferedImage(colorModel, raster, false, null);
    image.flush();
    return image;
}

12. WebcamDefaultDevice#open()

Project: webcam-capture
File: WebcamDefaultDevice.java
@Override
public void open() {
    if (disposed.get()) {
        return;
    }
    LOG.debug("Opening webcam device {}", getName());
    if (size == null) {
        size = getResolutions()[0];
    }
    if (size == null) {
        throw new RuntimeException("The resolution size cannot be null");
    }
    LOG.debug("Webcam device {} starting session, size {}", device.getIdentifierStr(), size);
    grabber = new OpenIMAJGrabber();
    // NOTE!
    // Following the note from OpenIMAJ code - it seams like there is some
    // issue on 32-bit systems which prevents grabber to find devices.
    // According to the mentioned note this for loop shall fix the problem.
    DeviceList list = grabber.getVideoDevices().get();
    for (Device d : list.asArrayList()) {
        d.getNameStr();
        d.getIdentifierStr();
    }
    boolean started = grabber.startSession(size.width, size.height, 50, Pointer.pointerTo(device));
    if (!started) {
        throw new WebcamException("Cannot start native grabber!");
    }
    // set timeout, this MUST be done after grabber is open and before it's closed, otherwise it
    // will result as crash
    grabber.setTimeout(timeout);
    LOG.debug("Webcam device session started");
    Dimension size2 = new Dimension(grabber.getWidth(), grabber.getHeight());
    int w1 = size.width;
    int w2 = size2.width;
    int h1 = size.height;
    int h2 = size2.height;
    if (w1 != w2 || h1 != h2) {
        if (failOnSizeMismatch) {
            throw new WebcamException(String.format("Different size obtained vs requested - [%dx%d] vs [%dx%d]", w1, h1, w2, h2));
        }
        Object[] args = new Object[] { w1, h1, w2, h2, w2, h2 };
        LOG.warn("Different size obtained vs requested - [{}x{}] vs [{}x{}]. Setting correct one. New size is [{}x{}]", args);
        size = new Dimension(w2, h2);
    }
    smodel = new ComponentSampleModel(DATA_TYPE, size.width, size.height, 3, size.width * 3, BAND_OFFSETS);
    cmodel = new ComponentColorModel(COLOR_SPACE, BITS, false, false, Transparency.OPAQUE, DATA_TYPE);
    // clear device memory buffer
    LOG.debug("Clear memory buffer");
    clearMemoryBuffer();
    // set device to open
    LOG.debug("Webcam device {} is now open", this);
    open.set(true);
    // start underlying frames refresher
    refresher = startFramesRefresher();
}

13. ImageRawPNGAdapterTestCase#testRenderingIntentImpliessRGBColorProfile()

Project: fop
File: ImageRawPNGAdapterTestCase.java
@Test
public void testRenderingIntentImpliessRGBColorProfile() {
    ComponentColorModel cm = mock(ComponentColorModel.class);
    ImageRawPNG irpng = mock(ImageRawPNG.class);
    PDFDocument doc = mock(PDFDocument.class);
    PDFProfile profile = mock(PDFProfile.class);
    PDFResources resources = mock(PDFResources.class);
    PDFICCBasedColorSpace cs = mock(PDFICCBasedColorSpace.class);
    PDFICCStream stream = mock(PDFICCStream.class);
    ICC_Profile iccprof = ICC_Profile.getInstance(ColorSpace.CS_sRGB);
    ImageRawPNGAdapter irpnga = new ImageRawPNGAdapter(irpng, "mock");
    ImageSize is = RawPNGTestUtil.getImageSize();
    when(irpng.getColorModel()).thenReturn(cm);
    when(irpng.getRenderingIntent()).thenReturn(0);
    when(cm.getNumComponents()).thenReturn(3);
    // when(cm.hasAlpha()).thenReturn(false);
    when(doc.getProfile()).thenReturn(profile);
    when(doc.getResources()).thenReturn(resources);
    when(resources.getICCColorSpaceByProfileName("sRGB")).thenReturn(cs);
    when(profile.getPDFAMode()).thenReturn(PDFAMode.PDFA_1A);
    when(irpng.getSize()).thenReturn(is);
    when(cs.getICCStream()).thenReturn(stream);
    when(stream.getICCProfile()).thenReturn(iccprof);
    irpnga.setup(doc);
    PDFICCStream iccStream = irpnga.getICCStream();
    assertTrue(ColorProfileUtil.isDefaultsRGB(iccStream.getICCProfile()));
}

14. ImageRawPNGAdapterTestCase#testOutputContentsWithGRGBAPNG()

Project: fop
File: ImageRawPNGAdapterTestCase.java
private void testOutputContentsWithGRGBAPNG(int gray, int red, int green, int blue, int alpha) throws IOException {
    int numColorComponents = gray > -1 ? 1 : 3;
    int numComponents = numColorComponents + (alpha > -1 ? 1 : 0);
    ComponentColorModel cm = mock(ComponentColorModel.class);
    ImageRawPNG irpng = mock(ImageRawPNG.class);
    PDFDocument doc = mock(PDFDocument.class);
    PDFProfile profile = mock(PDFProfile.class);
    ImageRawPNGAdapter irpnga = new ImageRawPNGAdapter(irpng, "mock");
    ImageSize is = RawPNGTestUtil.getImageSize();
    when(irpng.getColorModel()).thenReturn(cm);
    when(irpng.getRenderingIntent()).thenReturn(-1);
    when(cm.getNumComponents()).thenReturn(numComponents);
    // when(cm.hasAlpha()).thenReturn(false);
    when(doc.getProfile()).thenReturn(profile);
    when(profile.getPDFAMode()).thenReturn(PDFAMode.PDFA_1A);
    when(irpng.getSize()).thenReturn(is);
    irpnga.setup(doc);
    FlateFilter filter = (FlateFilter) irpnga.getPDFFilter();
    assertEquals(numColorComponents, filter.getColors());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] data = RawPNGTestUtil.buildGRGBAData(gray, red, green, blue, alpha);
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    when(irpng.createInputStream()).thenReturn(bais);
    irpnga.outputContents(baos);
    if (alpha > -1) {
        byte[] expected = RawPNGTestUtil.buildGRGBAData(gray, red, green, blue, -1);
        assertArrayEquals(expected, baos.toByteArray());
    } else {
        assertArrayEquals(data, baos.toByteArray());
    }
}

15. PNGRed#createComponentColorModel()

Project: batik
File: PNGRed.java
/**
     * A convenience method to create an instance of
     * <code>ComponentColorModel</code> suitable for use with the
     * given <code>SampleModel</code>.  The <code>SampleModel</code>
     * should have a data type of <code>DataBuffer.TYPE_BYTE</code>,
     * <code>TYPE_USHORT</code>, or <code>TYPE_INT</code> and between
     * 1 and 4 bands.  Depending on the number of bands of the
     * <code>SampleModel</code>, either a gray, gray+alpha, rgb, or
     * rgb+alpha <code>ColorModel</code> is returned.
     */
public static ColorModel createComponentColorModel(SampleModel sm) {
    int type = sm.getDataType();
    int bands = sm.getNumBands();
    ComponentColorModel cm = null;
    if (type == DataBuffer.TYPE_BYTE) {
        switch(bands) {
            case 1:
                cm = colorModelGray8;
                break;
            case 2:
                cm = colorModelGrayAlpha8;
                break;
            case 3:
                cm = colorModelRGB8;
                break;
            case 4:
                cm = colorModelRGBA8;
                break;
        }
    } else if (type == DataBuffer.TYPE_USHORT) {
        switch(bands) {
            case 1:
                cm = colorModelGray16;
                break;
            case 2:
                cm = colorModelGrayAlpha16;
                break;
            case 3:
                cm = colorModelRGB16;
                break;
            case 4:
                cm = colorModelRGBA16;
                break;
        }
    } else if (type == DataBuffer.TYPE_INT) {
        switch(bands) {
            case 1:
                cm = colorModelGray32;
                break;
            case 2:
                cm = colorModelGrayAlpha32;
                break;
            case 3:
                cm = colorModelRGB32;
                break;
            case 4:
                cm = colorModelRGBA32;
                break;
        }
    }
    return cm;
}

16. PNGImageDecoder#createComponentColorModel()

Project: batik
File: PNGImageDecoder.java
/**
     * A convenience method to create an instance of
     * <code>ComponentColorModel</code> suitable for use with the
     * given <code>SampleModel</code>.  The <code>SampleModel</code>
     * should have a data type of <code>DataBuffer.TYPE_BYTE</code>,
     * <code>TYPE_USHORT</code>, or <code>TYPE_INT</code> and between
     * 1 and 4 bands.  Depending on the number of bands of the
     * <code>SampleModel</code>, either a gray, gray+alpha, rgb, or
     * rgb+alpha <code>ColorModel</code> is returned.
     */
public static ColorModel createComponentColorModel(SampleModel sm) {
    int type = sm.getDataType();
    int bands = sm.getNumBands();
    ComponentColorModel cm = null;
    if (type == DataBuffer.TYPE_BYTE) {
        switch(bands) {
            case 1:
                cm = colorModelGray8;
                break;
            case 2:
                cm = colorModelGrayAlpha8;
                break;
            case 3:
                cm = colorModelRGB8;
                break;
            case 4:
                cm = colorModelRGBA8;
                break;
        }
    } else if (type == DataBuffer.TYPE_USHORT) {
        switch(bands) {
            case 1:
                cm = colorModelGray16;
                break;
            case 2:
                cm = colorModelGrayAlpha16;
                break;
            case 3:
                cm = colorModelRGB16;
                break;
            case 4:
                cm = colorModelRGBA16;
                break;
        }
    } else if (type == DataBuffer.TYPE_INT) {
        switch(bands) {
            case 1:
                cm = colorModelGray32;
                break;
            case 2:
                cm = colorModelGrayAlpha32;
                break;
            case 3:
                cm = colorModelRGB32;
                break;
            case 4:
                cm = colorModelRGBA32;
                break;
        }
    }
    return cm;
}