简体   繁体   English

如何将“画布”设置为非透明图像?

[英]How to set Canvas to Non-transparent Image?

I have a bitmap of size 400*100. 我有一个大小为400 * 100的位图。 Now i want to increase the bitmap size to 400*200 with empty white space on bottom. 现在我想将位图的大小增加到400 * 200,底部留空白。 i tried the below code, but its creating transparent space, not white space. 我尝试了下面的代码,但是它创建了透明的空间,而不是空白。

=== My Code === ===我的代码===

// oldBitMap size are 400(width) and 100(height)

Bitmap newBitmap = Bitmap.createBitmap(400, 200, oldBitMap.getConfig());

Canvas canvas = new Canvas(newBitmap);

canvas.drawColor(Color.WHITE);

canvas.drawBitmap(oldBitMap, 0, 0, null);

Help Please.... 请帮助....

Try changing the first line to: 尝试将第一行更改为:

Bitmap newBitmap = Bitmap.createBitmap(400, 200, Bitmap.Config.ARGB_8888);

The only thing I can come up with is the original bitmap having a bad config. 我唯一能想到的就是配置错误的原始位图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM