RGB转换成整数数组为位图 [英] Convert Array of RGB Integers to Bitmap
问题描述
我们知道,我们可以得到位图图像的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屋!