如何保存在SD卡图像中的Andr​​oid应用RGB彩色滤光片后 [英] How to save an image in sdcard after applying RGB color filter in android

查看:217
本文介绍了如何保存在SD卡图像中的Andr​​oid应用RGB彩色滤光片后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

presently我根据照片编辑正在设计一个应用程序。而这样做我遇到了一个问题,即


  1. 我已经通过了教程如何应用RGB颜色过滤器的图像从这个的链接本教程是非常有益的和好的。

  2. 但问题是应用RGB彩色滤光片到图像之后,我需要保存更改后的图像中的SD卡。

  3. 我GOOGLE了很多关于这一点,但并没有找到确切的事情。

  4. 他们中的许多sugested用油漆()但是我没有得到如何使用。

  5. 那么究竟我的问题是将RBG着色图像后,我需要保存在SD卡的形象,但我没有找到怎么办呢?


解决方案

如何到Android的ImageView保存到SD卡

您有一个您已通过各种灯光效果和彩色滤光片修改,现在你希望的结果保存到SD卡为.jpg或ImageView的 .PNG格式的图像。

这里是如何


    查看
  1. 加载位图图像。

  2. 保存位图图像到SD卡。

示例:结果
不要忘记测试例外和补充必要的权限,您的清单!

  ImageView的ImageView的= LT;查看保存到SD卡取代;
位图位图= loadBitmapFromView(ImageView的);
最后弦乐pathTxt = Environment.getExternalStorageDirectory();
文件storagePath =新的文件(pathTxt);
档案文件=新的文件(storagePathfilename.jpg);
FileOutputStream中出=新的FileOutputStream(文件);
bitmap.com preSS(Bitmap.Com pressFormat.JPEG,80出);
了out.flush();
out.close();私人位图loadBitmapFromView(视图v){
    最终诠释W = v.getWidth();
    最终诠释H = v.getHeight();
    最后的位图B = Bitmap.createBitmap(W,H,Bitmap.Config.ARGB_8888);
    最后帆布C =新的Canvas(B);
    //v.layout(0,0,W,H);
    v.layout(v.getLeft(),v.getTop(),v.getRight(),v.getBottom());
    v.draw(C);
    返回b;
}

Presently I am designing an application based on photo editing. While doing this i encountered with a problem i.e.

  1. I have gone through a tutorial "how to apply RGB color filter for an image" from this link and this tutorial is very helpful and nice.
  2. But the problem is after applying RGB color filter to the image i need to save the changed image in sd card.
  3. I have googled a lot for this but didn't found exact thing.
  4. Many of them sugested to use paint() But im not getting how to use that.
  5. So exactly my problem is "After Applying RBG Coloration to image I need to save that image in SD Card, But I do not found the how to do it" ?

解决方案

How to Save an Android ImageView to SD Card

You have an ImageView which you've modified via various lighting effects and color filters and now you wish to save the result to the SD card as as a .jpg or .png format image.

Here's how:

  1. Load Bitmap image from View.
  2. Save Bitmap image to SD card.

Example:
Don't forget to test for Exceptions and add the necessary permissions to your manifest!

ImageView imageView = <View to save to SD card>;
Bitmap bitmap = loadBitmapFromView(imageView);
final String pathTxt = Environment.getExternalStorageDirectory();
File storagePath = new File(pathTxt);
File file = new File(storagePath, "filename.jpg");
FileOutputStream out = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, out);
out.flush();
out.close();

private Bitmap loadBitmapFromView(View v) {
    final int w = v.getWidth();
    final int h = v.getHeight();
    final Bitmap b = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    final Canvas c = new  Canvas(b);
    //v.layout(0, 0, w, h);
    v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
    v.draw(c);
    return b;
}

这篇关于如何保存在SD卡图像中的Andr​​oid应用RGB彩色滤光片后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆