I am using c# winforms and I am taking a screenshot using Graphics.copyfromscreen
private Bitmap CaptureImage()
{
// Create a bitmap with the specified dimensions
Bitmap capturedImage = new Bitmap(captureArea.Width, captureArea.Height);
// Create a graphics object from the bitmap
using (Graphics graphics = Graphics.FromImage(capturedImage))
{
graphics.InterpolationMode =
System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
// Copy the screen pixels to the bitmap
graphics.CopyFromScreen(captureArea.Location, Point.Empty, captureArea.Size);
}
// Store the captured image for later use
// You can save it as a class member or in a desired location
// In this example, it's being stored as a class member
return capturedImage;
}
I am using this image in IronOcr/TesseractOcr, but I get the following warning:
Warning: Invalid resolution 3780 dpi. Using 70 instead.
This library requires atleast 300 dpi to run accurately, I am getting some bad results due to low DPI, how can I fix this?
I tried changing the input.TargetDPi of OCRInput inside of IronOcr, but it is clear that the problem is with the image because if I save a normal screen shot to a file and then use it this warning does not come, I tried changing the DPI of the image using .SetResolution after using .copyfromscreen aswell but no change at all.