如题
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 - dx);
for (int l = -1; l <= 2; l++)
{

本文探讨了如何在Unity引擎中利用双三次插值算法(bicubic interpolation)来优化图片压缩的过程,通过这种方法提高图像质量的同时降低资源占用。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



