android 处理图片到固定像素 rt 如何把一个图片处理成固定像素大小的另外一个图片并保存下来处理后的 而原文件不动呢?如 在D位置有个1024*768的图片 怎么处理成480*800的图片存在E位置呢?D位置的图片不动 谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 大概是这样子的//判断本地文件是否存在 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()); } } /** * @将图片对象保存为PNG格式文件 * */ public void SaveBitmap(Bitmap bitmap,String filename) throws IOException { File file = new File(ImageDir, filename); FileOutputStream out; try{ out = new FileOutputStream(file); if(bitmap.compress(Bitmap.CompressFormat.PNG, 70, out)) { out.flush(); out.close(); } } catch (FileNotFoundException e) { LogPrintf("SaveBitmap err:"+e.getMessage()); } catch (IOException e) { LogPrintf("SaveBitmap err:"+e.getMessage()); } } Android大侠进来看一下,标题是不是要长长长长长长长长长长长长长长长长啊!!! android 开发问题 求解错误原因 关于 Android 混淆器 android的autoCompleteTextVeiw控件问题 初识安桌!问个新手问题。。 android是一个怎么样的学习过程 用eclipse android开发时运行模拟器就显示adb.ese已停止工作?!!!!!!求大神解决 andriod可展开列表点击? WIFI信号实时更新问题 Android实现自动登录 请问android系统如何进行系统备份和还原 从webservice 返回一段话怎么显示在textview上
//判断本地文件是否存在
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());
}
}
* @将图片对象保存为PNG格式文件
*
*/
public void SaveBitmap(Bitmap bitmap,String filename) throws IOException
{
File file = new File(ImageDir, filename);
FileOutputStream out;
try{
out = new FileOutputStream(file);
if(bitmap.compress(Bitmap.CompressFormat.PNG, 70, out))
{
out.flush();
out.close();
}
}
catch (FileNotFoundException e)
{
LogPrintf("SaveBitmap err:"+e.getMessage());
}
catch (IOException e)
{
LogPrintf("SaveBitmap err:"+e.getMessage());
}
}