• Texture to texture2D以及texture2D像素反转


        private void SaveRenderTextureToPNG(Texture inputTex, string file)
        {
            RenderTexture temp = RenderTexture.GetTemporary(inputTex.width, inputTex.height, 0, RenderTextureFormat.ARGB32);
            Graphics.Blit(inputTex, temp);
            Texture2D tex2D = GetRTPixels(temp);
            RenderTexture.ReleaseTemporary(temp);
            File.WriteAllBytes(file, tex2D.EncodeToPNG());
        }
    
        private Texture2D GetRTPixels(RenderTexture rt)
        {
            RenderTexture currentActiveRT = RenderTexture.active;
            RenderTexture.active = rt;
            Texture2D tex = new Texture2D(rt.width, rt.height);
            tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);
            RenderTexture.active = currentActiveRT;
            return tex;
        }
                Color[] colors = tex.GetPixels(capx, capy, capwidth, capheight);
                System.Array.Reverse(colors, 0, colors.Length);
    
    
                Texture2D t = new Texture2D(capwidth, capheight, TextureFormat.RGB24, true);
                //Debug.Log("Pixel size:" + capx + " " + capy + " " + capwidth + " " + capheight);
                //t.ReadPixels(new Rect(capx, capy, capwidth, capheight), 0, 0, false);
    
                //for (int i = 0; i < capwidth; i++)
                //{
                //    for(int j=0;j<capheight;j++)
                //    {
                //        Color temp = t.GetPixel(i, j);
                //        t.SetPixel(i,j,)
                //    }
                //}
    
                t.SetPixels(colors);
                t.Apply();
  • 相关阅读:
    25.Zabbix入门必备
    6.Ansible Roles角色实战
    5.Ansible Jinja2 模板
    4.Ansible Task控制
    3.Ansible varialbes实战
    2.Ansible Playbook剧本
    1.Ansible自动化管理工具
    网站架构面试题必备
    winsows CMD及Linux命令大全 欢迎补充
    Oracle查询表空间
  • 原文地址:https://www.cnblogs.com/llstart-new0201/p/8359013.html
Copyright © 2020-2023  润新知