保存JPEG以后观看 [英] saved jpeg viewing later
本文介绍了保存JPEG以后观看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我工作的一个应用程序,将存储绘制的帆布作为SD卡的JPEG图像。
问题是,当我试图查看保存的图像,它加载了很多的时间比我想在正常时间要查看保存的图像像其他图像其它图像
我的code保存的图像是:
I am working on a application that will stores a drawn canvas as jpeg image in SD card. The issue is when i tried to view the saved image it is loading for lot of time than other images i want the saved image to be viewed in normal time as like other images My code for saving an image is:
View content = drawView;
content.setDrawingCacheEnabled(true);
content.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
Bitmap bitmap = content.getDrawingCache();
String path = Environment.getExternalStorageDirectory().getAbsolutePath();
String file_name="Imatge"+System.currentTimeMillis()+".jpg";
File file = new File(path,file_name);
FileOutputStream ostream;
try {
ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.PNG,50, ostream);
ostream.flush();
ostream.close();
Toast.makeText(getApplicationContext(), " :) Image saved in "+ path+"/"+file_name, 5000).show();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), e.toString()+"error", 5000).show();
}
}
在此先感谢,请帮助我!!!!
Thanks in advance please help me!!!!
推荐答案
我自己找到解决方案,该解决方案是存储直通媒体商店的形象这里是我的code的正常工作
I myself find the solution , the solution is to store the image thru media store here is my code that is working correctly
View content = drawView;
content.setDrawingCacheEnabled(true);
content.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_AUTO);
Bitmap bitmap;
bitmap = content.getDrawingCache();
String file_name="MyImage"+System.currentTimeMillis()+".jpg";
ContentValues values = new ContentValues();
values.put(Images.Media.TITLE,"MyImage");
values.put(Images.Media.DESCRIPTION,"Advanced Practice");
values.put(Images.Media.MIME_TYPE, "image/jpeg");
Uri url = null;
try
{
url = getContentResolver().insert(MediaStore.Images.Thumbnails.getContentUri("external"), values);
MediaStore.Images.Media.insertImage(getContentResolver(), bitmap,"MyImage","Advanced Practice");
Toast.makeText(getApplicationContext(), " :) Image saved in /sdcard/DCIM/Camera/"+file_name, 5000).show();
}
catch (Exception e)
{
e.printStackTrace();
Toast.makeText(getApplicationContext(), e.toString()+"error", 5000).show();
}
这篇关于保存JPEG以后观看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文