Solved

URGENT:Changing Pixels within an image at run-time

Posted on 2003-12-06
8
200 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
  • 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

777 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