예제 #1
0
        /// <summary>
        /// Gets the final pixel color for the given point, taking layers, opacity, and blend modes into account.
        /// </summary>
        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).ToCairoColor ();

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

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

                return dst.GetPixel (0, 0).ToColorBgra ();
            }
        }