android Bitmap缩放
来源:互联网 发布:建筑扫描建模软件 编辑:程序博客网 时间:2024/06/05 15:42
// 获得屏幕的宽高 int screenWidth = getWindow().getWindowManager().getDefaultDisplay().getWidth(); int screenHeight = getWindow().getWindowManager().getDefaultDisplay().getHeight(); // 加载Imageview和获得图片的信息 final ImageView imageView = (ImageView) findViewById(R.id.imgView); final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.a); int bitmapWidth = bitmap.getWidth(); int bitmapHeight = bitmap.getHeight(); // 计算缩放比,因为如果图片的尺寸超过屏幕,那么就会自动匹配到屏幕的尺寸去显示。 float scaleX = screenWidth / (float) bitmapWidth; float scaleY = screenHeight / (float) bitmapHeight; float baseScale = Math.min(scaleX, scaleY);// 获得缩放比例最大的那个缩放比,即scaleX和scaleY中小的那个 final Matrix matrix = new Matrix(); matrix.setScale(baseScale, baseScale); Bitmap bitmap2 = Bitmap.createBitmap(bitmap, 0, 0, bitmapWidth, bitmapHeight, matrix, false); imageView.setImageBitmap(bitmap2);final Matrix matrix = new Matrix(); int bitmapWidth = bitmap[i].getWidth(); matrix.setScale(1/baseScale, 1/baseScale ); imageView.setImageMatrix(matrix);
0 0
- android bitmap缩放
- android Bitmap缩放
- Android Bitmap缩放
- Android 缩放bitmap的函数
- android Bitmap 读取缩放图片
- Android 之 Bitmap等比缩放
- android ImagView缩放方法之一(Bitmap)
- android 中bitmap 缩放和阴影效果
- Android Bitmap转换以及图片的缩放
- Android中图片Bitmap的缩放
- android Bitmap的截取及缩放
- Android bitmap 图片缩放,压缩处理
- Android中图片Bitmap的缩放
- Android中bitmap图像的缩放
- Android中图片Bitmap的缩放
- Android中图片Bitmap的缩放
- Android Bitmap精确缩放到指定大小
- Bitmap缩放
- Eclipse添加jar包方法
- ExtJs--07--Ext.define定义一个类的过程
- iOS开发之常用的第三方类库大汇总
- Android 怎样在xml里打开其他xml的layout
- iOS多线程编程Part 2/3 - NSOperation
- android Bitmap缩放
- unity3d 常用的指令SetActive()、renderer .enabled 、collider.enabled
- Python标准库:内置函数classmethod(function)
- iOS多线程编程Part 3/3 - GCD
- List<Object>强制转换为List<String>
- android resolver.query 查询数据时报错: get field slot from row 0 col X failed
- SecureCRT使用方法技巧
- 【Hibernate】Could not obtain transaction-synchronized Session for current thread
- 将一个字符串不使用额外容器向左移动M位