解决方案 »
- [求助]关于SurfaceView的SurfaceCreated方法。
- 服务器端向Android客户端返回数据显示
- 新手指教 怎么样点击Button使TextView或EditText清空
- android蛇吃豆是不是这样的。
- 【开发咨询】Android手机通过WIFI传输数据(对方可能是PC,也可能是另一智能手机,或者智能电视)
- GridLayout中addView方法报错的问题
- tabhost 子窗口如何通知父窗口。。。
- 请问这个效果中的问题怎么解决,谢谢!
- android中登陆的帐号密码保存在哪?
- 最近准备做个基于ftdi的红外项目
- android 微信分享问题
- Please ensure that adb is correctly located at
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
bitmap = BitmapFactory.decodeFile(getRealFilePath(context,uri), options);
options.inJustDecodeBounds = false; // 设为 false
int w = options.outWidth;
int h = options.outHeight;
float hh = 500f;//这里设置高度为800f
float ww = 300f;//这里设置宽度为480f
int be = 1;
if (w/h >= ww/hh) {//如果宽度大的话根据宽度固定大小缩放
be = (int) (options.outWidth / ww);
} else{//如果高度高的话根据宽度固定大小缩放
be = (int) (options.outHeight / hh);
}
if (be <= 0) {
be = 1;
}
options.inSampleSize=be;
System.err.println(be+":::"+options.outMimeType);
bitmap = BitmapFactory.decodeFile(getRealFilePath(context, uri), options);
try {
int size = bitmap.getRowBytes()*bitmap.getHeight();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.JPEG,100, bos);
bitmap = BitmapFactory.decodeByteArray(bos.toByteArray(), 0, bos.toByteArray().length);
bos.close();
System.err.println(size+"::::"+bos.toByteArray().length+":::"+bitmap.getRowBytes()*bitmap.getHeight());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bitmap;这是我这边的代码 ,,我最后是吧bitmap转换成输入流传到服务器上去的
服务器上的图片会比手机上的图片大好多