示例#1
0
        /// <summary>
        /// Checks if all of the pixels in the column (within the bounds of the rectangle) match the specified color.
        /// </summary>
        private static bool IsConstantColumn(ImageSurface surf, Cairo.Color color, Gdk.Rectangle rect, int x)
        {
            for (int y = rect.Top; y < rect.Bottom; ++y)
            {
                if (!color.Equals(surf.GetPixel(x, y)))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Checks if all of the pixels in the row match the specified color.
        /// </summary>
        private static bool IsConstantRow(ImageSurface surf, Cairo.Color color, int y)
        {
            for (int x = 0; x < surf.Width; ++x)
            {
                if (!color.Equals(surf.GetPixel(x, y)))
                {
                    return(false);
                }
            }

            return(true);
        }
示例#3
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());
            }
        }