- Home /
EncodeToJPG is too slow. Blocking main thread.Is there new way alternative?
private byte[] EncodingJPG(Texture2D texture2D)
{
byte[] bytes = texture2D.EncodeToJPG(20);
return bytes;
}
EncodeToJPG is too slow. Blocking main thread.I have already tried Coroutine,but still very slow.If I need to execute this method continuously,What should I do?
Coroutines run on the main thread as well, so that won't help. You would need to run it on a separate thread for it to not block, but I'm not sure Unity will allow to access the memory of a Texture2D
on a separate thread.
It seems there is a newer API call ImageConversion.EncodeToJPG(). $$anonymous$$aybe that is faster?
From what I have seen, you can't put EncodeToJPG in another thread. $$anonymous$$aybe there is an other way to to do this, maybe it is faster. Try what @Harinezumi suggested, it might be faster.
Do you by any chance have a solution for this? A simple c# jpeg encoder that takes a byte / color array in would be sufficient
Your answer
Follow this Question
Related Questions
EncodeNativeArrayToJPG 0 Answers
load .png/.jpg from .txt-file 2 Answers
Any way to show a picture on the screen when a model is clicked? 2 Answers
IOS Game running slow on iPhone(Loading.UpdatePreloading) 0 Answers
unity running extremely slow 0 Answers