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 String bitmapToString(Bitmap bm, int rate) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG, rate, baos); byte[] b = baos.toByteArray(); return Base64.encodeToString(b, Base64.DEFAULT); }
From source file:Main.java
public static String encodeImageBase64(Bitmap bitmap) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream); return Base64.encodeToString(outputStream.toByteArray(), Base64.DEFAULT); }
From source file:Main.java
public static String getImageAsString(Bitmap bmp) { ByteArrayOutputStream bYtE = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 100, bYtE); byte[] byteArray = bYtE.toByteArray(); String image = Base64.encodeToString(byteArray, Base64.DEFAULT); bmp.recycle();/* w ww. j a v a2 s. c om*/ Log.d("Converted TO : ", image); return image; }
From source file:Main.java
public static void base64ToBitmap(String base64Data, String imgName, String imgFormat) { byte[] bytes = Base64.decode(base64Data, Base64.DEFAULT); Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); File myCaptureFile = new File("/sdcard/", imgName); FileOutputStream fos = null;//from ww w. j ava 2 s. co m try { fos = new FileOutputStream(myCaptureFile); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } boolean isTu = bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos); if (isTu) { // fos.notifyAll(); try { fos.flush(); fos.close(); } catch (IOException e) { e.printStackTrace(); } } else { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:Main.java
public static String bitMapToString(Bitmap bitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); byte[] b = baos.toByteArray(); String temp = Base64.encodeToString(b, Base64.DEFAULT); return temp;/*from ww w . ja v a2 s . c om*/ }
From source file:Main.java
public static String encodeBase64File(String path) throws Exception { File file = new File(path); FileInputStream inputFile = new FileInputStream(file); byte[] buffer = new byte[(int) file.length()]; inputFile.read(buffer);/*from www . j a v a 2 s . c om*/ inputFile.close(); return Base64.encodeToString(buffer, Base64.DEFAULT); }
From source file:Main.java
public static String bitmapToBase64(Bitmap bitmap) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, bytes); byte[] byteArr = bytes.toByteArray(); return Base64.encodeToString(byteArr, Base64.DEFAULT); }
From source file:Main.java
public static String bitmapToBase64(Bitmap bmp) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 75, byteArrayOutputStream); byte[] imgBytes = byteArrayOutputStream.toByteArray(); return Base64.encodeToString(imgBytes, Base64.DEFAULT); }
From source file:Main.java
public static String SHA256(String text) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(text.getBytes());//from w ww . j a va 2s . c om byte[] digest = md.digest(); return Base64.encodeToString(digest, Base64.DEFAULT); }
From source file:Main.java
public static String toBase64(Bitmap bitmap) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); return Base64.encodeToString(byteArray, Base64.DEFAULT); }