• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image from Canvas

 
manu g
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . 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.
Thanks.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manu,
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.

HTH,
-Nate
[This message has been edited by Nathan Pruett (edited April 12, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic