如何从现有位图创建更大的位图
我有一张位图图像。如何以编程方式创建更大的位图?我尝试创建scaleBitMap,但它没有显示更大。
int newHeight=900;
Bitmap bg1=Bitmap.createScaledBitmap(bg, width, newHeight, false);
canvas.drawBitmap(bg1, null, new Rect(0, 0, getWidth(), newHeight), null);
我该如何解决这个问题?
I have one Bitmap image. How do I create a bigger bitmap programmatically? I tried creating scaleBitMap, but it is not displaying bigger.
int newHeight=900;
Bitmap bg1=Bitmap.createScaledBitmap(bg, width, newHeight, false);
canvas.drawBitmap(bg1, null, new Rect(0, 0, getWidth(), newHeight), null);
How do I fix this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
也许你应该尝试这个:
总是值得一试
Maybe you should try this instead:
always worth a try
Bitmap.createScaledBitmap() 正在执行您想要的操作,问题是当您尝试将其绘制到画布上时。 getWidth() 返回什么?将其余代码发布给我们一些背景信息,我们可以找到您的问题。
The Bitmap.createScaledBitmap() is doing what you want, the problem is when you're trying to draw it to the canvas. What is getWidth() returning? Post the rest of the code to give us some context and we can find your problem.
尝试这个代码...
然后在 onCreate 方法中使用这个...
Try this code...
then in onCreate method use this...