本文主要是介绍基于双三次插值算法(bicubic interpolation)实现的unity图片压缩算法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
如题
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
这篇关于基于双三次插值算法(bicubic interpolation)实现的unity图片压缩算法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!