Android Bitmap Save saveBitmapFromScrollView(ScrollView scrollView, String path)

Here you can find the source of saveBitmapFromScrollView(ScrollView scrollView, String path)

Description

save Bitmap From Scroll View

Declaration

public static Bitmap saveBitmapFromScrollView(ScrollView scrollView,
            String path) 

Method Source Code

//package com.java2s;

import java.io.FileOutputStream;

import android.graphics.Bitmap;

import android.graphics.Canvas;

import android.widget.ScrollView;

public class Main {
    public static Bitmap saveBitmapFromScrollView(ScrollView scrollView,
            String path) {/*from  ww w . jav a 2 s. c  om*/
        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);
        scrollView.draw(canvas);
        FileOutputStream out = null;
        try {
            out = new FileOutputStream(path);
            if (out != null) {
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
                out.flush();
                out.close();
            }
        } catch (Exception e) {
            return null;
        }
        return bitmap;
    }
}

Related

  1. bitmap2Stream(Bitmap bitmap)
  2. getImagePath(Context context, Bitmap inImage)
  3. saveBitmap(Bitmap bitmap, File file)
  4. saveBitmap(String bitName, Bitmap bitmap)
  5. saveBitmap(final Bitmap bitmap, final String savePath)
  6. saveBitmaptoFile(Bitmap bmp, String path, CompressFormat format, int quality)
  7. saveImage(String filename, Bitmap bm)
  8. saveImage(String filename, Bitmap bm, boolean landscape)
  9. saveMyBitmap(String bitName, Bitmap mBitmap)