List of usage examples for android.util Base64 DEFAULT
int DEFAULT
To view the source code for android.util Base64 DEFAULT.
Click Source Link
From source file:Main.java
public static Bitmap convertString2Icon(String st) { // OutputStream out; Bitmap bitmap = null;/*from w w w. java 2 s . c o m*/ try { // out = new FileOutputStream("/sdcard/aa.jpg"); byte[] bitmapArray; bitmapArray = Base64.decode(st, Base64.DEFAULT); bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length); // bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); return bitmap; } catch (Exception e) { return null; } }
From source file:Main.java
private static String getStringImage(Bitmap bmp) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] imageBytes = baos.toByteArray(); String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT); return encodedImage; }
From source file:Main.java
public static String bitmapToBase64(Bitmap bitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] imageBytes = baos.toByteArray(); String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT); return encodedImage; }
From source file:Main.java
public static byte[] getImageBytes(Bitmap bmp) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 100, baos); byte[] imageBytes = baos.toByteArray(); String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT); return imageBytes; }
From source file:Main.java
public static String BitmapToByte(Bitmap bitmap) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 50, byteArrayOutputStream); return new String(Base64.encodeToString(byteArrayOutputStream.toByteArray(), Base64.DEFAULT)); }
From source file:Main.java
public static String bitmapToBase64String(Bitmap bm) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG, 80, bos); byte[] b = bos.toByteArray(); return Base64.encodeToString(b, Base64.DEFAULT); }
From source file:Main.java
public static String encodeBitmap(Bitmap bitmap, Bitmap.CompressFormat compressFormat) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(compressFormat, 100, baos); byte[] bytes = baos.toByteArray(); byte[] encodedImage = Base64.encode(bytes, Base64.DEFAULT); return new String(encodedImage); }
From source file:Main.java
public static Object stringToObject(String encodedObject) { try {/*ww w . j a v a 2 s .c o m*/ return new ObjectInputStream( new Base64InputStream(new ByteArrayInputStream(encodedObject.getBytes()), Base64.DEFAULT)) .readObject(); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static String bitmapChangeString(Bitmap bitmap) { if (bitmap != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); String str = new String(Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT)); return str; }/* w ww. j a va 2 s. c om*/ return null; }
From source file:Main.java
public static String bitmapToBase64String(Bitmap bitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 80, baos); byte[] bitmapArray = baos.toByteArray(); String encodeString = Base64.encodeToString(bitmapArray, Base64.DEFAULT); return encodeString; }