首页 > 代码库 > android 关于图片缩放,旋转的简单应用
android 关于图片缩放,旋转的简单应用
右转
private void right() { // TODO Auto-generated method stub int bmpW = bm.getWidth() ; int bmpH = bm.getHeight() ; double scale =1 ; scaleW = (float)(scaleW*scale); scaleH = (float)(scaleH*scale); Matrix mt =new Matrix (); mt .postScale(scaleW, scaleH); mt.setRotate(curDegrees=curDegrees+5); Bitmap bitmap= Bitmap.createBitmap(bm, 0, 0, bmpW, bmpH, mt, true); iv.setImageBitmap(bitmap); }左转
private void left() { int bmpW = bm.getWidth() ; int bmpH = bm.getHeight() ; double scale =1 ; scaleW = (float)(scaleW*scale); scaleH = (float)(scaleH*scale); Matrix mt =new Matrix (); mt .postScale(scaleW, scaleH); mt.setRotate(curDegrees=curDegrees-5); Bitmap bitmap= Bitmap.createBitmap(bm, 0, 0, bmpW, bmpH, mt, true); iv.setImageBitmap(bitmap); }缩小
private void small() { int width =bm.getWidth() ; int height = bm.getHeight() ; double scale = 0.8; scaleW= (float) (scale*scaleW) ; scaleH = (float) (scaleH*scale) ; Matrix mt =new Matrix (); mt.postScale(scaleW, scaleH); Bitmap resizebmp = Bitmap.createBitmap(bm,0,0,width,height,mt,true); iv.setImageBitmap(resizebmp); }
放大
private void big() { int bmpW = bm.getWidth() ; int bmpH = bm.getHeight() ; double scale =1.25 ; scaleW = (float) (scaleW*scale) ; scaleH = (float) (scaleH * scale) ; Matrix mt = new Matrix () ; mt.postScale(scaleW, scaleH) ; Bitmap bmp = Bitmap.createBitmap(bm, 0, 0, bmpW, bmpH, mt, true) ; iv.setImageBitmap(bmp); }
android 关于图片缩放,旋转的简单应用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。