Android Bitmap Compress bitmap2Stream(Bitmap bitmap, CompressFormat format, int quality)

Here you can find the source of bitmap2Stream(Bitmap bitmap, CompressFormat format, int quality)

Description

bitmap Stream

Declaration

public static final InputStream bitmap2Stream(Bitmap bitmap,
            CompressFormat format, int quality) 

Method Source Code

//package com.java2s;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

import java.io.InputStream;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;

public class Main {
    public static final InputStream bitmap2Stream(Bitmap bitmap) {
        return bitmap2Stream(bitmap, CompressFormat.JPEG, 100);
    }/*from  w  w  w .ja  va 2  s .com*/

    public static final InputStream bitmap2Stream(Bitmap bitmap,
            CompressFormat format, int quality) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        bitmap.compress(format, quality, baos);
        InputStream stream = new ByteArrayInputStream(baos.toByteArray());
        return stream;
    }
}

Related

  1. bitmap2File(Bitmap bitmap, File file, CompressFormat format, int quality)
  2. compressBitmapToFile(Bitmap originalBitmap, String path, int quality)
  3. compressToBytes(Bitmap bitmap)
  4. compressToBytes(Bitmap bitmap, int quality)
  5. flattenBitmap(Bitmap bitmap)