当前位置: 首页 > news >正文

运营的三个核心要素优化大师官网登录入口

运营的三个核心要素,优化大师官网登录入口,网络空间,wordpress默认页面设置方法在实际应用开发中&#xff0c;有时候需要通过代码对Texture进行缩放。 有两个方法&#xff0c;一个是通过控制宽高进行缩放&#xff0c;另一个是通过比例值进行等比例缩放。 1、控制宽高的方法&#xff1a; /// <summary>/// 纹理缩放方法一&#xff0c;指定宽高/// &…

在实际应用开发中,有时候需要通过代码对Texture进行缩放。

有两个方法,一个是通过控制宽高进行缩放,另一个是通过比例值进行等比例缩放。

1、控制宽高的方法:

/// <summary>/// 纹理缩放方法一,指定宽高/// </summary>/// <param name="tex">缩放原始纹理</param>/// <param name="scaledWidth">缩放后的宽度</param>/// <param name="scaledHeight">缩放后的纹理</param>/// <returns></returns>Texture2D ScaleTexture(Texture2D tex,int scaledWidth,int scaledHeight){// 创建缩放后的纹理tex = new Texture2D(scaledWidth, scaledHeight);// 将原始纹理的像素数据拷贝到缩放后的纹理RenderTexture renderTexture = RenderTexture.GetTemporary(scaledWidth, scaledHeight);RenderTexture.active = renderTexture;Graphics.Blit(sourceTexture, renderTexture);// 从RenderTexture中读取像素数据并应用到缩放后的纹理tex.ReadPixels(new Rect(0, 0, scaledWidth, scaledHeight), 0, 0);tex.Apply();// 释放临时的RenderTextureRenderTexture.active = null;RenderTexture.ReleaseTemporary(renderTexture);return tex;}

2、通过比例值进行等比例缩放:

 /// <summary>/// 纹理缩放方法二,等比例/// </summary>/// <param name="tex">原始纹理</param>/// <param name="ratio">比例</param>/// <returns></returns>public Texture2D ScaleTexture(Texture2D tex, float ratio){if (tex == null)return null;if (ratio <= 0)return tex;Color color;int scaledWidth = (int)(tex.width * ratio);int scaledHeight = (int)(tex.height * ratio);Texture2D newTex = new Texture2D(scaledWidth, scaledHeight, TextureFormat.RGB24, false);float newWidthGap = scaledWidth * ratio;float newHieghtGap = scaledHeight * ratio;for (int i = 0; i < newTex.height; i++){for (int j = 0; j < newTex.width; j++){color = tex.GetPixel((int)(j * (1 / ratio)), (int)(i * (1 / ratio)));newTex.SetPixel(j, i, color);}}return newTex;}

http://www.mmbaike.com/news/63439.html

相关文章:

  • 电商网站怎么制作推广平台网站热狗网
  • 无锡做app的公司有哪些google seo 优化招聘
  • 网站seo诊断分析报告竞价关键词排名软件
  • 网站建设服务兴田德润免费做网站怎么做网站链接
  • app网站建设可行性分析网络营销是网上销售吗
  • 温州网站提升排名seo系统是什么
  • 购物网站seo搜索引擎优化方案域名服务器ip地址查询
  • flash网站用什么做网络营销步骤
  • css做电影海报网站设计揭阳百度快照优化排名
  • 大气公司网站源码合肥网络科技有限公司
  • 泰州网站推广见效快厦门网站推广公司哪家好
  • 网站建设中遇到的问题sem是什么分析方法
  • php网站数据迁移花西子网络营销案例分析
  • 建站模板有操作后台的吗种子搜索神器下载
  • 用bootstrap做的网站搜索引擎seo优化平台
  • 在网上做黑彩网站会怎样东营优化公司
  • 恩施网站定制网站的收录情况怎么查
  • 在线制作书封网站信息流广告代运营
  • 怎样查看网站服务商小程序免费制作平台
  • 榆林做网站的公司市场推广计划方案模板
  • wifiu盘做网站网络营销企业案例分析
  • 哈尔滨做网站哪家好强网站地址ip域名查询
  • 地图网站制作seo网站排名优化服务
  • 网站设计与制作教程1seo 技术优化
  • pos机做网站推广线上营销平台
  • 做影视网站须要注意什么网络营销运营
  • 网站建市场营销计划方案
  • 深圳免费网站优化网络推广百度手机助手安卓版
  • wordpress 窗口浙江关键词优化
  • 定制网站哪家好百度怎么推广