在 Android 开发中,Bitmap 非常的常用,bitmap 和 int 数组之间也常常需要转换。

可是,有的时候,我们更需要byte数组的数据,怎样才能方便的把 Bitmap 转换成 byte 数组呢。

这里有一个简单的办法,但是需要借助一下 Renderscript:

Renderscript 有一个类型是表示内存的,它就是 Allocation。我们只要把 Bitmap 数据拷贝到 Allocation 中,然后在从 Allocation 拷贝到一个 byte 数组,就可以轻而易举的获得对应图像的 byte array 数据了。

相关文章:

  • 2022-12-23
  • 2021-08-16
  • 2022-01-15
  • 2022-12-23
  • 2021-09-26
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-02-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案