gpt4 book ai didi

java - 为什么 setPixel 在 android lollipop 中比在 android KitKat 中慢

转载 作者:行者123 更新时间:2023-11-30 08:43:25 26 4
gpt4 key购买 nike

我想将应用程序从 android kitkat 移植到 lollipop,我发现 setPixel 在 lollipop 中变慢了。

app的作用只是从buffer中绘制Bitmap;然而,在 android lollipop 中它需要大约 15 倍的时间。

如何改进我的代码?谢谢。

public Bitmap draw(byte[] buffer) {
Bitmap pic = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888);

for (int i = 0; i < 150; i++) {
for (int j = 0; j < 180; j++) {
byte temp = (byte) (buffer[(i*180 + j)]);
int color=0xff000000;
color = color ^ temp << 24;
pic.setPixel(i+10, j+10, color);
}
}
return pic;
}

最佳答案

如果您要设置多个像素,您应该始终使用 setPixels()而不是单独调用 setPixel()

关于java - 为什么 setPixel 在 android lollipop 中比在 android KitKat 中慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34280197/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com