如何将绘制的图像与视图背景一起保存到图库

时间:2012-01-31 10:53:34

标签: android

我的代码应该能够存储可绘制的画布以及背景视图。

public void saveImage(Bitmap bitmap) 
{
    String filename = String.valueOf(System.currentTimeMillis());
    ContentValues values = new ContentValues();
    values.put(Images.Media.TITLE, filename);
    values.put(Images.Media.DATE_ADDED, System.currentTimeMillis());
    values.put(Images.Media.MIME_TYPE, "image/**");
    Uri uri = this.getContentResolver().insert(Images.Media.EXTERNAL_CONTENT_URI,values);

    try 
    {
        OutputStream outStream = this.getContentResolver()
            .openOutputStream(uri);

        bitmap.compress(Bitmap.CompressFormat.JPEG, 90, outStream);
        outStream.flush();

        System.out.println("SAVEEEEEEEEEEEEEEEEEEEEE IS CALLING");

        outStream.close();

        Toast.makeText(ImagePaint.this, "Image Saved!", Toast.LENGTH_SHORT).show();
    } 
    catch (FileNotFoundException e) 
    {
        e.printStackTrace();
    } 
    catch (IOException e) 
    {
        e.printStackTrace();
    }
}

0 个答案:

没有答案