URGENT:Changing Pixels within an image at run-time

Posted on 2003-12-06
Last Modified: 2010-03-31
In my code, I am using an image of size 200*200. At run-time, I am calculating new values for a pixel, and need to change a few of the pixels. So, on my display, I only want to change the values of the changed pixels instead of drawing the entire image again. How can I do it in Java. What are the data types will i have to use?

This is an extremely urgent question. I need an answer as soon as possible.

Question by:miteshn
  • 4
  • 3
LVL 86

Expert Comment

ID: 9888548
You can use a PixelGrabber to get the pixels:
LVL 86

Expert Comment

ID: 9888553
You can also work with an ImageFilter:

Author Comment

ID: 9889986
If I have my Image on a form, how do I reflect the changes on the image? I do not want to redraw the entire form. using Pixel grabber or ImageFilter, I can change the array values, but how do i reflect these changes on screen?

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

LVL 92

Accepted Solution

objects earned 250 total points
ID: 9890180
Use a BufferedImage, it allows you to change individual pixel values.
Then call repaint() on the component displaying the image to show changes on screen.
LVL 92

Expert Comment

ID: 9890488
eg. if the image was painted at the origin of your component and you wanted to change the pixel at 10, 10:

mybufferedimage.setRGB(10, 10, rgb);
repaint(10, 10, 1, 1);

LVL 86

Assisted Solution

CEHJ earned 250 total points
ID: 9891866
If you want to use a BufferedImage, the easiest way to get one is:

BufferedImage image = File("x.jpg"));
LVL 86

Expert Comment

ID: 9892090
LVL 92

Expert Comment

ID: 9892999

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Oracle SQL syntax check  without executing 6 75
What's wrong with this code? 4 26
ejb mdb examples 1 8
Is there a simpler dropbox system? 10 34
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question