2012-05-30 37 views
0

夥計我正在開發一款用於閱讀QR碼的Android應用程序。我實施了庫ZXing,但我不能使用相機。我需要將QR碼保存爲圖像,並使用與ZXing解碼存儲爲圖像的QR碼相關的功能...任何想法?無需使用相機即可解碼QR碼圖像

我檢查了論壇,但我需要更多的東西完全..:(

+0

你的意思是說,你選擇圖像文件,然後解碼應該做的。是這樣嗎? – Bhavin

+0

是的,原諒我的英語,我不得不解碼QR碼在不使用攝像頭。在其他線程中發現的代碼片段我還沒有足夠的..我需要一步一步來:(... ZXing庫已經downl已上班並放置在工作區中。 –

+0

讓我再次清楚。你不想使用相機,你想解碼QR碼? – Bhavin

回答

5

是的,你可以在不使用攝像頭解碼QR你必須從圖庫中導入圖像,獲得該位圖,它傳遞給LuminanceSource source = new RGBLuminanceSource(bMap); 這裏是代碼。

LuminanceSource source = new RGBLuminanceSource(bMap); 
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); 
Reader reader = new MultiFormatReader(); 
try { 
    Result result = reader.decode(bitmap); 
    String contents = result.getText(); 
    byte[] rawBytes = result.getRawBytes(); 
    BarcodeFormat format = result.getBarcodeFormat(); 
    ResultPoint[] points = result.getResultPoints(); 
} catch (NotFoundException e) { 
    e.printStackTrace(); 
    return; 
} catch (ChecksumException e) { 
    e.printStackTrace(); 
    return; 
} catch (FormatException e) { 
    e.printStackTrace(); 
    return; 
} 
+0

這不適合我... –