ImageGear .NET v25.1 - Updated
Perspective Method
Example 




ImageGear.Processing.Advanced Assembly > ImageGear.Processing Namespace > ImGearEffects Class : Perspective Method
Page class object.
New coordinates of left top image corner.
New coordinates of right top image corner.
New coordinates of left bottom image corner.
New coordinates of right bottom image corner.
Fill color for empty image part.
This method provides a perspective-like effect by image corners transformation.
Syntax
'Declaration
 
Public Shared Sub Perspective( _
   ByVal page As ImGearRasterPage, _
   ByVal point0 As ImGearPoint, _
   ByVal point1 As ImGearPoint, _
   ByVal point2 As ImGearPoint, _
   ByVal point3 As ImGearPoint, _
   ByVal color As ImGearPixel _
) 
'Usage
 
Dim page As ImGearRasterPage
Dim point0 As ImGearPoint
Dim point1 As ImGearPoint
Dim point2 As ImGearPoint
Dim point3 As ImGearPoint
Dim color As ImGearPixel
 
ImGearEffects.Perspective(page, point0, point1, point2, point3, color)
public static void Perspective( 
   ImGearRasterPage page,
   ImGearPoint point0,
   ImGearPoint point1,
   ImGearPoint point2,
   ImGearPoint point3,
   ImGearPixel color
)
public: static void Perspective( 
   ImGearRasterPage* page,
   ImGearPoint point0,
   ImGearPoint point1,
   ImGearPoint point2,
   ImGearPoint point3,
   ImGearPixel* color
) 
public:
static void Perspective( 
   ImGearRasterPage^ page,
   ImGearPoint point0,
   ImGearPoint point1,
   ImGearPoint point2,
   ImGearPoint point3,
   ImGearPixel^ color
) 

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
//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);
'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

Reference

ImGearEffects Class
ImGearEffects Members
ImGearRasterPage Class
ImGearPoint Structure
ImGearPixel Class