LEADTOOLS Image Processing (Leadtools.ImageProcessing.Effects assembly)
LEAD Technologies, Inc

TextureAlphaBlendCommand Constructor(RasterImage,LeadPoint,LeadRect,Int32,RasterImage,RasterImage,LeadPoint)

Example 





RasterImage object that references the source image.
LeadPoint structure that contains the origin of the source rectangle.
LeadRect structure that contains the destination rectangle.
Opacity value used when combining the areas from the result of feathering and destination images. Valid values range from 0 to 255.
RasterImage object that references the fade mask, if you want to combine the two images just with opacity set this parameter to null.
RasterImage that references the image to be used as the underlying image. The command will use this image to underlay the mask image. You could ignore this parameter effect by passing null.
References the underlay image offset with respect to the destination image. The command will use this point to calculate the parts of the underlay image that will be applied to the mask image. Using this point gives the user the ability to provide the feel of continuous texture when applying this command to neighboring parts inside the destination image using the same or different mask. If underlayImage is null also set this parameter to null.
Initializes a new TextureAlphaBlendCommand class object with explicit parameters. .NET support WinRT support
Syntax
public TextureAlphaBlendCommand( 
   RasterImage sourceImage,
   LeadPoint sourcePoint,
   LeadRect destinationRectangle,
   int opacity,
   RasterImage maskImage,
   RasterImage underlayImage,
   LeadPoint underlayOffset
)
'Declaration
 
Public Function New( _
   ByVal sourceImage As RasterImage, _
   ByVal sourcePoint As LeadPoint, _
   ByVal destinationRectangle As LeadRect, _
   ByVal opacity As Integer, _
   ByVal maskImage As RasterImage, _
   ByVal underlayImage As RasterImage, _
   ByVal underlayOffset As LeadPoint _
)
'Usage
 
Dim sourceImage As RasterImage
Dim sourcePoint As LeadPoint
Dim destinationRectangle As LeadRect
Dim opacity As Integer
Dim maskImage As RasterImage
Dim underlayImage As RasterImage
Dim underlayOffset As LeadPoint
 
Dim instance As New TextureAlphaBlendCommand(sourceImage, sourcePoint, destinationRectangle, opacity, maskImage, underlayImage, underlayOffset)
public TextureAlphaBlendCommand( 
   RasterImage sourceImage,
   LeadPoint sourcePoint,
   LeadRect destinationRectangle,
   int opacity,
   RasterImage maskImage,
   RasterImage underlayImage,
   LeadPoint underlayOffset
)
function TextureAlphaBlendCommand( 
   sourceImage ,
   sourcePoint ,
   destinationRectangle ,
   opacity ,
   maskImage ,
   underlayImage ,
   underlayOffset 
)

Parameters

sourceImage
RasterImage object that references the source image.
sourcePoint
LeadPoint structure that contains the origin of the source rectangle.
destinationRectangle
LeadRect structure that contains the destination rectangle.
opacity
Opacity value used when combining the areas from the result of feathering and destination images. Valid values range from 0 to 255.
maskImage
RasterImage object that references the fade mask, if you want to combine the two images just with opacity set this parameter to null.
underlayImage
RasterImage that references the image to be used as the underlying image. The command will use this image to underlay the mask image. You could ignore this parameter effect by passing null.
underlayOffset
References the underlay image offset with respect to the destination image. The command will use this point to calculate the parts of the underlay image that will be applied to the mask image. Using this point gives the user the ability to provide the feel of continuous texture when applying this command to neighboring parts inside the destination image using the same or different mask. If underlayImage is null also set this parameter to null.
Example
 
Public Sub TextureAlphaBlendConstructorExample()
   Dim codecs As New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg"))

   ' Prepare the command
   Dim srcImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ImageProcessingDemo\image3.cmp"), 4, CodecsLoadByteOrder.Bgr, 1, 1)
   'Load the fade mask image.
   Dim maskImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ImageProcessingDemo\FadeMask.bmp"), 4, CodecsLoadByteOrder.Bgr, 1, 1)
   Dim underlayImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"), 4, CodecsLoadByteOrder.Bgr, 1, 1)

   Dim rect As LeadRect = New LeadRect(leadImage.Width \ 2 - maskImage.Width \ 2, leadImage.Height \ 2 - maskImage.Height \ 2, maskImage.Width, maskImage.Height)

   Dim command As TextureAlphaBlendCommand = New TextureAlphaBlendCommand(srcImage, New LeadPoint(0, 0), rect, 100, maskImage, underlayImage, New LeadPoint(150, 10))
   ' Combine ImageSource with the affected image, with MaskImage and a 100 opacity.
   command.Run(leadImage)
   codecs.Save(leadImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24)

End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void TextureAlphaBlendConstructorExample()
   {
      // 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 = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"ImageProcessingDemo\Image3.cmp"), 4, CodecsLoadByteOrder.Bgr, 1, 1);

      //Load the fade mask image.
      RasterImage maskImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"ImageProcessingDemo\FadeMask.bmp"), 4, CodecsLoadByteOrder.Bgr, 1, 1);

      RasterImage underlayImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"), 4, CodecsLoadByteOrder.Bgr, 1, 1);

      LeadRect rect = new LeadRect(image.Width / 2 - maskImage.Width / 2, image.Height / 2  - maskImage.Height / 2, maskImage.Width, maskImage.Height);

      TextureAlphaBlendCommand command = new TextureAlphaBlendCommand(srcImage, new LeadPoint(0, 0), rect, 100, maskImage, underlayImage, new LeadPoint(150, 10));

      // 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:\Users\Public\Documents\LEADTOOLS Images";
}
[TestMethod]
public async Task TextureAlphaBlendConstructorExample()
{
   // Load an image
   RasterCodecs codecs = new RasterCodecs();
   codecs.ThrowExceptionsOnInvalidImages = true;
   string srcFileName = @"Assets\Master.jpg";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));

   // Prepare the command
   srcFileName = @"Assets\Image3.cmp";
   loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage srcImage = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile), 4, CodecsLoadByteOrder.Bgr, 1, 1);

   //Load the fade mask image.
   srcFileName = @"Assets\FadeMask.bmp";
   loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage maskImage = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile), 4, CodecsLoadByteOrder.Bgr, 1, 1);

   //Load the underlay image.
   srcFileName = @"Assets\cannon.jpg";
   loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage underlayImage = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile), 4, CodecsLoadByteOrder.Bgr, 1, 1);

   LeadRect rect = LeadRectHelper.Create(image.Width / 2 - maskImage.Width / 2, image.Height / 2 - maskImage.Height / 2, maskImage.Width, maskImage.Height);

   TextureAlphaBlendCommand command = new TextureAlphaBlendCommand(srcImage, LeadPointHelper.Create(0, 0), rect, 100, maskImage, underlayImage, LeadPointHelper.Create(150, 10));

   // Combine ImageSource with the affected image, with MaskImage and a 100 opacity.
   command.Run(image);

   string destFileName = @"result.bmp";
   StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(destFileName);
   await codecs.SaveAsync(image, LeadStreamFactory.Create(saveFile), RasterImageFormat.Bmp, 24);
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

TextureAlphaBlendCommand Class
TextureAlphaBlendCommand Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.