Search in sources :

Example 16 with DirectColorModel

use of java.awt.image.DirectColorModel in project jdk8u_jdk by JetBrains.

the class ImageRepresentation method getOpaqueRGBImage.

public BufferedImage getOpaqueRGBImage() {
    if (bimage.getType() == BufferedImage.TYPE_INT_ARGB) {
        int w = bimage.getWidth();
        int h = bimage.getHeight();
        int size = w * h;
        // Note that we steal the data array here, but only for reading...
        DataBufferInt db = (DataBufferInt) biRaster.getDataBuffer();
        int[] pixels = SunWritableRaster.stealData(db, 0);
        for (int i = 0; i < size; i++) {
            if ((pixels[i] >>> 24) != 0xff) {
                return bimage;
            }
        }
        ColorModel opModel = new DirectColorModel(24, 0x00ff0000, 0x0000ff00, 0x000000ff);
        int[] bandmasks = { 0x00ff0000, 0x0000ff00, 0x000000ff };
        WritableRaster opRaster = Raster.createPackedRaster(db, w, h, w, bandmasks, null);
        try {
            BufferedImage opImage = createImage(opModel, opRaster, false, null);
            return opImage;
        } catch (Exception e) {
            return bimage;
        }
    }
    return bimage;
}
Also used : DirectColorModel(java.awt.image.DirectColorModel) ColorModel(java.awt.image.ColorModel) IndexColorModel(java.awt.image.IndexColorModel) WritableRaster(java.awt.image.WritableRaster) DirectColorModel(java.awt.image.DirectColorModel) DataBufferInt(java.awt.image.DataBufferInt) BufferedImage(java.awt.image.BufferedImage) AWTException(java.awt.AWTException)

Example 17 with DirectColorModel

use of java.awt.image.DirectColorModel in project jdk8u_jdk by JetBrains.

the class CGLGraphicsConfig method createCompatibleImage.

@Override
public BufferedImage createCompatibleImage(int width, int height) {
    ColorModel model = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    WritableRaster raster = model.createCompatibleWritableRaster(width, height);
    return new BufferedImage(model, raster, model.isAlphaPremultiplied(), null);
}
Also used : DirectColorModel(java.awt.image.DirectColorModel) ColorModel(java.awt.image.ColorModel) WritableRaster(java.awt.image.WritableRaster) DirectColorModel(java.awt.image.DirectColorModel) BufferedImage(java.awt.image.BufferedImage)

Example 18 with DirectColorModel

use of java.awt.image.DirectColorModel in project chipKIT32-MAX by chipKIT32.

the class PGraphics2D method allocate.

//public void setParent(PApplet parent)
//public void setPrimary(boolean primary)
//public void setPath(String path)
//public void setSize(int iwidth, int iheight)
protected void allocate() {
    pixelCount = width * height;
    pixels = new int[pixelCount];
    if (primarySurface) {
        cm = new DirectColorModel(32, 0x00ff0000, 0x0000ff00, 0x000000ff);
        ;
        mis = new MemoryImageSource(width, height, pixels, 0, width);
        mis.setFullBufferUpdates(true);
        mis.setAnimated(true);
        image = Toolkit.getDefaultToolkit().createImage(mis);
    }
}
Also used : DirectColorModel(java.awt.image.DirectColorModel) MemoryImageSource(java.awt.image.MemoryImageSource)

Example 19 with DirectColorModel

use of java.awt.image.DirectColorModel in project jdk8u_jdk by JetBrains.

the class GLXGraphicsConfig method createCompatibleImage.

@Override
public BufferedImage createCompatibleImage(int width, int height) {
    ColorModel model = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    WritableRaster raster = model.createCompatibleWritableRaster(width, height);
    return new BufferedImage(model, raster, model.isAlphaPremultiplied(), null);
}
Also used : DirectColorModel(java.awt.image.DirectColorModel) ColorModel(java.awt.image.ColorModel) WritableRaster(java.awt.image.WritableRaster) DirectColorModel(java.awt.image.DirectColorModel) BufferedImage(java.awt.image.BufferedImage)

Example 20 with DirectColorModel

use of java.awt.image.DirectColorModel in project jdk8u_jdk by JetBrains.

the class WritableRasterNative method createNativeRaster.

public static WritableRasterNative createNativeRaster(ColorModel cm, SurfaceData sd, int width, int height) {
    SampleModel smHw = null;
    int dataType = 0;
    int scanStride = width;
    switch(cm.getPixelSize()) {
        case 8:
        case 12:
            // 8-bits uses PixelInterleavedSampleModel
            if (cm.getPixelSize() == 8) {
                dataType = DataBuffer.TYPE_BYTE;
            } else {
                dataType = DataBuffer.TYPE_USHORT;
            }
            int[] bandOffsets = new int[1];
            bandOffsets[0] = 0;
            smHw = new PixelInterleavedSampleModel(dataType, width, height, 1, scanStride, bandOffsets);
            break;
        // all others use SinglePixelPackedSampleModel
        case 15:
        case 16:
            dataType = DataBuffer.TYPE_USHORT;
            int[] bitMasks = new int[3];
            DirectColorModel dcm = (DirectColorModel) cm;
            bitMasks[0] = dcm.getRedMask();
            bitMasks[1] = dcm.getGreenMask();
            bitMasks[2] = dcm.getBlueMask();
            smHw = new SinglePixelPackedSampleModel(dataType, width, height, scanStride, bitMasks);
            break;
        case 24:
        case 32:
            dataType = DataBuffer.TYPE_INT;
            bitMasks = new int[3];
            dcm = (DirectColorModel) cm;
            bitMasks[0] = dcm.getRedMask();
            bitMasks[1] = dcm.getGreenMask();
            bitMasks[2] = dcm.getBlueMask();
            smHw = new SinglePixelPackedSampleModel(dataType, width, height, scanStride, bitMasks);
            break;
        default:
            throw new InternalError("Unsupported depth " + cm.getPixelSize());
    }
    DataBuffer dbn = new DataBufferNative(sd, dataType, width, height);
    return new WritableRasterNative(smHw, dbn);
}
Also used : PixelInterleavedSampleModel(java.awt.image.PixelInterleavedSampleModel) SinglePixelPackedSampleModel(java.awt.image.SinglePixelPackedSampleModel) PixelInterleavedSampleModel(java.awt.image.PixelInterleavedSampleModel) SampleModel(java.awt.image.SampleModel) DirectColorModel(java.awt.image.DirectColorModel) SinglePixelPackedSampleModel(java.awt.image.SinglePixelPackedSampleModel) Point(java.awt.Point) DataBuffer(java.awt.image.DataBuffer)

Aggregations

DirectColorModel (java.awt.image.DirectColorModel)24 ColorModel (java.awt.image.ColorModel)15 IndexColorModel (java.awt.image.IndexColorModel)15 WritableRaster (java.awt.image.WritableRaster)12 BufferedImage (java.awt.image.BufferedImage)10 SinglePixelPackedSampleModel (java.awt.image.SinglePixelPackedSampleModel)7 Point (java.awt.Point)6 ComponentColorModel (java.awt.image.ComponentColorModel)6 SampleModel (java.awt.image.SampleModel)6 DataBufferInt (java.awt.image.DataBufferInt)5 ColorSpace (java.awt.color.ColorSpace)4 MultiPixelPackedSampleModel (java.awt.image.MultiPixelPackedSampleModel)4 ComponentSampleModel (java.awt.image.ComponentSampleModel)3 DataBuffer (java.awt.image.DataBuffer)3 Rectangle (java.awt.Rectangle)2 DataBufferByte (java.awt.image.DataBufferByte)2 PixelInterleavedSampleModel (java.awt.image.PixelInterleavedSampleModel)2 Raster (java.awt.image.Raster)2 IOException (java.io.IOException)2 PaletteData (org.eclipse.swt.graphics.PaletteData)2