使用Android中的Matrix类实现
//加载需要操作的图片
Bitmap bitmapOrg = BitmapFactory.decoreResource(getResource(),R.drawable.eoe_andrid);
//获取这个图片的宽度和高度
int width = bitmapOrg.getWidth();
int hegith = bitmapOrg.getHeight();
//定义预转化成的图片的宽度和高度
int newWidht =200;
int newHeight=200;
//计算缩放率,新尺寸除原始尺寸
float scaleWidth = ((float)newWidth)/width;
float scaleHeight= ((float)newHeight)/height;
//创建操作图片用的Matrix对象
Matrix matrix = new Matrix();
//缩放图像动作
matrix.postScale(scaleWidth,scaleHeight);
//旋转图片
matrix.postRotate(45);
创建新的图片
Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg,0,0,width,hegith,matrix,true);
//将上面的创建的Bitmap转化成Drawable对象
BitmapDrawable bmb = new BitmapDrawable(resizedBitmap);
//创建一个imageview
ImageView imageView = new ImageView(this);
imageView.setImageDrawable(bmb);
分享到:
相关推荐
一个简单的demo。使用android中的matrix属性,实现图片的放大、缩小、以及左旋转、右旋转。
Android图片编辑demo(包含图片的裁剪、旋转、缩放)。
Android图片的旋转 缩放 剪切 存储
android 图片 旋转 平移 缩放,生成无锯齿图片
android图片缩放双击旋转效果 支持图片拖动,双击缩放,旋转,展示
android ImageView控件缩放和旋转图片源码.rar
android手势处理图片平移、缩放和旋转 图片出界判断 处理后新图片的创建
android 图片缩放和旋转,可以参考学习
图片的旋转和缩放android高级,内有详细讲解和源码实例
本项目是一个图片处理的综合例子源码,实现了图片的旋转,缩放,加盖水印,透明,倾斜,扭曲用到的图片是使用httpclient 实现在线图片的下载展示,并实现图片处理。如果,网络图片不存在了,请在代码中修改图片路径...
如何在Android中实现图片及动画的缩放和旋转.doc
图片的旋转和缩放android高级.pdf
这一篇,给大家介绍一下ImageView控件的使用,ImageView主要是用来显示图片,可以对图片进行放大、缩小、旋转的功能。 android:sacleType属性指定...在实现图片的缩放和旋转时,我们都需要用到android.graphics.
android缩放/旋转图片Matrix代码 android缩放/旋转图片Matrix代码
Android 图片平移、旋转、缩放demo源码
Android高级应用源码-Android图片的旋转,缩放,剪切,存储.zip
Android中各种图像格式转换(裁剪,旋转,缩放等一系列操作工具).zip Android中各种图像格式转换(裁剪,旋转,缩放等一系列操作工具).zip Android中各种图像格式转换(裁剪,旋转,缩放等一系列操作工具).zip ...
Android源码——ImageView控件缩放和旋转图片源码.zip