Java 在Android中将RGB值数组转换为图像
我已通过Java 在Android中将RGB值数组转换为图像,java,android,rgb,android-bitmap,Java,Android,Rgb,Android Bitmap,我已通过BitmapFactory.decodeStream将JPEG图像转换为RGB颜色值数组,代码如下: picw = selectedImage.getWidth(); pich = selectedImage.getHeight(); int[] pix = new int[picw * pich]; selectedImage.getPixels(pix, 0, picw, 0, 0, picw, pich); int R, G, B; for (int y = 0; y <
BitmapFactory.decodeStream
将JPEG图像转换为RGB颜色值数组,代码如下:
picw = selectedImage.getWidth();
pich = selectedImage.getHeight();
int[] pix = new int[picw * pich];
selectedImage.getPixels(pix, 0, picw, 0, 0, picw, pich);
int R, G, B;
for (int y = 0; y < pich; y++) {
for (int x = 0; x < picw; x++) {
int index = y * picw + x;
R = (pix[index] >> 16) & 0xff;
G = (pix[index] >> 8) & 0xff;
B = pix[index] & 0xff;
pix[index] = (R << 16) | (G << 8) | B;
}
}
picw=selectedImage.getWidth();
pich=selectedImage.getHeight();
int[]pix=新的int[picw*pich];
选择eImage.getPixels(像素,0,像素,0,0,像素,像素);
int R,G,B;
对于(int y=0;y>16)&0xff;
G=(pix[index]>>8)&0xff;
B=pix[索引]&0xff;
pix[index]=(R您可以使用静态方法
android中没有@Venugopal setRGB的可能副本
Bitmap bmp = Bitmap.createBitmap(pix, picw, pich, Bitmap.Config.ARGB_8888)