ImageGear for .NET
Blend(ImGearRasterPage,Int32,Int32,ImGearRasterPage,Double) Method
See Also  Example Send Feedback
ImageGear21.Core Assembly > ImageGear.Processing Namespace > ImGearRasterProcessing Class > Blend Method : Blend(ImGearRasterPage,Int32,Int32,ImGearRasterPage,Double) Method




page
Page to process.
left
Left margin of blended image.
top
Top margin of blended image.
pageToBlendWith
Image to blend with page.
weight
A value from 0 to 100 defining the % weight of the pageToBlendWith image to be blended.

Glossary Item Box

Blends two images based on the weight (in percents) of the secondary image.

Syntax

 
Visual Basic
C#
Managed Extensions for C++
C++/CLI
 
 

Parameters

page
Page to process.
left
Left margin of blended image.
top
Top margin of blended image.
pageToBlendWith
Image to blend with page.
weight
A value from 0 to 100 defining the % weight of the pageToBlendWith image to be blended.

Remarks

This method blends all channels of page with corresponding channels of pageToBlendWith, using the following formula:

            pagePixel = (pagePixel * (100.0 - weight) + pageToBlendPixel * weight) / 100.0
            

The method validates input pages for further processing according to following logics:

  • This method is applicable to any colorspace, but both images must have the same base colorspace (i.e. upon validation of input images will be considered color channels only - Alpha or Extra channels will be ignored. So, for example, any combination of pages with RGB(A/Ex) colorspaces (e.g. RGB and RGBA) are valid input parameters).
  • This method is applicable to any supported by ImageGear channel depth for given colorspace, but channel depths of both images must be the same.

The method processes the input pages according to following logics:

  • This method processes all channels of input pages. In order to process a specific group of image channels, e.g. color channels only, use another overload Blend(ImGearRasterPage,Int32,Int32,ImGearRasterPage,Double,ImGearChannelRange).
  • If page and pageToBlendWith have different number of channels, the method blends the minimal number of channels between the images. For example, for images with RGB and RGBEx colorspaces will be processed 3 channels. The remaining redundant channels will be handled as following:
  • This method does not not provide any special handling for the Alpha channel (i.e. it processes it as ordinary color channel), please use BlendWithAlpha method to blend images using the Alpha channel.

Example

C#Copy Code
// Opens an image and blends it into an already open image.
using (FileStream file = new FileStream("photo.jpg",
                   FileMode.Open, FileAccess.Read, FileShare.Read))
{
    ImGearRasterPage igPageToBlend = (ImGearRasterPage)
        ImGearFileFormats.LoadPage(file, 0);

    // Blend the page with a weight of 25% starting from the point 100,100.
    ImGearRasterProcessing.Blend(igRasterPage, 100, 100, igPageToBlend, 25.0);
}
Visual BasicCopy Code
' Opens an image and blends it into an already open image.
Using file As New FileStream("photo.jpg", FileMode.Open, FileAccess.Read, FileShare.Read)
    Dim igPageToBlend As ImGearRasterPage = DirectCast(ImGearFileFormats.LoadPage(file, 0), ImGearRasterPage)

    ' Blend the page with a weight of 25% starting from the point 100,100.
    ImGearRasterProcessing.Blend(igRasterPage, 100, 100, igPageToBlend, 25)
End Using

See Also

©2013. Accusoft Corporation. All Rights Reserved.