Android Bitmap Compress flattenBitmap(Bitmap bitmap)

Here you can find the source of flattenBitmap(Bitmap bitmap)

Description

flatten Bitmap

Declaration

public static byte[] flattenBitmap(Bitmap bitmap) 

Method Source Code

//package com.java2s;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import android.graphics.Bitmap;

import android.util.Log;

public class Main {
    public static byte[] flattenBitmap(Bitmap bitmap) {
        int size = bitmap.getWidth() * bitmap.getHeight() * 4;
        ByteArrayOutputStream out = new ByteArrayOutputStream(size);
        try {//from   w  w w.j  ava2s . com
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
            out.flush();
            out.close();
            return out.toByteArray();
        } catch (IOException e) {
            Log.w("Favorite", "Could not write icon");
            return null;
        }
    }
}

Related

  1. bitmap2File(Bitmap bitmap, File file, CompressFormat format, int quality)
  2. bitmap2Stream(Bitmap bitmap, CompressFormat format, int quality)
  3. compressBitmapToFile(Bitmap originalBitmap, String path, int quality)
  4. compressToBytes(Bitmap bitmap)
  5. compressToBytes(Bitmap bitmap, int quality)
  6. smallPic(String oldPath, String newPath, int size)
  7. compressWithWidth(Bitmap bitmap, int width)
  8. compressWithWidth(String filePath, int width)
  9. compressBitmap(Bitmap bitmap)