如何从包含像素的数组创建BufferedImage? [英] How do I create a BufferedImage from array containing pixels?

查看:312
本文介绍了如何从包含像素的数组创建BufferedImage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用方法 getRGB() BufferedImage 获取像素。像素存储在名为 data [] 的数组中。在对数据数组进行一些操作之后,我需要再次创建一个 BufferedImage ,以便我可以将它传递给一个模块,该模块将显示来自此数据数组的已修改图像,但是我我坚持了下来。

解决方案

 的BufferedImage的BufferedImage =新的BufferedImage(宽度,高度,BufferedImage.TYPE_INT_RGB); 

然后再次设置像素。

  bufferedImage.setRGB(x,y,your_value); 

PS:如评论中所述,请使用@TacticalCoder的答案


I get the pixels from BufferedImage using the method getRGB(). The pixels are stored in array called data[]. After some manipulation on data array, I need to create a BufferedImage again so that I can pass it to a module which will display the modified image, from this data array, but I am stuck with it.

解决方案

BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

Then set the pixels again.

bufferedImage.setRGB(x, y, your_value);

PS: as stated in the comments, please use the answer from @TacticalCoder

这篇关于如何从包含像素的数组创建BufferedImage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆