GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / AutoDeskew Method / AutoDeskew(Int32,Single,Color) Method
GdPicture image identifier.
Maximum angle of research. IE: set 10 to perform a skew research about ±10 degrees. A value lower than 15 is suggested. Value used by other overloads is 15.
Color to use to fill background. A suitable color value can be obtained by using the ARGB() method.
Example





In This Topic
AutoDeskew(Int32,Single,Color) Method
In This Topic
Tries to deskew a GdPicture image to about ± specified degrees. This method enables to specify the background color to use. Deskewing an image can help a lot to do OCR, OMR, barcode detection or just improve the readability of an image.
Syntax
'Declaration
 
Public Overloads Function AutoDeskew( _
   ByVal ImageID As Integer, _
   ByVal MaxAngleOfResearch As Single, _
   ByVal BackColor As Color _
) As GdPictureStatus
public GdPictureStatus AutoDeskew( 
   int ImageID,
   float MaxAngleOfResearch,
   Color BackColor
)
public function AutoDeskew( 
    ImageID: Integer;
    MaxAngleOfResearch: Single;
    BackColor: Color
): GdPictureStatus; 
public function AutoDeskew( 
   ImageID : int,
   MaxAngleOfResearch : float,
   BackColor : Color
) : GdPictureStatus;
public: GdPictureStatus AutoDeskew( 
   int ImageID,
   float MaxAngleOfResearch,
   Color BackColor
) 
public:
GdPictureStatus AutoDeskew( 
   int ImageID,
   float MaxAngleOfResearch,
   Color BackColor
) 

Parameters

ImageID
GdPicture image identifier.
MaxAngleOfResearch
Maximum angle of research. IE: set 10 to perform a skew research about ±10 degrees. A value lower than 15 is suggested. Value used by other overloads is 15.
BackColor
Color to use to fill background. A suitable color value can be obtained by using the ARGB() method.

Return Value

A member of the GdPictureStatus enumeration.
Remarks
Deskewing often results in "padding" surrounding the image where the dimensions of the image were extended because of the rotation. This method offers a fill color for this padding, so that if you specify it to be the same as the original background color, the deformities would not show.
Example
Deskewing a tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("skewed.tif");
 
    gdpictureImaging.AutoDeskew(imageID, 15, gdpictureImaging.ARGB(255, 255, 255, 255));
 
    // Let's encode the new tiff with the same mode used by the input image.
    TiffCompression tiffCompression = gdpictureImaging.GetTiffCompression(imageID);
 
    gdpictureImaging.SaveAsTIFF(imageID, "deskewed.tif", tiffCompression);
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also