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

Convert image to bufferedImage  RSS feed

Sandy Abraham
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's an error when i try to convert my image to a buffered image, so that I can getRaster().
My code is:
Toolkit toolkit = Toolkit.getDefaultToolkit();
image = toolkit.getImage("Image2.jpg");
BufferedImage sourceBufferedImage =new BufferedImage(image.getWidth(null),image.getHeight(null),BufferedImage.TYPE_INT_ARGB);
The error is :
Exception in thread "main" java.lang.IllegalArgumentException: Width (-1) and he
ight (-1) cannot be <= 0
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Direct
at java.awt.image.BufferedImage.<init>(
at Joan$MyCanvas.<init>(
at Joan.setupPanels(
at Joan.<init>(
at Joan.main(

What is the problem? Please help.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!