This question already has answers here:
Can't read and write a TIFF image file using Java ImageIO standard library

(5个答案)


3年前关闭。




这段代码提供了一个空的tiff文件,我不明白为什么。
g在其中的Canvas显示该行。

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);}...
}

最佳答案

尝试在绘制之前设置颜色:

g2d.setColor(Color.WHITE);

关于java - Java,保存tiff文件,始终为空? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40566849/

10-13 07:29