List of usage examples for android.graphics Bitmap compress
@WorkerThread public boolean compress(CompressFormat format, int quality, OutputStream stream)
From source file:Main.java
/** * Converts bitmap to byte array/* w ww . j a v a 2 s .com*/ * * @param bitmap * @return */ public static byte[] getBytes(Bitmap bitmap) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 0, stream); return stream.toByteArray(); }
From source file:Main.java
public static Uri writeToTempImageAndGetPathUri(Context inContext, Bitmap inImage) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes); String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null); return Uri.parse(path); }
From source file:Main.java
private static byte[] readBitmap(Bitmap bmp) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 60, baos); try {// www . j av a2 s. co m baos.flush(); baos.close(); } catch (IOException e) { e.printStackTrace(); } return baos.toByteArray(); }
From source file:Main.java
public static InputStream getBitmapJpegStream(Bitmap theBitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); theBitmap.compress(Bitmap.CompressFormat.JPEG, 95, baos); byte[] data = baos.toByteArray(); return new ByteArrayInputStream(data); }
From source file:Main.java
public static InputStream getBitmapPngStream(Bitmap theBitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); theBitmap.compress(Bitmap.CompressFormat.PNG, 95, baos); byte[] data = baos.toByteArray(); return new ByteArrayInputStream(data); }
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 InputStream getInputStream(Bitmap bitmap) { ByteArrayOutputStream bStream = new ByteArrayOutputStream(); bitmap.compress(CompressFormat.JPEG, 100, bStream); return new ByteArrayInputStream(bStream.toByteArray()); }
From source file:Main.java
public static byte[] bitmapToByte(Bitmap bitmap) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, bos); return bos.toByteArray(); }
From source file:Main.java
public static InputStream getInputStreamFromBitmap(Bitmap bitmap) { final ByteArrayOutputStream out = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); final byte[] bitmapdata = out.toByteArray(); final ByteArrayInputStream bs = new ByteArrayInputStream(bitmapdata); return bs;//from w ww . j ava 2 s . c o m }
From source file:Main.java
public static Uri getImageUri(Context inContext, Bitmap inImage) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes); String path = MediaStore.Images.Media.insertImage(inContext.getContentResolver(), inImage, "croppedImage", null);/* ww w . j av a2 s . co m*/ return Uri.parse(path); }