Open
Description
If you pass a .NET bitmap to the engine the resolution of the image is ignored.
Here is the fix:
--- tesseract.net\src\Tesseract\BitmapToPixConverter.cs Mon Sep 19 08:34:33 2016
+++ tesseract.net_bugfix\src\Tesseract\BitmapToPixConverter.cs Wed Jan 04 14:40:18 2017
@@ -45,6 +45,13 @@
} else if (imgData.PixelFormat == PixelFormat.Format1bppIndexed) {
TransferDataFormat1bppIndexed(imgData, pixData);
}
+
+ if (img.VerticalResolution > 0 && img.HorizontalResolution > 0)
+ {
+ pix.XResolution = (int)img.HorizontalResolution;
+ pix.YResolution = (int)img.VerticalResolution;
+ }
+
return pix;
} catch (Exception) {
pix.Dispose();
--- tesseract.net\src\Tesseract\Pix.cs Mon Sep 19 08:34:33 2016
+++ tesseract.net_bugfix\src\Tesseract\Pix.cs Wed Jan 04 14:21:12 2017
@@ -171,6 +171,18 @@
return new PixData(this);
}
+ public int XResolution
+ {
+ get { return Interop.LeptonicaApi.Native.pixGetXRes(handle); }
+ set { Interop.LeptonicaApi.Native.pixSetXRes(handle, value); }
+ }
+
+ public int YResolution
+ {
+ get { return Interop.LeptonicaApi.Native.pixGetYRes(handle); }
+ set { Interop.LeptonicaApi.Native.pixSetYRes(handle, value); }
+ }
+
#endregion Properties
#region Save methods
--- tesseract.net\src\Tesseract\PixToBitmapConverter.cs Mon Sep 19 08:34:34 2016
+++ tesseract.net_bugfix\src\Tesseract\PixToBitmapConverter.cs Wed Jan 04 14:41:18 2017
@@ -37,6 +37,10 @@
} else if (depth == 1) {
TransferData1(pixData, imgData);
}
+
+ if (pix.XResolution > 0 && pix.YResolution > 0)
+ img.SetResolution(pix.XResolution, pix.YResolution);
+
return img;
} catch (Exception) {
img.Dispose();
Activity