File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Image from Canvas Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Image from Canvas" Watch "Image from Canvas" New topic

Image from Canvas

manu g

Joined: Mar 18, 2001
Posts: 5
i have drawn an image in canvas,now i want to make it as an image so that i be able to extract the pixel information from it,how can i make an Image object from the information in canvas
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at . We require names to have at least two words (single letters are not permited), separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

The way I would do it is use the createImage( x, y ) method in Component to create a "back buffer" image ( normally used in double buffering ) that you do all the drawing to in your paint method. Then, at the end of the paint method, you simply do a g.drawImage( buffer, 0, 0, this ) to draw to the screen. You would also have a reference to the image being shown on the screen.

[This message has been edited by Nathan Pruett (edited April 12, 2001).]

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: Image from Canvas
It's not a secret anymore!