Friday, March 13, 2015

How to encode base64 Strings from Bitmaps in Android (JAVA)

This is a relatively easy process. See the function below. It takes a Bitmap variable and outputs a string. 

private static String endcodeBase64 (Bitmap ico) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
ico.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
return Base64.encodeToString(byteArray, Base64.DEFAULT);
}

No comments:

Post a Comment

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...