【发布时间】:2017-09-16 20:18:26
【问题描述】:
我正在制作一个程序,从图像中提取像素数组,取出 ARGB 值。并将它们再次写回以制作另一个图像。
BufferedImage imagebuffer = ImageIO.read(new File("C:\\Users\\Ramandeep\\Downloads\\w3.jpg"));
iw = imagebuffer.getWidth();
ih = imagebuffer.getHeight();
pixels = new int[iw * ih];
PixelGrabber pg = new PixelGrabber(imagebuffer, 0, 0, iw, ih, pixels, 0, iw);
pg.grabPixels();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
image.setRGB(0, 0, width, height, pixels, 0, width);
ImageIO.write(image, "jpg", new File("C:\\Users\\Ramandeep\\Desktop\\out.jpg"));
ImageIO.write(image, "gif", new File("C:\\Users\\Ramandeep\\Desktop\\out.gif"));
ImageIO.write(image, "png", new File("C:\\Users\\Ramandeep\\Desktop\\out.png"));
现在 png 和 gif 的输出图像看起来不错,但输出的 jpg 图像却偏红。
知道是什么原因造成的吗?任何朝着正确方向的推动将不胜感激。
【问题讨论】:
-
您尝试的图像处理应该达到什么程度?
-
嗯,我正在努力使用 LSB 替换方法在图像中嵌入纯文本消息。但在此之前,我只是尝试简单地在新图像中写入像素以使其不碍事。
-
为什么不用图形?
-
嗯。我想,我不知道那堂课。它是否有适当的方法来获取像素数组,反之亦然?你能指出我在某个地方的一个工作示例吗?那很好啊。或者我会仔细研究文档 xD
标签: java image image-processing jpeg