Pinta.Core.Document.GetComputedPixel C# (CSharp) Method

GetComputedPixel() public method

Gets the final pixel color for the given point, taking layers, opacity, and blend modes into account.
public GetComputedPixel ( int x, int y ) : ColorBgra
x int
y int
return ColorBgra
        public ColorBgra GetComputedPixel(int x, int y)
        {
            using (var dst = new ImageSurface (Format.Argb32, 1, 1)) {
                using (var g = new Context (dst)) {
                    foreach (var layer in GetLayersToPaint ()) {
                        var color = layer.Surface.GetColorBgraUnchecked (x, y).ToStraightAlpha ().ToCairoColor ();

                        g.SetBlendMode (layer.BlendMode);
                        g.SetSourceColor (color);

                        g.Rectangle (dst.GetBounds ().ToCairoRectangle ());
                        g.PaintWithAlpha (layer.Opacity);
                    }
                }

                return dst.GetColorBgraUnchecked (0, 0);
            }
        }