Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit pixel values

Tags:

java

image

pixel

How to edit pixel values of an image in Java. Is there any method to change pixel values?

like image 442
swaroop_ps Avatar asked Apr 18 '11 11:04

swaroop_ps


2 Answers

For example:

BufferedImage image = ...
image.setRGB(x, y, 0);

From documentation:

 void setRGB(int x, int y, int rgb)
 //Sets a pixel in this BufferedImage to the specified RGB value.
like image 68
lukastymo Avatar answered Sep 27 '22 23:09

lukastymo


In BufferedImage: public void setRGB(int x, int y, int rgb)

Sets a pixel in this BufferedImage to the specified RGB value. The pixel is assumed to be in the default RGB color model, TYPE_INT_ARGB, and default sRGB color space. For images with an IndexColorModel, the index with the nearest color is chosen.

http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html

like image 38
jzd Avatar answered Sep 27 '22 22:09

jzd