当前位置:首页 » 安卓系统 » android让图片旋转

android让图片旋转

发布时间: 2022-06-23 08:04:51

① Android中怎么使一张图片绕Y轴自动旋转

动画animation能实现围绕自身某个点旋转和围绕外部屏幕上某个点旋转.

② android 中用画布旋转图片的时候怎么让让他 围着一个坐标旋转

方法只有一种。

步骤:

1、画布平移坐标原点

2、旋转画布

示例代码

java">canvas.save();//保存当前画布状态
canvas.translate(x,y);//将坐标中心平移到要围绕的坐标点x,y
canvas.rotate(90);//旋转角度,这里比如90度
canvas.restore();//恢复画图状态到保存前

③ android 怎么让图片实现朝Z轴的方向旋转RotateAnimation是x y方向的,我想要包含z方向的

RotateAnimation是不可以绕Z轴旋转的,如果LZ想要实现Z轴旋转效果,可以看下matrix这个类(实际还是opengl),可以给LZ例举下:
rotateX(float degree) 绕着x轴旋转degree个度数
rotateY(float degree) 绕着y轴旋转degree个度数
rotateZ(float degree) 绕着z轴旋转degree个度数

④ android开发中让图片旋转发生outofmemory错误要怎么解决

没什么好办法,加载Bitmap的时候已经占用内存了,你一让它旋转,它会重新调用OnDraw方法,将界面重新绘制一下,又占用了一块内存,没有思路。要不你试试将图片缩小一下再试试。

⑤ android 怎么得到手机拍照照片的旋转角度

具体思路:
1、首先在调用拍照方法时,保存拍照后的相片原图,得到原图路径,(PhotoBitmapUtils是我自己写的一个工具类)

String fileName = "";
/**
* 启动相机拍照
*/
private void addBitmapShoots() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// 设置图片要保存的 根路径+文件名
fileName = PhotoBitmapUtils.getPhotoFileName(getContext());
File file = new File(fileName);
if (!file.exists()) {
try {
file.createNewFile();

⑥ android怎么实现图片旋转

可以使用RotateAnimation动画实现,设定无限循环即可

代码如下

{

ImageViewiv;
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_two);
iv=(ImageView)findViewById(R.id.image);
RotateAnimationanimation=newRotateAnimation(0,360);
animation.setDuration(100000);//设定转一圈的时间
animation.setRepeatCount(Animation.INFINITE);//设定无限循环
animation.setRepeatMode(Animation.RESTART);
iv.startAnimation(animation);
}
}


也可以自定义view继承于imageview,启动一个线程,在while循环里设置view的旋转角度


{

privatefloatmCurDegree=0;//当前旋转角度
publicRotateView(Contextcontext,AttributeSetattrs){
super(context,attrs);
newThread(this).start();
}

@Override
protectedvoidonLayout(booleanchanged,intleft,inttop,intright,
intbottom){
super.onLayout(changed,left,top,right,bottom);
//设定旋转中心
setPivotX(getMeasuredWidth()/2);
setPivotY(getMeasuredHeight()/2);
}

@Override
publicvoidrun(){
while(true){
setRotation(mCurDegree);
mCurDegree+=5;
postInvalidate();
SystemClock.sleep(16);
}
}
}

在布局文件里使用RotateView代替imageview即可

⑦ Android 如何通过帽子右下角的按钮来控制图片的缩放和旋转

Android中对图片处理应用比较常见,所以整理了一些对图片的基本操作处理功能方法:
/**
* 图片反转
* @param img
* @return
*/
public Bitmap toturn(Bitmap img){
Matrix matrix = new Matrix();
matrix.postRotate(90); /*翻转90度*/
int width = bitmap.getWidth();
int height =bitmap.getHeight();
img = Bitmap.createBitmap(img, 0, 0, width, height, matrix, true);
return img;
}
/**
* 图片缩放
* @param bigimage
* @param newWidth
* @param newHeight
* @return
*/
public Bitmap tochange(Bitmap bigimage,int newWidth,int newHeight){
// 获取这个图片的宽和高
int width = bigimage.getWidth();
int height = bigimage.getHeight();
// 创建操作图片用的matrix对象
Matrix matrix = new Matrix();
// 计算缩放率,新尺寸除原始尺寸
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
// 缩放图片动作
matrix.postScale(scaleWidth, scaleHeight);
Bitmap bitmap = Bitmap.createBitmap(bigimage, 0, 0, width, height,matrix, true);
return bitmap;
}

/**
* 程序切割图片
* @param bitmap
* @param x
* @param y
* @param w
* @param h
* @return
*/
public Bitmap BitmapClipBitmap(Bitmap bitmap,int x, int y, int w, int h) {
return Bitmap.createBitmap(bitmap, x, y, w, h);
}
/**
* 图片叠加
* @param b
* @return
*/
public Bitmap diejia(Bitmap b){

if(!b.isMutable()){

热点内容
4k无压缩 发布:2025-05-15 06:02:54 浏览:74
hp存储6350 发布:2025-05-15 05:40:41 浏览:233
怎么更改电脑默认缓存位置 发布:2025-05-15 05:39:01 浏览:877
安卓qq公孙离在哪个战区战力最低 发布:2025-05-15 05:38:58 浏览:493
androidffmpeg压缩 发布:2025-05-15 05:37:02 浏览:288
ftp简称是 发布:2025-05-15 05:37:02 浏览:121
光遇发光耳机怎么设置安卓 发布:2025-05-15 05:32:03 浏览:113
台电安卓平板系统太低怎么办 发布:2025-05-15 05:20:00 浏览:510
安装了zlib编译报错 发布:2025-05-15 05:19:56 浏览:168
二分算法无序 发布:2025-05-15 05:18:22 浏览:30