我有一個位圖,我想發送到服務器,通過編碼到base64,但我不想壓縮在PNG或JPEG圖像。將位圖轉換爲byteArray android
現在我以前在做的是。
ByteArrayOutputStream byteArrayBitmapStream = new ByteArrayOutputStream();
bitmapPicture.compress(Bitmap.CompressFormat.PNG, COMPRESSION_QUALITY, byteArrayBitmapStream);
byte[] b = byteArrayBitmapStream.toByteArray();
//then simple encoding to base64 and off to server
encodedImage = Base64.encodeToString(b, Base64.NO_WRAP);
現在我只是不希望使用任何壓縮,也沒有任何形式樸素簡單的byte []從位圖,我可以編碼併發送到服務器。
任何指針?
小代碼會大大幫助:) – 2012-04-17 13:22:13
byte [] b; \t \t \t \t ByteBuffer byteBuffer = ByteBuffer.allocate(bitmapPicture.getByteCount()); \t \t bitmapPicture.copyPixelsToBuffer(byteBuffer); \t \t b = byteBuffer.array(); ??? – 2012-04-17 13:22:58
@AsadKhan我添加了一個例子。 – Jave 2012-04-17 13:33:06