Here you can find the source of setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels)
Parameter | Description |
---|---|
image | a BufferedImage object |
x | the left edge of the pixel block |
y | the right edge of the pixel block |
width | the width of the pixel arry |
height | the height of the pixel arry |
pixels | the array of pixels to set |
public static void setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels)
//package com.java2s; //License from project: Apache License import java.awt.image.*; public class Main { /**/* w w w . j av a2 s . c o m*/ * A convenience method for setting ARGB pixels in an image. This tries to avoid the performance * penalty of BufferedImage.setRGB unmanaging the image. * @param image a BufferedImage object * @param x the left edge of the pixel block * @param y the right edge of the pixel block * @param width the width of the pixel arry * @param height the height of the pixel arry * @param pixels the array of pixels to set * @see #getRGB */ public static void setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) { int type = image.getType(); if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB) image.getRaster().setDataElements(x, y, width, height, pixels); else image.setRGB(x, y, width, height, pixels, 0, width); } }