ImageGear for .NET
Perspective Method
See Also  Example Send Feedback
ImageGear21.Processing.Advanced Assembly > ImageGear.Processing Namespace > ImGearEffects Class : Perspective Method




page
Page class object.
point0
New coordinates of left top image corner.
point1
New coordinates of right top image corner.
point2
New coordinates of left bottom image corner.
point3
New coordinates of right bottom image corner.
color
Fill color for empty image part.

Glossary Item Box

This method provides a perspective-like effect by image corners transformation.

Syntax

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

Parameters

page
Page class object.
point0
New coordinates of left top image corner.
point1
New coordinates of right top image corner.
point2
New coordinates of left bottom image corner.
point3
New coordinates of right bottom image corner.
color
Fill color for empty image part.

Example

C#Copy Code
//Sample usage of Perspective method.
//New positions for the 4 corners of the image
ImGearPoint igPointLeftTop = new ImGearPoint(igRasterPage.DIB.Width / 4, igRasterPage.DIB.Height / 4);
ImGearPoint igPointRightTop = new ImGearPoint(igRasterPage.DIB.Width, 0);
ImGearPoint igPointLeftBottom = new ImGearPoint(0, igRasterPage.DIB.Height);
ImGearPoint igPointRightBottom = new ImGearPoint(3 * igRasterPage.DIB.Width / 4, 3 * igRasterPage.DIB.Height / 4);
//Background color to fill in after adjusting the corners of the image.
ImGearPixel igPixel = new ImGearPixel(igRasterPage.DIB.ChannelCount, igRasterPage.DIB.BitsPerChannel);
//Set the color to a dark gray based on the bits per channel.
for (int i = 0; i < igPixel.ChannelCount; ++i)
    igPixel[i] = (int)Math.Pow(2, igRasterPage.DIB.BitsPerChannel) / 4;
//Apply the perspective change.
ImGearEffects.Perspective(
    igRasterPage, igPointLeftTop, igPointRightTop,
    igPointLeftBottom, igPointRightBottom, igPixel);
Visual BasicCopy Code
'Sample usage of Perspective function.
     Dim igPointLeftTop As ImGearPoint, igPointRightTop As ImGearPoint
     Dim igPointLeftBottom As ImGearPoint, igPointRightBottom As ImGearPoint
     'New positions for the 4 corners of the image
     igPointLeftTop = New ImGearPoint(igRasterPage.DIB.Width / 4, igRasterPage.DIB.Height / 4)
     igPointRightTop = New ImGearPoint(igRasterPage.DIB.Width, 0)
     igPointLeftBottom = New ImGearPoint(0, igRasterPage.DIB.Height)
     igPointRightBottom = New ImGearPoint(3 * igRasterPage.DIB.Width / 4, 3 * igRasterPage.DIB.Height / 4)
     'Background color to fill in after adjusting the corners of the image.
     Dim igPixel As New ImGearPixel(igRasterPage.DIB.ChannelCount, igRasterPage.DIB.BitsPerChannel)
     For i As Integer = 0 To igPixel.ChannelCount - 1
         igPixel(i) = CInt(Math.Pow(2, igRasterPage.DIB.BitsPerChannel)) / 4
     Next
     'Set the color to a dark gray based on the bits per channel.
     'Apply the perspective change.
     ImGearEffects.Perspective(igRasterPage, igPointLeftTop, igPointRightTop, _
igPointLeftBottom, igPointRightBottom, igPixel)

See Also

©2013. Accusoft Corporation. All Rights Reserved.