GetResultingColorIndex() public method

Gets resulting color when blending two others.
public GetResultingColorIndex ( byte overlaying, byte underlaying, TransparencyType type ) : byte
overlaying byte /// Foreground color. ///
underlaying byte /// Background color. ///
type TransparencyType /// Type of blending. ///
return byte
Beispiel #1
0
        private void ApplyBake(byte[] tobake)
        {
            int width  = Background.GetWidth();
            int height = Background.GetHeight();
            TransparencyTable trans = TransparencyTable;

            foreach (GraphicObject obj in Objects)
            {
                if (obj == null || obj.Image == null)
                {
                    continue;
                }
                for (int y = 0; y < obj.Image.GetHeight(); y++)
                {
                    for (int x = 0; x < obj.Image.GetWidth(); x++)
                    {
                        if (x + obj.Location.X >= 0 && y + obj.Location.Y >= 0 && x + obj.Location.X < width && y + obj.Location.Y < height)
                        {
                            byte color = obj.Image.ImageData[obj.Image.GetWidth() * y + x];
                            if (color == obj.TransparentIndex)
                            {
                                continue;
                            }
                            int index = width * (y + obj.Location.Y) + obj.Location.X + x;
                            if (trans == null || obj.Transparency == TransparencyType.None)
                            {
                                tobake[index] = color;
                            }
                            else
                            {
                                tobake[index] = trans.GetResultingColorIndex(color, tobake[index], obj.Transparency);
                            }
                        }
                    }
                }
            }
        }