【发布时间】:2019-12-20 15:21:53
【问题描述】:
原创
https://drive.google.com/file/d/1B3xxfWkGsMs2_MQ_bUQ8_ALYI0DL-LIo/view?usp=sharing
保存到文件时
https://drive.google.com/file/d/1z5euXupeHmiFebch4A39fVqGukoUiK0p/view?usp=sharing
当打印到画布上时
https://drive.google.com/file/d/1VouD-ygf0pPXFFx9Knr4pv44FHMtoqcV/view?usp=sharing
BufferedImage temp = bImg.getSubimage(100, 100, (int)imgWidth - 100, (int)imgHeight - 100);
try{
ImageIO.write(temp, "png", new File("test.png"));
}catch(Exception e){
e.printStackTrace();
}
gc.drawImage(SwingFXUtils.toFXImage(temp, null), 100, 100);
由于某种原因,如果我将图像打印到画布上,与将相同图像保存到文件中的情况不同。当我将它保存到一个文件时,它会正确计算 subImage 但是当我将它打印到画布上时,它会忽略我给它的 x 和 y 坐标,并使用 (0,0) 作为 (x,y) 给定宽度的 subImage和高度。
【问题讨论】:
标签: java javafx bufferedimage