Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Image and BufferedImage  RSS feed

 
Wael Atef
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i have a java.awt.Image object and want to convert it to java.awt.image.BufferedImage object.How can i perform that? thanks
 
Chella Anu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To convert Image to BufferedImage:
Create an instance of Buffered Image with the width,height of Image
BufferedImage bufImg=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
Create Graphics and draw the image
java.awt.Graphics2D grap=bufImg.createGraphics();
grap.drawImage(img,null,null);
grap.dispose();
 
Wael Atef
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you, i tried this solution but it's somewhat slow. is there another solution which is more faster.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!