本文介绍了SurfaceView,绘制图像,减少大小,旋转图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我婉画一个图像(从摄像机获取)上surfaceview。图纸我想,以减少图像的尺寸图像后,更改触摸表面观影像的位置。旋转图像。目前,我吸取表面观的形象,但剩下的任务是如何没有这样做。请一些身体帮我。

感谢


解决方案

 公共无效的drawImage(帆布油画,位图的位图,诠释的x,INT Y,诠释rotationAngle,浮动scalingfactor){
        字模=新的Matrix();
        matrix.postRotate(rotationAngle,bitmap.getWidth()/ 2,bitmap.getHeight()/ 2);
        matrix.postScale(scalingfactor,scalingfactor,bitmap.getWidth()/ 2,bitmap.getHeight()/ 2);
        matrix.postTranslate(X,Y);
        canvas.drawBitmap(位图,矩阵,零);
    }

使用上述code旋转和缩放surfaceview形象。
如果scalingfactor 1.0F意味着,图像大小将是一样的。如果你想减少大小像使用0.5F。
rotationAngle是0到360

I wan to draw a image (get from camera) on surfaceview. After drawing the image i want to reduce the size of the image, change the image location on surface view with touch. rotate the image. currently i draw the image on surface view but how the remaining task is not done. Please some body help me.

Thanks

解决方案
public void drawImage(Canvas canvas, Bitmap bitmap, int x, int y, int rotationAngle, float scalingfactor){
        Matrix matrix = new Matrix();
        matrix.postRotate(rotationAngle, bitmap.getWidth()/2, bitmap.getHeight()/2);
        matrix.postScale(scalingfactor, scalingfactor, bitmap.getWidth()/2, bitmap.getHeight()/2);
        matrix.postTranslate(x, y);
        canvas.drawBitmap(bitmap, matrix, null);
    }

Use above code to rotate and scaling image in surfaceview.if scalingfactor 1.0f means, image size will be same. If you want to reduce the size use like 0.5f.rotationAngle is 0 to 360

这篇关于SurfaceView,绘制图像,减少大小,旋转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 14:44