Android的:如何叠加一个位图/画,在一个位图?

编程入门 行业动态 更新时间:2024-10-27 01:22:53
本文介绍了Android的:如何叠加一个位图/画,在一个位图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有两个问题实际上是:

I have two questions actually:

  • 是更好地绘制图像上的位图或创建一个位图资源,然后绘制了一个位图?性能方面...哪一个更好?
  • 如果我想画的东西在透明位图,我怎么会去这样做呢?
  • 如果我想覆盖一个透明位图在另一个,我会怎么做呢?
  • 对不起,长长的名单,但在学习的兴趣,我想探讨两个途径......

    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的:如何叠加一个位图/画,在一个位图?

    本文发布于:2023-08-02 03:45:04,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1274342.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:位图   在一   Android

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!