TextureAlphaBlendCommand Class (original) (raw)

Summary

Combines image data from two images with feathering and constant opacity; by combining the two images with a variable opacity that depends on a fade mask then combine the result with the destination image with a constant opacity.

Syntax

class TextureAlphaBlendCommand(RasterCommand): 

Example

Run the TextureAlphaBlendCommand on an image.

using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing.Effects; public void TextureAlphaBlendCommandExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")); // Prepare the command RasterImage SrcImage; RasterImage MaskImage; RasterImage underlayImage; SrcImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"ImageProcessingDemo\Image3.cmp"), 4, CodecsLoadByteOrder.Bgr, 1, 1); //Load the fade mask image. MaskImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"ImageProcessingDemo\FadeMask.bmp"), 4, CodecsLoadByteOrder.Bgr, 1, 1); underlayImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"), 4, CodecsLoadByteOrder.Bgr, 1, 1); TextureAlphaBlendCommand command = new TextureAlphaBlendCommand(); command.DestinationRectangle = new LeadRect(image.Width / 2 - MaskImage.Width / 2, image.Height / 2 - MaskImage.Height / 2, MaskImage.Width, MaskImage.Height); command.MaskImage = MaskImage; command.Opacity = 100; command.SourceImage = SrcImage; command.SourcePoint = new LeadPoint(0, 0); command.UnderlayImage = underlayImage; // Combine ImageSource with the affected image, with MaskImage and a 100 opacity. command.Run(image); codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24); } static class LEAD_VARS { public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; }