如何将jpeg转换为“原始8bpp灰度图像像素数据”

时间:2019-04-01 07:57:26

标签: java android jpeg honeywell

我想通过Honeywell的SwiftDecoder在Android设备上运行图像。 Honeywell SDK需要“原始的8bpp灰度图像像素数据”作为byteArray。我尽了一切可能。但是,请始终返回空结果列表,并在调试控制台中返回以下错误消息:

“ E / HSMLog:在类com.honeywell.barcode.DecodeManager中捕获了异常 方法:DecodeImage() 消息:字节[]偏移量= 0长度= 9000000 src.length = 6420735“

我已将jpeg转换为具有位图格式ARGB_8888的位图,然后将其移植到灰度图像中,并将其转换成bitArray。

    ```BitmapFactory.Options op = new BitmapFactory.Options();
    op.inPreferredConfig = Bitmap.Config.ARGB_8888;
    picBitmap = (Bitmap) BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getPath() + "/path/test.jpeg", op);
    greyscaleBitmap = toGrayscale(picBitmap);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    picBitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
    byte[] byteArray = baos.toByteArray();

    HSMDecodeResult[] barcodeData = hsmDecoder.decodeImage(byteArray, picBitmap.getWidth(), picBitmap.getHeight());```

我得到一个空结果和以下错误消息:“ E / HSMLog:在类中捕获异常:com.honeywell.barcode.DecodeManager 方法:DecodeImage() 消息:字节[]偏移量= 0长度= 9000000 src.length = 6420735“

0 个答案:

没有答案
相关问题