Android的:如何叠加一个位图/画,在一个位图? [英] Android: How to overlay-a-bitmap/draw-over a bitmap?

查看:153
本文介绍了Android的:如何叠加一个位图/画,在一个位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个问题实际上是:

I have two questions actually:

  1. 是更好地绘制图像上的位图或创建一个位图资源,然后绘制了一个位图?性能方面...哪一个更好?
  2. 如果我想画的东西在透明位图,我怎么会去这样做呢?
  3. 如果我想覆盖一个透明位图在另一个,我会怎么做呢?

对不起,长长的名单,但在学习的兴趣,我想探讨两个途径......

Sorry for the long list, but in the interest of learning, I would like to explore both the approaches...

推荐答案

我不能相信没有人已经回答了这个呢!一种罕见的发生在如此!

I cant believe no-one has answered this yet! A rare occurrence on SO!

问题没有引起太大意义,我。但生病给它刺伤。 如果你问有关直接绘制在画布(多边形,底纹,文字等)VS加载位图和位图传输到这将取决于您的绘图的复杂性,在画布上。 如附图变得更加复杂所需的CPU时间将相应增加。 然而,位块传输的位图到画布上永远是​​恒定的时间成比例的所述位图的大小。

Question doesn't quite make sense to me. But ill give it a stab. If you're asking about direct drawing to a canvas (polygons, shading, text etc...) VS loading a bitmap and blitting it onto the canvas that would depend on the complexity of your drawing. As the drawing gets more complex the CPU time required will increase accordingly. However, blitting a bitmap onto a canvas will always be a constant time which is proportional to the size of the bitmap.

不知道是什么东西是我怎么能告诉你该怎么办呢? 你应该能够找出#2的答案#3。

Without knowing what "something" is how can i show you how to do it? You should be able to figure out #2 from the answer for #3.

假设:

  • BMP1是两个
  • 的大
  • 您希望他们无论从左上角覆盖。

  • bmp1 is the bigger of the two
  • you want them both overlaid from the top left corner.

    private Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
        Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
        Canvas canvas = new Canvas(bmOverlay);
        canvas.drawBitmap(bmp1, new Matrix(), null);
        canvas.drawBitmap(bmp2, new Matrix(), null);
        return bmOverlay;
    }

这篇关于Android的:如何叠加一个位图/画,在一个位图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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