Here you can find the source of toRgbPixels(BufferedImage image)
public static int[] toRgbPixels(BufferedImage image)
//package com.java2s; //License from project: Apache License import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; public class Main { public static int[] toRgbPixels(BufferedImage image) { if (image.getData().getDataBuffer() instanceof DataBufferInt) { return ((DataBufferInt) image.getData().getDataBuffer()).getData(); } else {//from w ww .ja va 2 s .c o m return image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth()); } } }