android - Convert PNG image to Base64 -


I am converting the drawable resource PGG image to bitmap and then converting that bitmap to base 64 and making it web Sending to the server by service. / P>

The image is stored on the server at some address and I am getting the URL where the image is stored.

The problem is that the url I am getting with the URL after sending the image to the server is setting the image in another image view, but the transparent part of the image is blackish, I think That problem is to convert PGG image to base 64,

My code:

  bitmap bitmap = bitmapfender Decode processing (getResources (), R.drawable.ic_launcher); Bitmap = bitmap.scent scaledbitmap (bitmap, 300, 300, incorrect); MImageView.setImageBitmap (bitmap); BytereonOperputTreamBao = new BytereOutStream (); Bitmap.compress (bitmap.compress format.png, 90, bao); Byte [] Ba = Bao To Batteryre (); Base64Image = Base 64. encodeToString (BA, Base64.DEFAULT);  

Please give me the solution ASAP

Whatever you are doing Are right. Depending on the version of Android you are compiling, there may be different default behavior in decodeResource . You can use bitmapfactory Can force.

  BitmapFactory.Options options = new BitmapFactory.Options (); Options.inPreferredConfig = Bitmap.source. ARGB_8888; Options.inDither = false; Bitmap bitmap = bitmapfender Decode resource (getResources (), R.drawable.ic_launcher, option);  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -