rafaK
unread,Oct 27, 2011, 9:53:13 PM10/27/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to zxing
Hi,
In Android I'm using zxing project/source code to create a new
application. I changed the code in the class DecodeHandler to save
the image as a Bitmap but I think on this process I'm losing quality.
Anybody know another way to do that?
private void decode(byte[] data, int width, int height) throws
IOException {
long start = System.currentTimeMillis();
Result rawResult = null;
PlanarYUVLuminanceSource source =
CameraManager.get().buildLuminanceSource(data, width, height);
BinaryBitmap bitmap = new BinaryBitmap(new
HybridBinarizer(source));
try {
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inDither = true;
opt.inPreferredConfig = Bitmap.Config.ARGB_8888;
//Bitmap bmp = BitmapFactory.decodeByteArray(data, 0 ,
data.length, opt);
YuvImage yuvimage=new YuvImage(data, ImageFormat.NV21, width,
height, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
yuvimage.compressToJpeg(new Rect(0, 0, width, height), 100,
baos);
byte[] jdata = baos.toByteArray();
// Convert to Bitmap
Bitmap bmp = BitmapFactory.decodeByteArray(jdata, 0,
jdata.length);
...............
Thanks,
Rafael.