protected static Color[] TextureResizeTRSBase(Color[] colorsOrigin, int oldW, int oldH, int newW, int newH, EffectData data) { Color[] colorsNew = new Color[newW * newH]; for (int i = 0; i < newW; i++) { for (int j = 0; j < newH; j++) { int index = XYtoIndex(newW, newH, i, j); Vector2 uv = TexUV(newW, newH, i, j); ////////////////////////////////////////////////////////////////////// bool hasCol = TexUVTRS(ref uv, data); colorsNew[index] = SWTextureProcess.GetColor_UVNoClamp(oldW, oldH, colorsOrigin, uv); if (!hasCol) { colorsNew [index] = new Color(0, 0, 0, 0); } ////////////////////////////////////////////////////////////////////// } } return(colorsNew); }
/// <summary> /// For mask's wand/dropper /// Resize node's tex and apply trs /// </summary> public static SWTexture2DEx TextureResizeTRS(Texture2D tex, int newWidth, int newHeight, EffectData data) { SWTexture2DEx newTex = SWCommon.TextureCreate(newWidth, newHeight, TextureFormat.ARGB32); var colors = TextureResizeTRSBase(tex.GetPixels(), tex.width, tex.height, newWidth, newHeight, data); newTex.SetPixels(colors); newTex.Apply(); return(newTex); }