Solved

URGENT:Changing Pixels within an image at run-time

Posted on 2003-12-06
8
204 Views
Last Modified: 2010-03-31
Hi,
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.

Thanks,
0
Comment
Question by:miteshn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 9888548
You can use a PixelGrabber to get the pixels:

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/PixelGrabber.html
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9888553
You can also work with an ImageFilter:

http://javaalmanac.com/egs/java.awt.image/FilterRgb.html
0
 

Author Comment

by:miteshn
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?

thanks
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 92

Accepted Solution

by:
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.
0
 
LVL 92

Expert Comment

by:objects
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);

0
 
LVL 86

Assisted Solution

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

BufferedImage image = ImageIO.read(new File("x.jpg"));
   
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9892090
8-)
0
 
LVL 92

Expert Comment

by:objects
ID: 9892999
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

622 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