Save Texture of RawImage after a new uvRect

Hi,

I want to save the texture of my RawImage but the result is inverted.
I try to apply a uvRect to flip the image before saving and, I see to image flip on screen, but the image.jpg is still inverted. No mater what I do with the uvRect I see no change on image.jpg.

There is my code :

    Texture2D TextureToTexture2D(Texture texture)
    {
        Texture2D texture2D = new Texture2D(texture.width, texture.height, TextureFormat.RGBA32, false);
        RenderTexture currentRT = RenderTexture.active;
        RenderTexture renderTexture = RenderTexture.GetTemporary(texture.width, texture.height, 32);

        Graphics.Blit(texture, renderTexture);

        RenderTexture.active = renderTexture;

        texture2D.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0);
        texture2D.Apply();

        //texture2D = FlipTexture(texture2D);

        RenderTexture.active = currentRT;
        RenderTexture.ReleaseTemporary(renderTexture);

        return texture2D;
    }

    myRawImage.uvRect = new Rect(myRawImage.uvRect.x, myRawImage.uvRect.y, myRawImage.uvRect.width, -myRawImage.uvRect.height);
    Texture2D textureToSave = TextureToTexture2D(myRawImage.texture);
    byte[] bytes = textureToSave.EncodeToJPG();
    System.IO.File.WriteAllBytes(@"C:\Test\" + "Image_JPG.jpg", bytes);
    break;

It’s ok I find an other way.

No more need of uvRect and
I add this function :

void FlipTexture(ref Texture2D texture)
{
int textureWidth = texture.width;
int textureHeight = texture.height;

Color32[ ] pixels = texture.GetPixels32();

for (int y = 0; y < textureHeight; y++)
{
int yo = y * textureWidth;
for (int il = yo, ir = yo + textureWidth - 1; il < ir; il++, ir–)
{
Color32 col = pixels[il];
pixels[il] = pixels[ir];
pixels[ir] = col;
}
}
texture.SetPixels32(pixels);
texture.Apply();
}