我希望以顺时针方式和反时钟方式旋转图像.
我曾试过但不能同时旋转图像,
如果你知道的话,请给我解决问题的方法.
提前致谢……………..///
解决方法:
请使用以下代码
public class Rotateimage extends Activity {@OverrIDepublic voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_gallery); // or just load a resource from the res/drawable directory: Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.flo); // find the wIDth and height of the screen: display d = getwindowManager().getDefaultdisplay(); int x = d.getWIDth(); int y = d.getHeight(); // get a reference to the ImageVIEw component that will display the image: ImageVIEw img1 = (ImageVIEw)findVIEwByID(R.ID.imageVIEw1); // scale it to fit the screen, x and y swapped because my image is wIDer than it is tall Bitmap scaledBitmap = Bitmap.createScaledBitmap(myBitmap, y, x, true); // create a matrix object Matrix matrix = new Matrix(); matrix.postRotate(45, 90, 180); // create a new bitmap from the original using the matrix to transform the result Bitmap rotatedBitmap = Bitmap.createBitmap(scaledBitmap , 0, 0, scaledBitmap .getWIDth(), scaledBitmap .getHeight(), matrix, true); // display the rotated bitmap img1.setimageBitmap(rotatedBitmap);}}
总结 以上是内存溢出为你收集整理的在android中旋转图像全部内容,希望文章能够帮你解决在android中旋转图像所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)