Skip to content

图片多时会卡,最大的瓶颈就在那一行 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ni-ken opened this issue Aug 3, 2018 · 2 comments
Open

图片多时会卡,最大的瓶颈就在那一行 #2

ni-ken opened this issue Aug 3, 2018 · 2 comments

Comments

@ni-ken
Copy link

ni-ken commented Aug 3, 2018

Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false);
texture.LoadImage(data);

纹理创建和纹理数据载入不能在子线程中做,只能在主线程。一旦下载的图片是png、jpg等格式,LoadImage内部会解码元数据格式到ARGB32,这个是比较花费CPU的,所以图片多一些的时候,卡顿会很明显。好一点的做法考虑在收到http下载的图片数据后。自己写一个解码图片的函数在线程中计算解码。然后在主线程中把解码后的数据直接通过SetPixels或LoadRawTextureData。这样会减少卡顿。

@hcq0618
Copy link
Owner

hcq0618 commented May 17, 2019

你可以提交一个pr 然后进来 因为毕竟我已经几年没维护了

@hcq0618 hcq0618 mentioned this issue May 17, 2019
@BensonMaZIHao
Copy link

纹理 2D 纹理 = 新纹理 2D (宽度、 高度、纹理形式. ARGB32, 错误);
纹理。负载图像(数据);

纹理创建和纹理数据载入不能在子线程中做,只能在主线程。 一旦下载的图片是png、jpg等格式,LoadImage内部会解码元数据格式到ARGB32,这个是比较花费CPU的,所以图片多一些的时候,卡顿会很明显。 好一点的做法考虑在收到http下载的图片数据后。 自己写一个解码图片的函数在线程中计算解码。 然后在主线程中把解码后的数据直接通过SetPixels或LoadRawTextureData。 这样会减少卡顿。

你好这个问题拟解决了嘛,有好的解决方案嘛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants