- Home /
How reduce size of texture?
I render camera to texture (renderedTexture.ReadPixels(Rect (0, 0, Screen.width, Screen.height), 0, 0);) and i want send this texture over network to app on mobile ,but texture slow load from bytes on mobile. (I render to texture format RGB24 and before send ,encode to jpg) Render texture with resolution 1024x600 have size 1,8 MB ,how reduce it? (sorry for my english)
Answer by devil304 · Dec 04, 2014 at 07:20 AM
Saved jpg (using EncodeToJPG(50)) have size ~50KB ,mybe I will not do anything more. Thanks for help.
Answer by zharik86 · Nov 30, 2014 at 07:49 PM
If I correctly understood, you want to make from texture of 1024x600, for example, 512x300. Use (write on CSharp):
int newW = renderedTexture.width / 2;
int newH = renderedTexture.height / 2;
renderedTexture.Resize(newW, newH, renderedTexture.format, false);
renderedTexture.Apply();
I hope that it will help you.
I want reduce size in memory without resize texture ,but with this script may change texture format into RGB16 ?
@devil304 Of course, you can use RGB16 format:
renderedTexture.Resize(newW, newH, TextureFormat.RGB565, false);
Each created texture in Unity is bmp (or you can encode it to png). You need convert bmp/png to jpg. See this links from forum. If I'm not mistakes, System.Drawing namespace not supported in Unity. You can copy this dll into Assets folder and tried converting to jpg. But it's, maybe, bad.
Thanks ,this is it what I need. (I encode texture to jpg befor send to other devices without this plugin. bytes = renderedTExture.EncodeToJPG();)
@devil304 Are your texture have gray after resize or after compression in jpg?
Your answer
![](https://koobas.hobune.stream/wayback/20220613172817im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Assigning UV Map to model at runtime 0 Answers
can any one tell me log file not showing my textures and other sizes 1 Answer
Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer
Loading texture file from png/jpg file on disk 5 Answers
Simple mesh deformation : Mesh.vertices or vertex shader with displacement texture ? 1 Answer