Exemplo n.º 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)
        {
            var pixel = ColorBgra.Zero;

            foreach (var layer in GetLayersToPaint())
            {
                var blend_op = UserBlendOps.GetBlendOp(layer.BlendMode, layer.Opacity);

                pixel = blend_op.Apply(pixel, layer.Surface.GetColorBgra(x, y));
            }

            return(pixel);
        }
Exemplo n.º 2
0
        public ImageSurface GetFlattenedImage()
        {
            // Create a new image surface
            var surf = new Cairo.ImageSurface(Cairo.Format.Argb32, ImageSize.Width, ImageSize.Height);

            // Blend each visible layer onto our surface
            foreach (var layer in GetLayersToPaint())
            {
                var blendop = UserBlendOps.GetBlendOp(layer.BlendMode, layer.Opacity);
                blendop.Apply(surf, layer.Surface);
            }

            surf.MarkDirty();
            return(surf);
        }
Exemplo n.º 3
0
        // Flatten current layer
        public void MergeCurrentLayerDown()
        {
            if (current_layer == 0)
            {
                throw new InvalidOperationException("Cannot flatten layer because current layer is the bottom layer.");
            }

            // Get our source and destination layers
            var source = CurrentUserLayer;
            var dest   = UserLayers[current_layer - 1];

            // Blend the layers
            var blendop = UserBlendOps.GetBlendOp(source.BlendMode, source.Opacity);

            blendop.Apply(dest.Surface, source.Surface);

            DeleteCurrentLayer();
        }