使用 Canvas 和 canvas.scale(Scale, Scale); 的图像质量问题
我在使用 Canvas 和 canvas.scale(Scale, Scale); 时遇到图像质量问题它们看起来与以下内容完全相同:
android:在运行时调整大小的图像的质量
我相信我已经阅读了有关调整位图大小时图像质量问题的所有帖子,但在使用 Canvas 比例(浮动)进行缩放时似乎没有帮助规模)。
我按照图像质量帖子的建议尝试了许多不同的选项。
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = false;
options.inDither = false;
options.inSampleSize = 1;
options.inScaled = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;//I thought this would do it
CurrentPicture = BitmapFactory.decodeFile(path, options);//Also tried decodeStream()
PicturePaint = new Paint();
//PicturePaint = new Paint(Paint.FILTER_BITMAP_FLAG); //I also tried this
//PicturePaint = new Paint(Paint.ANTI_ALIAS_FLAG); //I also tried this
canvas.scale(Scale, Scale);
canvas.drawBitmap(CurrentPicture, 0, 0, PicturePaint);
我相信这是实现我的目标的最后障碍。我很担心,因为如果无法解决图像质量问题,我就会遇到麻烦。任何帮助表示赞赏。
谢谢!
系统不让我发图片,所以下面是一个链接。
I am having Image Quality problems using Canvas and canvas.scale(Scale, Scale); they look exactly like the following:
android: quality of the images resized in runtime
I believe I have read all the posts on image quality problems when re-sizing bitmaps, but it doesn't seem to help when scaling with a Canvas scale(float scale).
I have tried many different options as suggested by the image quality posts.
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = false;
options.inDither = false;
options.inSampleSize = 1;
options.inScaled = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;//I thought this would do it
CurrentPicture = BitmapFactory.decodeFile(path, options);//Also tried decodeStream()
PicturePaint = new Paint();
//PicturePaint = new Paint(Paint.FILTER_BITMAP_FLAG); //I also tried this
//PicturePaint = new Paint(Paint.ANTI_ALIAS_FLAG); //I also tried this
canvas.scale(Scale, Scale);
canvas.drawBitmap(CurrentPicture, 0, 0, PicturePaint);
I believe this the last barrier to achieving my goals. I am quite concerned as I am in trouble if I can't get the image quality problem solved. Any help is appreciated.
Thanks!
The system will not let me post a picture, so following is a link.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道我的答案是否正确,我有画布代码。我希望这可以帮助你。
I don't no whether my answer is correct or not i have a code for canvas. i wish this might help you.
您有可以显示您所说的质量问题的屏幕截图吗?如果在画图上启用过滤应该没问题。
Do you have a screenshot that would show the quality issue you are talking about? If filtering is enabled on the Paint it should be fine.
我尝试了很多很多代码。
我只是将其添加到我的清单中,我就得到了最好质量的图像。
我认为问题在于画布是以低分辨率创建的。如果您尝试在屏幕上打印设备的分辨率,您会发现它是错误的。
随着清单中的添加,分辨率发生变化。
I tried many and many code.
I just add this in my manifest and I had the best quality image.
I think the problem is the canvas is created in low resolution. If u try to print on the screen the resolution of your device, u can see it is wrong.
With the add in the manifest the resolution change.