1 Reply Latest reply: Aug 2, 2009 10:25 AM by 793415 RSS

    trying to create an image and save it on file system

    800574
      Hi,
      I'm trying to create an image and save it in the file system :

           public static void main(String[] args) {
           int wid = 632;
           int hgt = 864;
           BufferedImage bufferedImage = new BufferedImage(wid,hgt,BufferedImage.TYPE_INT_RGB);
           bufferedImage.getGraphics().setColor(Color.black);
           bufferedImage.getGraphics().drawOval(30, 30, 100, 100);
                bufferedImage.getGraphics().drawString("test me one two three",2,2);
                bufferedImage.flush();
      try {
                     ImageIO.write(bufferedImage,".bmp",new File("C:/MyImage.bmp"));
                     
           } catch (IOException e) {               
                     e.printStackTrace();
                }
      }

      THE PROBLEM : It creates C:/MyImage.bmp on my file system, but the file is empty (size 0).
      Am I missing something ?

      Thanks