旋转图像但图像颜色暗且图像变形
我想旋转图像更多时间,但我不能在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();
}
通过图像旋转得很好,但是图像变形,非常难看,你能告诉我为什么吗,并给出给我一个好方法,谢谢
i want to rotate i image more time,and i cannot to do it in the onDraw Method,my code is:
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();
}
through the image rotate very well,but the image is deformation,it is very ugly ,can you tell me why,and give me a good method,thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用
setAntiAlias(true)
或者
Try using the
setAntiAlias(true)
Or
我已经使用了@user7777方法,并修改 Paint Paint = new Paint();
Paint.setAntiAlias(true);然后旋转图像的中心旋转,图像变形发生了一点变化,我看看 围绕画布中的中心点旋转图像
i have used @user7777 methods ,and modify Paint paint = new Paint();
paint.setAntiAlias(true); then rotate the center of the image rotate ,the image-deformation is changed little alos i look at rotate image in around its center point in canvas