Question by
BennyP · Nov 22, 2017 at 07:10 AM ·
androidrendertexturepng
RenderTexture to PNG on Android
Hi everyone,
I'm trying to render a png from a camera. I've been able to get it working on PC/Editor but when trying on android the rendering is wrong (fully grey or full transparent with some black lines..).
Here is the code to render :
RenderTexture camRT = bilanCam.targetTexture;
RenderTexture.active = camRT;
bilanCam.Render();
Texture2D printTex = new Texture2D(bilanCam.targetTexture.width, bilanCam.targetTexture.height, TextureFormat.ARGB32, false);
printTex.ReadPixels(new Rect(0f, 0f, bilanCam.targetTexture.width, bilanCam.targetTexture.height), 0, 0);
printTex.Apply();
The RenderTexture is setup : 2D, 1240x1754, no AA, ARGB32, No depth buffer, sRGB true, mipmaps false, calmp, bilinear, aniso level 0
I think it has something to do with texture format but I could not find a working one. Does anyone have already tried this ? maybe suggestion on the best format to use ?
Thanks.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612143136im_/https://answers.unity.com/themes/thub/images/avi.jpg)