二维码生成、二维码识别、生成对应小鱼模型、摄像图截图保存本地、读取本地图片替换模型贴图、裁剪

Plugins文件夹里放这三个
在这里插入图片描述

using System.IO;
/// <summary>
/// 保存替换贴图
/// </summary>
public class CameraTextureSave : MonoBehaviour
{
   
   public static void SaveOne(WebCamTexture t,int frame,int w,int h)
    {
   
        Texture2D t2d= new Texture2D(w, h, TextureFormat.ARGB32, true);
        Vector2 offset = new Vector2((t.width - w) / 2, (t.height - h) / 2);
        t2d.SetPixels(t.GetPixels((int)offset.x, (int)offset.y, w, h));
        t2d.Apply();
        //编码
        byte[] imageTytes=t2d.EncodeToJPG();
        //存储
        File.WriteAllBytes(@"Assets\Resources\myTexture1.jpg", imageTytes);
    }
    public static void SaveTwo(WebCamTexture t,int frame,int w=850,int h=550)
    {
   
        Texture2D texture=new Texture2D(w,h, TextureFormat.ARGB32,true);
        Vector2 offset=new Vector2((t.width-w)/2,(t.height-h)/2);        
        texture.SetPixels(t.GetPixels((int)offset.x,(int)offset.y,w,h));
        texture.Apply();
        byte[] imageTytes = texture.EncodeToJPG();
        File.WriteAllBytes(@"Assets\Resources\myTexture2.jpg", imageTytes);
    }
}
using System.Collections;
using System.Collections.Generic<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值