Beispiel #1
0
        private (byte a, byte r, byte g, byte b) PoolMean3(LockBitmap4Pointer bitmap, int startX, int xLength, int startY, int yLength)
        {
            var a     = 0;
            var r     = 0;
            var g     = 0;
            var b     = 0;
            var index = 0;

            for (var x = startX; x < startX + xLength && x < _width; x++)
            {
                for (var y = startY; y < startY + yLength && y < _height; y++)
                {
                    var color = bitmap.GetPixel(x, y);
                    a += color.A;
                    r += color.R;
                    g += color.G;
                    b += color.B;
                    index++;
                }
            }

            _valueSumOfColor[0] += a;
            _valueSumOfColor[1] += r;
            _valueSumOfColor[2] += g;
            _valueSumOfColor[3] += b;
            return((byte)(a / index), (byte)(r / index), (byte)(g / index), (byte)(b / index));
        }
Beispiel #2
0
        private float PoolMean(LockBitmap4Pointer bitmap, int startX, int xLength, int startY, int yLength)
        {
            var result = 0f;
            var index  = 0;

            for (var x = startX; x < startX + xLength && x < _width; x++)
            {
                for (var y = startY; y < startY + yLength && y < _height; y++)
                {
                    result += bitmap.GetPixel(x, y).ToArgb();//.GetBrightness();
                    index++;
                }
            }

            _valueSum += result;
            return(result / index);
        }
Beispiel #3
0
        private float PoolMax(LockBitmap4Pointer bitmap, int startX, int xLength, int startY, int yLength)
        {
            var result = 0f;

            for (var x = startX; x < startX + xLength && x < _width; x++)
            {
                for (var y = startY; y < startY + yLength && y < _height; y++)
                {
                    var light = Math.Abs(bitmap.GetPixel(x, y).ToArgb());//.GetBrightness();
                    if (result < light)
                    {
                        result = light;
                    }
                    _valueSum += light;
                }
            }

            return(result);
        }
Beispiel #4
0
        private (byte a, byte r, byte g, byte b) PoolMax3(LockBitmap4Pointer bitmap, int startX, int xLength, int startY, int yLength)
        {
            var a = 0;
            var r = 0;
            var g = 0;
            var b = 0;

            for (var x = startX; x < startX + xLength && x < _width; x++)
            {
                for (var y = startY; y < startY + yLength && y < _height; y++)
                {
                    var color = bitmap.GetPixel(x, y);
                    if (a < color.A)
                    {
                        a = color.A;
                    }
                    if (r < color.R)
                    {
                        r = color.R;
                    }
                    if (g < color.G)
                    {
                        g = color.G;
                    }
                    if (b < color.B)
                    {
                        b = color.B;
                    }
                    _valueSumOfColor[0] += color.A;
                    _valueSumOfColor[1] += color.R;
                    _valueSumOfColor[2] += color.G;
                    _valueSumOfColor[3] += color.B;
                }
            }

            return((byte)a, (byte)r, (byte)g, (byte)b);
        }