2 回答
TA贡献1887条经验 获得超5个赞
我遵循了您描述的代码(谢谢,因为它帮助我分析了我面临的问题,并且我遵循了类似的方法),在对 Java 代码进行以下更改后,我使图像与原始图像完全相同
int width = imageDetail.getWidth();
int height = imageDetail.getHeight();
byte[] data = imageDetail.getByteData();
String name = imageDetail.getName();
BufferedImage bufferedImage =new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int o = (x * 4) + (y * width * 4);
bufferedImage.setRGB(x, y, new Color(data[o] & 0xFF, data[o + 1] & 0xFF, data[o + 2] & 0xFF).getRGB());
}
}
try {
ImageIO.write(bufferedImage, "jpg", new File(PDFReportingUtil.baseReportFolderLocation+name+".jpg"));
} catch (IOException e) {
PDFReportingUtil.logger.error("Error while executing the thread "+Thread.currentThread().getName()+" ",e);
}
添加回答
举报