Results 1 to 2 of 2
Thread: ImageIO question
- 12-23-2011, 07:08 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 1
- Rep Power
- 0
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 java.io.File; import java.io.IOException; 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) { e.printStackTrace(); } } public static void main(String args[]) { ImageTest test = new ImageTest(); } }Last edited by lordsurya08; 12-23-2011 at 07:20 AM.
- 12-23-2011, 07:17 AM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Similar Threads
-
JPEGCodec and ImageIO
By Lacrim in forum Advanced JavaReplies: 0Last Post: 12-14-2011, 02:57 PM -
Error with ImageIO
By stegano in forum New To JavaReplies: 4Last Post: 03-31-2011, 03:59 PM -
BufferedImage, ImageIO and Jar files
By satory in forum New To JavaReplies: 6Last Post: 05-23-2010, 12:07 AM -
Trouble with ImageIO
By sari in forum New To JavaReplies: 1Last Post: 03-30-2009, 09:42 PM -
Help with ImageIO
By romina in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 05:21 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks