Results 1 to 2 of 2
  1. #1
    lordsurya08 is offline Member
    Join Date
    Dec 2011
    Rep Power

    Default ImageIO question

    SOLVED - wrong filename. I used test.png instead of src/test.png.

    Here's a piece of test code that simply draws a line on a newly created image and then puts the image into a png file. The png file is white in the beginning and no line appears after the program ends. Any idea why?

    Java Code:
    import java.awt.*;
    import java.awt.image.*;
    import javax.imageio.ImageIO;
    public class ImageTest
    	public ImageTest()
    		BufferedImage bi = new BufferedImage(512, 512, BufferedImage.TYPE_INT_RGB);
    		Graphics2D g = bi.createGraphics();
    		g.drawLine(0, 0, 444, 444);
    		File out = new File("test.png");
    		try {
    			ImageIO.write(bi, "png", out);
    		} catch (IOException e) {
    	public static void main(String args[])
    		ImageTest test = new ImageTest();
    Last edited by lordsurya08; 12-23-2011 at 07:20 AM.

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Rep Power

    Default Re: ImageIO question

    ImageIO question-test.png
    Thats my result of your code. The code looks right for me, should work

Similar Threads

  1. JPEGCodec and ImageIO
    By Lacrim in forum Advanced Java
    Replies: 0
    Last Post: 12-14-2011, 02:57 PM
  2. Error with ImageIO
    By stegano in forum New To Java
    Replies: 4
    Last Post: 03-31-2011, 03:59 PM
  3. BufferedImage, ImageIO and Jar files
    By satory in forum New To Java
    Replies: 6
    Last Post: 05-23-2010, 12:07 AM
  4. Trouble with ImageIO
    By sari in forum New To Java
    Replies: 1
    Last Post: 03-30-2009, 09:42 PM
  5. Help with ImageIO
    By romina in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 05:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts