Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, May 4, 2017 2:36:50 PM(UTC)


Groups: Tech Support, Administrators
Posts: 310

Was thanked: 3 time(s) in 3 post(s)

This project illustrates the use of LEADTOOLS 19 and combining images using the FeatherAlphaBlendCommand. The FeatherAlphaBlendCommand will combine two images using a transparency (grayscale) mask, whereby the mask indicates how much of each image to use in the final output. For non-tranparent images, this process is fairly straight forward. You pass two images you want to combine to the FeatherAlphaBlendCommand along with a third image that indicates how this should be done. You'll also pass a rectangle to indicate where part of the source image will be copied to the destination image using a rectangle, and you will also pass a point to indicate where in the destination image the combining should start.

The FeatherAlphaBlendCommand does not take the alpha channel into consideration when combining images. When dealing with a source image using transparency, special considerations are needed to create transparent output. This considerations include combining the alpha channels of both images and applying the combined output as the alpha image for the destination image.

This example uses image viewers to visually illustrate each image in the process to better understand each step in the process. The combining code in the example is the following:


if ((SourceViewer.Image.BitsPerPixel != SourceMaskViewer.Image.BitsPerPixel) || (SourceViewer.Image.BitsPerPixel != DestViewer.Image.BitsPerPixel))
    ColorResolutionCommand colorRes = new ColorResolutionCommand(ColorResolutionCommandMode.InPlace, 32, RasterByteOrder.Bgr,
                                                    RasterDitheringMethod.None, ColorResolutionCommandPaletteFlags.None, null);


LeadRect destRect = new LeadRect((DestViewer.Image.Width - SourceViewer.Image.Width) - 1, (DestViewer.Image.Height - SourceViewer.Image.Height) - 1,
                                    SourceViewer.Image.Width - 1, SourceViewer.Image.Height - 1);
FeatherAlphaBlendCommand blendCmd = new FeatherAlphaBlendCommand(SourceViewer.Image, new LeadPoint(0, 0), destRect, SourceMaskViewer.Image);
blendCmd.Progress += new EventHandler<RasterCommandProgressEventArgs>(blendCmd_Progress);


This project illustrates using the FeatherAlphaBlendCommand as well as combining the alpha channels to produce a transparent output images. Sample images are included for proper illustration. Here's a snapshot of the application:

See also:
V19 HOWTO: Simple change to alpha mask to produce smooth blending

File Attachment(s):
CS_FeatherAlphaBlend.zip (57kb) downloaded 83 time(s).
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2017, Yet Another Forum.NET
This page was generated in 0.136 seconds.