复制一个位图到另一个preserving透明度 [英] copy one bitmap into another preserving transparency

查看:128
本文介绍了复制一个位图到另一个preserving透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图为PNG复制到另外一个

I am trying to copy a png to another one

Bitmap overlay = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.logo);
Buffer buf = new Buffer
overlay.copyPixelsToBuffer(buf);
myImage.copyPixelsFromBuffer(buf);

我不知道我必须使用有什么样的缓冲区,也是我不知道这是正确的做法。此外,当复制到新位图没有偏移参数?

I am not sure what kind of buffer do I have to use there and also I dont know if this is the correct approach. Also, no offset parameter when copying into the new bitmap?

谢谢,对不起我的noobish问题:•

Thanks and sorry for my noobish questions :S

推荐答案

这是用帆布单向

Bitmap overlay = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.logo);
Bitmap background = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.bgr).copy(Bitmap.Config.ARGB_8888, true); 

Canvas canvas = new Canvas(background);

canvas.drawBitmap(overlay, 10, 10, null);

return background;

这篇关于复制一个位图到另一个preserving透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆