image-chooser-library icon indicating copy to clipboard operation
image-chooser-library copied to clipboard

Conversion to base64 gives corrupted Image

Open arindamdawn-zz opened this issue 9 years ago • 1 comments

This is something which I was trying for image uploading. The base64 string obtained from the bitmap results in a corrupted image

                imagePath = image.getFilePathOriginal();
                Log.d("TAG","PATH is"+imagePath);
                myBitmap = BitmapFactory.decodeFile(imagePath);
                Log.d("bitmap", myBitmap.toString());

                ImageView myImage = (ImageView) findViewById(R.id.shop_cover_image);
                myImage.setImageBitmap(myBitmap);

                coverImageArea.setVisibility(View.VISIBLE);
                dialog.hide();
                dialog.dismiss();
                ByteArrayOutputStream baos0 = new ByteArrayOutputStream();

                myBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos0);
                byte[] imageBytes0 = baos0.toByteArray();
                encodedImage= Base64.encodeToString(imageBytes0, Base64.DEFAULT);
                Log.e("addy",encodedImage);

arindamdawn-zz avatar May 28 '15 02:05 arindamdawn-zz

It shouldn't. But, I will check this out.

coomar2841 avatar Jul 01 '15 18:07 coomar2841