我想旋转图像更多的时间,但我不能在onDraw方法中做到这一点,我的代码是:
options = new BitmapFactory.Options();
options.inScaled = false;
options.inJustDecodeBounds = false;
options.inDither = false;
options.inScaled = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
public void setAddBmpImage(int rotate) {
byte[] by = getBitmapByte(rotatedBitmap);
Bitmap source = BitmapFactory.decodeByteArray(by, 0, by.length, options);
Bitmap bmpSephia = Bitmap.createBitmap(rotatedBitmap.getWidth(), rotatedBitmap.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmpSephia);
canvas.rotate(rotate);
canvas.drawBitmap(source, 0, 0, null);
rotatedBitmap= bmpSephia;
imageStartX = (screenWidth / 2 - rotatedBitmap.getWidth() / 2);
imageStartY = (screenHeight / 2 - rotatedBitmap.getHeight() / 2);
invalidate();
}通过图像旋转得很好,但是图像是变形的,很难看,你能告诉我为什么吗,并给我一个好的方法,谢谢
发布于 2011-08-12 17:31:13
尝试使用setAntiAlias(true)
Canvas canvas = new Canvas(bmpSephia);
canvas.rotate(rotate);
Paint paint = new Paint();
paint.setAntiAlias(true);
canvas.drawBitmap(source, 0, 0, paint);或
BitmapDrawable bmdraw = new BitmapDrawable(bmpSephia);
bmdraw.setAntiAlias(true);
Canvas canvas = new Canvas(bmdraw.getBitmap());
canvas.rotate(rotate);发布于 2011-08-13 10:59:03
我已经使用了@user7777方法,并修改了Paint paint = new Paint();paint.setAntiAlias(真);然后旋转图像的中心旋转,图像变形也发生了很小的变化,我看着rotate image in around its center point in canvas
https://stackoverflow.com/questions/7037321
复制相似问题