Reading Rectangle Coordinates from Microsoft Paint
Some IronOCR methods accept a Rectangle so you can run OCR on one part of an image instead of the whole thing. This guide shows you how to read the four values Rectangle needs (x, y, width, and height) straight out of Microsoft Paint.
The constructor looks like this:
Rectangle(int x, int y, int width, int height, MeasurementUnits units = MeasurementUnits.Pixels)
Rectangle(int x, int y, int width, int height, MeasurementUnits units = MeasurementUnits.Pixels)
Rectangle(x As Integer, y As Integer, width As Integer, height As Integer, Optional units As MeasurementUnits = MeasurementUnits.Pixels)
Each value means:
x: distance from the left edge of the image to the start of your region.y: distance from the top edge of the image to the start of your region.width: width of the region you want to read.height: height of the region you want to read.MeasurementUnits.Pixels: tells IronOCR the values are in pixels.
Coordinates start at the top-left corner of the image. x grows to the right, y grows downward.

Prerequisites
- Microsoft Paint (or any editor that shows the cursor position and selection size in pixels)
- The image you want to run OCR on
- IronOCR added to your project
This applies from version 2026.5.2 onward.
Solution
1. Read the X and Y start point
Open the image in Microsoft Paint, then move the cursor to the top-left corner of the region you want to read. That corner is your starting point. Read the cursor position from the bottom-left of the window. In the screenshot below it shows 2403, 1653px, so:
X = 2403
Y = 1653

2. Read the width and height
Use the Select tool and drag a box over the target text. Paint shows the size of your selection in the bottom-left. In the screenshot below it shows 1031 × 214px, so:
Width = 1031
Height = 214

3. Build the Rectangle
Assemble the Rectangle from the four values you just read. For the Testing123 region above:
var rectangle = new Rectangle(2403,1653,1031,214,MeasurementUnits.Pixels);
var rectangle = new Rectangle(2403,1653,1031,214,MeasurementUnits.Pixels);
Dim rectangle As New Rectangle(2403, 1653, 1031, 214, MeasurementUnits.Pixels)
Pass the rectangle to IronOCR to crop the image down to that region:
var rectangle = new Rectangle(2403,1653,1031,214,MeasurementUnits.Pixels);
ocrInput.LoadImage(frame, rectangle);
var rectangle = new Rectangle(2403,1653,1031,214,MeasurementUnits.Pixels);
ocrInput.LoadImage(frame, rectangle);
Dim rectangle = New Rectangle(2403, 1653, 1031, 214, MeasurementUnits.Pixels)
ocrInput.LoadImage(frame, rectangle)
Notes and Limitations
- The
1031 × 214pxvalue in the status bar is the width and height of your selection. It is not a coordinate. - The
2403, 1653pxcursor readout is the X and Y starting point (the top-left of the region). - Do not use the full image size (here
4960 × 7014px) as the rectangle size. That selects the whole image, not your region. - Paint reports in pixels, so pass
MeasurementUnits.Pixelsto match. - You read these values by eye, so they can be off by a few pixels. If the crop clips part of the text, widen
widthorheightslightly, or lowerxory.

