Texture to texture2D以及texture2D像素反转
2024-08-25 06:00:44
private void SaveRenderTextureToPNG(Texture inputTex, string file)
{
RenderTexture temp = RenderTexture.GetTemporary(inputTex.width, inputTex.height, , 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(, , tex.width, tex.height), , );
RenderTexture.active = currentActiveRT;
return tex;
}
Color[] colors = tex.GetPixels(capx, capy, capwidth, capheight);
System.Array.Reverse(colors, , 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();
最新文章
- liunx 磁盘管理命令记录
- Windows.document
- iOS打包ipa给客户测试流程
- error while loading shared libraries: xxx.so.x";错误的原因和解决办法
- android之数据库SQLite(一)
- android百度地图中的地图缩放级别
- JS 提示框 alert()、confirm()、prompt()的三者的区别
- tarjan缩点
- getopt()函数
- Android绘图机制(一)——自定义View的基础属性和方法
- kuangbin带你飞dp专题-基础dp
- vue-文字块收缩与展开功能
- Hadoop集群及基本组件搭建
- sudo权限管理
- 微信、陌陌等著名IM软件设计架构详解(转)
- wpf-典型的mvvm模式通用中小型管理系统框架0
- semi-consistent简介
- centos7.x网卡bond配置
- AndroidのUI体验之上拉下拉
- 在SQL Server中调用.NET程序集
热门文章
- 基于操作系统原理的Linux 的用户管理
- springboot系列之02-需要了解的宏观知识点
- DocumentFormat.OpenXml read excel file
- c#学习路线应该靠谱
- 如何配置VMware客户虚拟机使用NAT模式联网通信
- laravel 5.5 运行在 php7.0 报错 Symfony\Component\Translation\Translator.php FatalThrowableErrorParse error: syntax error, unexpected &#39;?&#39;, expecting variable (T_VARIABLE)
- iOS渠道分包2种模式之包内注入文件分包
- 《构建之法》MSF&;需求分析
- Android中内存泄露与如何有效避免OOM总结
- 分享一个移动端rem布局的适配mixin