Dim caption As String = "Example: GetOrientation"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Setting these properties is mandatory for using this method.
'Specify your path.
gdpictureOCR.ResourcesFolder = "D:\\GdPicture.NET 14\\Redist\\OCR"
'Specify your language.
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Load the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If gdpictureImaging.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Check the image orientation.
Dim orientation As Integer = gdpictureOCR.GetOrientation()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
If orientation <> 0 Then
If gdpictureImaging.RotateAngle(image, 360 - orientation) <> GdPictureStatus.OK Then
MessageBox.Show("The image is rotated, but the RotateAngle() method has failed with the status: " + gdpictureImaging.GetStat.ToString, caption)
Else
orientation = 0
End If
End If
'Continue if image is properly oriented.
If orientation = 0 Then
'Set up the required OCR parameters and continue with the process.
End If
Else
MessageBox.Show("The GetOrientation() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
End Using
string caption = "Example: GetOrientation";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Setting these properties is mandatory to be able to using this method.
gdpictureOCR.ResourcesFolder = "D:\\GdPicture.NET 14\\Redist\\OCR"; //Specify your path.
gdpictureOCR.AddLanguage(OCRLanguage.English); //Specify your language.
//Load the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Check the image orientation.
int orientation = gdpictureOCR.GetOrientation();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
if (orientation != 0)
{
if (gdpictureImaging.RotateAngle(image, 360 - orientation) != GdPictureStatus.OK)
MessageBox.Show("The image is rotated, but the RotateAngle() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
else
orientation = 0;
}
//Continue if image is properly oriented.
if (orientation == 0)
{
//Set up the required OCR parameters and continue with the process.
}
}
else
MessageBox.Show("The GetOrientation() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
{
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
}
gdpictureImaging.Dispose();
}