- Home /
Load image in runtime from jpg
If i load image to unity from jpg or png files. Image consumes great memory. And after 1.2-1.3 GB memory usage(not total ie usage) web player crashing(The content was stopped because a fatal content error has been detected).
Converting image to DXT1 not effective and as i learn compress in runtime almost not possible(Texture2D.compress too).
A 4096x4096 texture killing ~80-100MB system memory(load from jpg and no alpha also converted to DXT1).
Only way load from AssetBundle? And Why ~1.2 GB memory usage a limit for web application? Sure if there is no way to load image from jpg with low memory usage, i will look for alternative ways. But why memory usage have a limit or crash? (My total system memory big enough for more and using 64 bit system)
Texture2D tex = new Texture2D(4096, 4096, TextureFormat.RGB24, false); www.LoadImageIntoTexture(tex);
try to load images in this way. it should takes exactly 48$$anonymous$$B per texture,
also:
try this case in different browsers
try this case in standalone appilcation with same web loading
more bad 3 texture and reached ~0.5 GB. ~120 $$anonymous$$B per texture. again same result ~1.2 GB crashing. Standalone appilcation not crashed but using huge memory (same rate). Need working on ie too. Without ie not useful.
Yeah i dont know how it taking 2x more memory then our expect. I am used www.Dispose() too. i think only material texture using that size, no leak in code.
Converting DXT externally and download will save memory usage but it will req lots download size. (tested with DDS file it consumed ~10 $$anonymous$$B)
Use asset bundle / download in zip or rar file (for reduce size) are only ways i think. $$anonymous$$aybe i should ask for how to open zip/rar file? Or any suggestion about free file sharing site? (with direct download link) or DDS photo sharing site lol :D
I think my web application will req lots bantwidth because of images :D or maybe i should put images in build.
I wanted to download and assign textures in time. And fast loading for use. i could add low res textures until that high res images loading. But no way to load 18x 4096x4096 textures.
2 $$anonymous$$B jpg file consu$$anonymous$$g 120 $$anonymous$$B ram perfect :S I am sure a jpg file shouldnt consume lots memory like that. Something must be wrong.
Answer by ScroodgeM · Aug 03, 2012 at 04:24 PM
create an asset bundle (-s) with a textures imported by Unity and load them in bundles
http://docs.unity3d.com/Documentation/ScriptReference/AssetBundle.html
this should not use any additional converting/unpacking in runtime and store it packed.