Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我记得不久前阅读了有关执行getPixel()-ish 方法的另一种(又名更快)方法。
getPixel()
问题是,我不记得我在哪里读到的,而且我已经彻底搜索过……我想。
答案与将 Bitmap 锁定在内存中或类似的东西有关。
我需要getPixel()“按滴答”运行多次,这看起来非常昂贵。
有人知道我在说什么吗?
您可能正在考虑Bitmap.getPixels(),它将位图的任何部分复制到一个数组中。从那时起,您可以使用简单的数组访问直接访问任何像素,这比Bitmap.getPixel()多次调用要快得多。
Bitmap.getPixels()
Bitmap.getPixel()
您将在这里面临性能与内存的决定:如果您需要大量查询像素并且您的位图很少更改,请保留该数组(以将该数组保存在内存中为代价)。如果没有,尽快释放对阵列的兴趣,以确保在必要时可以收集。显然,避免调用getPixels()很多 - 想法是调用一次,然后多次查询数组。
getPixels()