Android:在画布上绘制位图时的图像分辨率问题
在画布上绘图时,如果我使用此代码来绘制位图,那么它会被拉伸。
代码1:
photoBitmap = Bitmap.createScaledBitmap(tempBitmap, display.getWidth(), display.getHeight(), true); // original
但是如果我使用下面的代码来绘制位图,那么位图不会被拉伸,但我只能得到图像左上角的某些部分。
代码2:
photoBitmap = Bitmap.createBitmap(tempBitmap);
现在,上面的两个代码都是用于创建/获取位图。并在画布上绘制位图,我使用下面的代码:
canvas.drawBitmap (photoBitmap,0, 0, null);// Original Without ImageView
现在,我应该做什么才能看到完整图像并且它不应该被拉伸。
谢谢。
On drawing on canvas if i use this code to draw the bitmap then it get stratched.
Code1:
photoBitmap = Bitmap.createScaledBitmap(tempBitmap, display.getWidth(), display.getHeight(), true); // original
But if i use below code to draw the bitmap then the Bitmap not getting stratched but i m only getting the some portion of top left corner of the Image.
Code2:
photoBitmap = Bitmap.createBitmap(tempBitmap);
Now, Above both code is for creating/getting the bitmap. and to draw the Bitmap on canvas i use below code:
canvas.drawBitmap (photoBitmap,0, 0, null);// Original Without ImageView
Now, What should i do to saw full image and it should not get stratch.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您要求做的是在两个方向上均匀拉伸位图,以便它适合显示器。试试这个:
It sounds like what you're asking to do is to stretch the bitmap in both directions equally so that it fits on the display. Try this: