List of utility methods to do Bitmap Save
void | addBitmapToMemoryCache(String key, Bitmap bitmap) add Bitmap To Memory Cache if (getBitmapFromMemCache(key) == null) {
mMemoryCache.put(key, bitmap);
|
String | base64Bitmap(Bitmap bitmap) base Bitmap ByteArrayOutputStream out = null; try { out = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); out.flush(); out.close(); byte[] imgBytes = out.toByteArray(); return Base64.encodeToString(imgBytes, Base64.DEFAULT); ... |
void | bitmap2File(Bitmap bitmap, File file) bitmap File bitmap2File(bitmap, file, CompressFormat.JPEG, 100); |
InputStream | bitmap2Stream(Bitmap bitmap) bitmap Stream return bitmap2Stream(bitmap, CompressFormat.JPEG, 100);
|
String | getImagePath(Context context, Bitmap inImage) get Image Path ByteArrayOutputStream bytes = new ByteArrayOutputStream(); inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes); String path = Images.Media.insertImage( context.getContentResolver(), inImage, "Title", null); return path; |
File | saveBitmap(Bitmap bitmap, File file) save Bitmap ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes); FileOutputStream fo = new FileOutputStream(file); fo.write(bytes.toByteArray()); fo.close(); return file; |
boolean | saveBitmap(String bitName, Bitmap bitmap) save Bitmap try { File temp = File.createTempFile("temp", ".png", new File( StringUtil.getNameDelLastPath(bitName))); FileOutputStream fOut = null; try { fOut = new FileOutputStream(temp); } catch (FileNotFoundException e) { bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut); fOut.flush(); fOut.close(); if (temp.exists()) { File f = new File(bitName); if (f.exists()) { f.delete(); FileUtil.moveFile(temp.getAbsolutePath(), bitName); return true; } catch (IOException e) { e.printStackTrace(); return false; |
void | saveBitmap(final Bitmap bitmap, final String savePath) save Bitmap FileOutputStream fileOutputStream = null; try { fileOutputStream = new FileOutputStream(savePath); bitmap.compress(Bitmap.CompressFormat.JPEG, DEAFULT_QUALITY, fileOutputStream); fileOutputStream.flush(); } catch (Exception e) { e.printStackTrace(); ... |
Bitmap | saveBitmapFromScrollView(ScrollView scrollView, String path) save Bitmap From Scroll View int h = 0; Bitmap bitmap = null; for (int i = 0; i < scrollView.getChildCount(); i++) { h += scrollView.getChildAt(i).getHeight(); bitmap = Bitmap.createBitmap(scrollView.getWidth(), h, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); ... |
boolean | saveBitmaptoFile(Bitmap bmp, String path, CompressFormat format, int quality) save Bitmapto File OutputStream stream = null; try { File file = new File(path); File filePath = file.getParentFile(); if (!filePath.exists()) { filePath.mkdirs(); if (!file.exists()) { ... |