Пример #1
0
 protected static Color[] TextureResizeBase(Color[] colorsOrigin, int oldW, int oldH, int newW, int newH)
 {
     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    = SWTextureProcess.TexUV(newW, newH, i, j);
             colorsNew[index] = SWTextureProcess.GetColor_UV(oldW, oldH, colorsOrigin, uv);
         }
     }
     return(colorsNew);
 }
Пример #2
0
        public static SWTexture2DEx TextureResize(Texture2D tex, int newWidth, int newHeight)
        {
            SWTexture2DEx newTex       = SWCommon.TextureCreate(newWidth, newHeight, TextureFormat.ARGB32);
            var           colorsOrigin = tex.GetPixels();
            var           colors       = newTex.GetPixels();

            for (int i = 0; i < newWidth; i++)
            {
                for (int j = 0; j < newHeight; j++)
                {
                    Vector2 uv    = SWTextureProcess.TexUV(newWidth, newHeight, i, j);
                    int     index = TexUV2Index(newTex.width, newTex.height, uv);
                    colors[index] = SWTextureProcess.GetColor_UV(tex.width, tex.height, colorsOrigin, uv);
                }
            }
            newTex.SetPixels(colors);
            newTex.Apply();
            return(newTex);
        }
        protected override void ThreadMission_Pixel(int i, int j)
        {
            base.ThreadMission_Pixel(i, j);
            Vector2 uv     = SWTextureProcess.TexUV(texSrcWidth, texSrcHeight, i, j);
            Vector2 fromUV = uv - offset;
            Vector2 dis    = fromUV - uv;
            float   alpha  = 0;
            float   pcg    = 0;
            Color   c      = SWTextureProcess.GetColor_UV(texSrcWidth, texSrcHeight, texSrcColorBuffer, uv);
            Color   c2     = SWTextureProcess.GetColor_UV(texSrcWidth, texSrcHeight, texSrcColorBuffer, uv - dis.normalized * 3f / 512f);
            Vector2 newUV  = uv - dis.normalized * pixelBack / 512f;
            int     newI   = 0;
            int     newJ   = 0;

            SWTextureProcess.TexUV2Index(texSrcWidth, texSrcHeight, newUV, ref newI, ref newJ);
            if (!IsImage(c) && !IsImage(c2))
            {
//				int index = 0;
                while (pcg <= 1)
                {
                    Vector2 xuv    = uv + dis * pcg;
                    Color   xColor = SWTextureProcess.GetColor_UV(texSrcWidth, texSrcHeight, texSrcColorBuffer, xuv);
                    Vector2 xpos   = uv;
                    xpos -= center;
                    xpos  = matrix.MultiplyPoint(xpos);
                    xpos += center;
                    if (xColor.a > 0)
                    {
                        alpha = pcg;
                        float g = alpha;
                        float b = 0;
                        float a = GreenToAlpha(g);
                        texColorBuffer [(texSrcHeight - newJ - 1) * texSrcWidth + newI] = new Color(xpos.x, alpha, b, a);
                        break;
                    }


                    pcg += accuracyUnit;
                }
            }
        }