This class contains all the render ops that can be used by the user to configure a layer's blending mode. It also contains helper functions to aid in enumerating and using these blend ops. Credit for mathematical descriptions of many of the blend modes goes to a page on Pegtop Software's website called, "Blend Modes" http://www.pegtop.net/delphi/articles/blendmodes/
Esempio 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);
        }
Esempio 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);
        }
Esempio 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();
        }