Example usage for java.awt.image DirectColorModel createCompatibleSampleModel

List of usage examples for java.awt.image DirectColorModel createCompatibleSampleModel

Introduction

In this page you can find the example usage for java.awt.image DirectColorModel createCompatibleSampleModel.

Prototype

public SampleModel createCompatibleSampleModel(int w, int h) 

Source Link

Document

Creates a SampleModel with the specified width and height that has a data layout compatible with this ColorModel .

Usage

From source file:de.mfo.jsurf.grid.RotationGrid.java

static BufferedImage createBufferedImageFromRGB(ImgBuffer ib) {
    int w = ib.width;
    int h = ib.height;

    DirectColorModel colormodel = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
    SampleModel sampleModel = colormodel.createCompatibleSampleModel(w, h);
    DataBufferInt data = new DataBufferInt(ib.rgbBuffer, w * h);
    WritableRaster raster = WritableRaster.createWritableRaster(sampleModel, data, new Point(0, 0));
    return new BufferedImage(colormodel, raster, false, null);
}