List of usage examples for java.awt.image DirectColorModel getDataElement
public int getDataElement(int[] components, int offset)
From source file:SampleAWTRenderer.java
private int[] processImage(Buffer buf) { int[] data = (int[]) buf.getData(); int[] ret = new int[data.length]; RGBFormat fmt = (RGBFormat) buf.getFormat(); DirectColorModel dcm = new DirectColorModel(fmt.getBitsPerPixel(), fmt.getRedMask(), fmt.getGreenMask(), fmt.getBlueMask());//from w ww. jav a 2 s .co m int[] rgb; int k; for (int i = 0; i < data.length; i++) { rgb = dcm.getComponents(data[i], null, 0); k = toGray(rgb); rgb[0] = rgb[1] = rgb[2] = k; ret[i] = dcm.getDataElement(rgb, 0); } return ret; }