RGB转换成整数数组为位图 [英] Convert Array of RGB Integers to Bitmap

查看:204
本文介绍了RGB转换成整数数组为位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们知道,我们可以得到位图图像的RGB与使用code如下:

We know that, we can get rgb of bitmap image with using the code as follow :

BufferedImage img = ImageIO.read(new File(bitmapURL));
int[] pixels = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth());

和,执行code的这一部分后,我们有一个包含4个字节用于任何像素的 Alpha,红,绿,蓝颜色整数数组。所以,我想知道我们如何能够转换成整数数组像 INT [] myPixels; 为位图?可能任何一个请帮助我达到这个?

And, after executing this parts of code, we have an array of integers that contains 4 bytes for Alpha, Red, Green and Blue colors of any pixel. So, i want to know that how can we convert an array of integers like int [] myPixels; to Bitmap ? Could any one please help me to reach this?

在此先感谢:)

推荐答案

您可以直接使用这样的:

You can directly use this :

image.setRGB(0, 0, width, height, pixels, 0, width);

<一个href=\"http://docs.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html#setRGB%28int,%20int,%20int,%20int,%20int%5B%5D,%20int,%20int%29\"相对=nofollow>来源

这篇关于RGB转换成整数数组为位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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