San*_*ela 8 android bitmap image-resizing
我希望我的应用程序的用户能够在运行时修改图像.用户应该能够通过点击图像视图的角落并拖动它来修改图像的高度和宽度,如下图所示:

我花了很多时间研究这个,我发现 了多点触控的感觉,并将一个大的位图文件调整为缩放输出文件,如Pinch Zoom,但这些都不符合我的要求.
目前我正在调整位图使用下面的结果和改变宽度的onprogress改变方法的搜索栏而不是帧.通过使用此功能,更改图像大小不能正常工作.
public static Bitmap decodeFile(File f,int WIDTH,int HIGHT){
try {
//Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f),null,o);
//The new size we want to scale to
final int REQUIRED_WIDTH=WIDTH;
final int REQUIRED_HIGHT=HIGHT;
//Find the correct scale value. It should be the power of 2.
int scale=1;
while(o.outWidth/scale/2>=REQUIRED_WIDTH && o.outHeight/scale/2>=REQUIRED_HIGHT)
scale*=2;
//Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize=scale;
return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
}
catch (FileNotFoundException e) {}
return null;
}
Run Code Online (Sandbox Code Playgroud)
更新:
现在使用画布中的绘图位图使用此问题的接受答案顺利工作.
现在扩孔部分是在图像周围设置框架,如裁剪框架.
请帮我实现这个目标.
| 归档时间: |
|
| 查看次数: |
1458 次 |
| 最近记录: |