0

This code provides an empty tiff file, I do not understand why. The Canvas in which g is shows the line.

private BufferedImage bImage;
Graphics2D g2d;
public void paint(Graphics g) {
    g2d = (Graphics2D)g;
    bImage = new BufferedImage(sX, sY, BufferedImage.TYPE_INT_RGB); 
    g2d = bImage.createGraphics();
    g2d.drawLine(a,b,c,d);
    g.drawLine(a,b,c,d);
    try { ImageIO.write(bImage, "tiff", saveFile);}...
}
Charles Mosndup
  • 600
  • 6
  • 19

3 Answers3

1

Try setting a color before drawing:

g2d.setColor(Color.WHITE);
Quagaar
  • 1,257
  • 12
  • 21
0

I found that ImageIO.write(bImage, "tiff", saveFile); returns false.

Javadoc says:Returns : false if no appropriate writer is found.

Question: What means no appropriate writer found?

Charles Mosndup
  • 600
  • 6
  • 19
0

Finally solved this problem.

1- install java SE8

2- load library jai_imageio-1.1.jar in build path

Charles Mosndup
  • 600
  • 6
  • 19