Exemple #1
0
        public EmugenImage Filter(EmugenPlaneImage plane, UInt64 div)
        {
            var hw = plane.width / 2;
            var hh = plane.height / 2;

            var newImage = new EmugenImage(this.width, this.height);

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    //var pos = (x + y * width);
                    //colors[pos].WriteUnityEngineColor(ref ucolors[pos]);
                    var col = new Color(0, 0, 0, 0);
                    for (var fx = 0; fx < plane.width; fx++)
                    {
                        for (var fy = 0; fy < plane.height; fy++)
                        {
                            //var fi = fx + fy * plane.width;
                            //Debug.Log($"DD {fx} {fy}");
                            var fcol   = plane.At(fx, fy);
                            var tx     = x + fx - hw;
                            var ty     = y + fy - hh;
                            var colSrc = At(tx, ty);
                            //var col = new Color(  )
                            col.a += colSrc.a * (UInt64)fcol;
                            col.r += colSrc.r * (UInt64)fcol;
                            col.g += colSrc.g * (UInt64)fcol;
                            col.b += colSrc.b * (UInt64)fcol;
                        }
                    }
                    col.a = col.a / div; if (col.a > 255)
                    {
                        col.a = 255;
                    }
                    col.r = col.r / div; if (col.r > 255)
                    {
                        col.r = 255;
                    }
                    col.g = col.g / div; if (col.g > 255)
                    {
                        col.g = 255;
                    }
                    col.b = col.b / div; if (col.b > 255)
                    {
                        col.b = 255;
                    }
                    newImage.SetColor(x, y, col);
                }
            }
            return(newImage);
        }