D
dbcheng
Guest
I have succeeded from onPreviewFrame (byte [] data, camera camera) {...} Will NV21 extract Y for the gray value, but I want to print the gray value, gray value should be 0 ~ 255 But according to the black area should be 0 but printed out -16777216, how can I see 0 ~ 255 PS.I know that ARGB_8888 is 32 bits, so to extract A black area if 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
public Bitmap applyGrayScale( byte [] data, int width, int height) {
int[] pixels = new int[width * height];
int p;
int size = width*height;
for(int i = 0; i < size; i++) {
p = data & 0xFF;
pixels = 0xff000000 | p<<16 | p<<8 | p;
Log.d("pixels=", String.valueOf(pixels));
}
return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
}
enter image description here
Continue reading...
public Bitmap applyGrayScale( byte [] data, int width, int height) {
int[] pixels = new int[width * height];
int p;
int size = width*height;
for(int i = 0; i < size; i++) {
p = data & 0xFF;
pixels = 0xff000000 | p<<16 | p<<8 | p;
Log.d("pixels=", String.valueOf(pixels));
}
return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888);
}
enter image description here
Continue reading...