Issue with decoding YUV Image on some Android devices -
i trying create online scanner using android onpreviewframe method. i've created asynctask process image me. code of converting method:
public bitmap rendercroppedgreyscalebitmap() { int width = getwidth(); int height = getheight(); int[] pixels = new int[width * height]; byte[] yuv = yuvdata; int inputoffset = top * datawidth + left; (int y = 0; y < height; y++) { int outputoffset = y * width; (int x = 0; x < width; x++) { int grey = yuv[inputoffset + x] & 0xff; pixels[outputoffset + x] = 0xff000000 | (grey * 0x00010101); } inputoffset += datawidth; } bitmap bitmap = bitmap.createbitmap(width, height, bitmap.config.argb_8888); bitmap.setpixels(pixels, 0, width, 0, 0, width, height); return bitmap; }
everything works great on devices, htc desire hd, samsung galaxy s2 or samsung galaxy gt or lg-p500. frames correctly sent server in greyscale , processed.
but on devices htc 1 x goes wrong. instead of real image server recieves images this: bad image
i trying change image format - nothing changed (now using default 1 - nv21). trying use yuvimage class , method compresstojpeg - nothing changed. image still wrong decoded. trying save image on sd card saved images corrupted also.
Comments
Post a Comment