保存缩略图.thumbnails文件夹 [英] Saving thumbnails to .thumbnails folder

查看:517
本文介绍了保存缩略图.thumbnails文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我想保存到文件夹.thumbnails的图像,如下图所示:

Hi I am trying to save an image to the .thumbnails folder as shown below:

bitmap = ThumbnailUtils.extractThumbnail
                                (BitmapFactory.decodeFile(actualImagePath,options), 120, 120);
                                bitmapGenerated = true;
                        File file = new File(Environment.getExternalStorageDirectory()
                                .toString()+"/"+"DCIM/.thumbnails/"+id+".jpg");
                        boolean bcc =file.createNewFile();
                        boolean success = bitmap.compress(Bitmap.CompressFormat.PNG,60,new
                                FileOutputStream
                                (file));

在'ID'其实是我想保存,如图所示从光标获得的特定图像的ID:

The 'id' is actually the id of the particular image that I am trying to save and is obtained from a cursor as shown:

image_column_index = mCursor.getColumnIndex(MediaStore.Images.Media._ID);
id = mCursor.getLong(image_column_index);

图片然而被保存在.thumbnails',因为我尝试访问我刚创建的图像的缩略图,它不读。
我想这是因为我给了缩略图的名字。

The image gets saved in the '.thumbnails' , however, as I try to access the image thumbnail that I just created, it is not read. I think it was because of the name I gave to the thumbnail image.

所以我的问题是它好保存到.thumbnails文件夹,如果是在什么名字,我们应该保存文件?

So my question is it okay to save to '.thumbnails' folder and if so in what name should we save the file?

帮助真的是AP preciated,

Help is really appreciated,

感谢你。

推荐答案

我发现生成缩略图,我们并不需要明确创建缩略图文件,并把它放在.thumbnials文件夹中。

I found out that to generate a thumbnail we don't need to explicitly create a thumbnail image file and put it in the .thumbnials folder.

有一个在我们可以用我们的目的MediaStore.Images.Media称为getThumbnail方法。 code为如下所示:

There is a method called getThumbnail in MediaStore.Images.Media that we can use for our purpose. Code is as shown:

    Cursor mCursor;
mCursor = mContext.getContentResolver().query(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null,
                null, null, null);
int image_column_index = mCursor.getColumnIndex(MediaStore.Images.Media._ID);
long id = mCursor.getLong(image_column_index);
MediaStore.Images.Thumbnails.getThumbnail(mContext
                    .getContentResolver(), id, MediaStore.Images.Thumbnails.MINI_KIND, null);

以上code会产生相关的imageid缩略图,首先我们要确保该缩略图不存在,并创建只有当不存在一个新的。

The above code will generate a thumbnail for the associated imageid , first we have to make sure that the thumbnail doesn't exist and create a new one only if one doesn't exist.

这篇关于保存缩略图.thumbnails文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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