首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android 处理图片到固定像素解决办法

2012-06-04 
android 处理图片到固定像素rt如何把一个图片处理成固定像素大小的另外一个图片并保存下来处理后的而原文

android 处理图片到固定像素
rt 如何把一个图片处理成固定像素大小的另外一个图片并保存下来处理后的 而原文件不动呢?如 在D位置有个1024*768的图片 怎么处理成480*800的图片存在E位置呢?D位置的图片不动 谢谢!

[解决办法]
大概是这样子的

Java code
//判断本地文件是否存在                   File fileS = new File(Sfilename);                if(fileS.exists())                {   //本地文件存在                        BitmapFactory.Options options = new BitmapFactory.Options();                    options.inJustDecodeBounds = true;                     // 获取这个图片原始的宽和高 在outHeight 及 outWidth                    Bitmap bm = BitmapFactory.decodeFile(fileS.getPath(), options); //此时返回bm为空                    //  我们要得到高及宽都不超过W H的缩略图                    int zW = options.outWidth/800;                            int zH = options.outHeight/480;                    int be = zH;                    if(zW > be)                        be = zW;                                        if(be == 0) be = 1;                                        options.inSampleSize = be;                    options.inJustDecodeBounds = false;                                             bm = BitmapFactory.decodeFile(fileS.getPath(), options);                    try {                        File fileD = new File(Dfilename);                        if(!fileD.exists())                        {    //本地文件不存在,则保存                            myConfig.SaveBitmap(result,Dfilename);                        }                    } catch (IOException e) {                        // TODO Auto-generated catch block                        myConfig.LogPrintf("ImageDownloadTask.onPostExecute() err:"+e.getMessage());                    }                } 

热点排行