【问题标题】:What's the difference between Bitmap, BitmapDrawable and Drawable?Bitmap、BitmapDrawable 和 Drawable 有什么区别?
【发布时间】:2015-11-26 01:37:17
【问题描述】:

我看到了这个答案:What is the difference between Bitmap and Drawable in Android?

谁能给出实际的解释?什么时候使用?优势劣势?

【问题讨论】:

  • 这样想:JPEG 和 PNG 是图像编码的两个例子。因此,当您处理图像时,您需要做两件事:解码图像(将流转换为像素)和渲染图像。 Bitmap 是关于编码/解码/操作像素的全部内容。 Drawable 就是将事物渲染到屏幕上以便您可以看到它们。 BitmapDrawable 汇聚于此。

标签: android performance android-drawable android-bitmap


【解决方案1】:

Bitmap 只是一个原样的图像。理想情况下,它将用于使用CanvasSurfaceView 或类似的东西在屏幕上绘制像素。

Drawable 是一个描述可以在屏幕上绘制的东西的类。

BitmapDrawableDrawable 的子类。这意味着它是一个Drawable 想要绘制图像。

通常android视图使用Drawable对象,所以Drawable的任何子类都是可以接受的,这意味着如果你想在View上使用Bitmap(原始像素)你需要创建一个@ 987654332@ 并传递给它。

【讨论】:

  • 我们也可以将Btmap 转换为Drawable 并将其作为背景传递给视图吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-09-24
  • 1970-01-01
  • 2019-09-21
  • 1970-01-01
  • 2011-10-18
  • 1970-01-01
  • 2010-09-29
相关资源
最近更新 更多