基于双三次插值算法(bicubic interpolation)实现的unity图片压缩算法

本文探讨了如何在Unity引擎中利用双三次插值算法(bicubic interpolation)来优化图片压缩的过程,通过这种方法提高图像质量的同时降低资源占用。
摘要由CSDN通过智能技术生成

如题

using UnityEngine;

public class BicubicInterpolationResizer
{
    public static Texture2D Resize(Texture2D texture , int width , int high,bool isnew=false)
    {
        
        int sWidth = texture.width;
        int sHigh = texture.height;
        float dx, dy, bmdx, bndy;
        float tx = (float) sWidth / (float) width;
        float ty = (float) sHigh / (float) high;
        var rawData = texture.GetPixels32(0);
        
        Color[] newColor = new Color[width * high];
        for (int i = 0; i < high; i++)
        {
            for (int j = 0; j < width; j++)
            {
                int x = (int) (tx * j);
                int y = (int) (ty * i);
                dx = tx * j - x;
                dy = ty * i - y;
                
                for (int k = -1; k <= 2; k++)
                {
                    bmdx = BSpline(k
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值