IRONSOFTWAREHOME

Reading Rectangle Coordinates from Microsoft Paint

Curtis Chau
Curtis Chau
Updated: August 21, 2026

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)
C#

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.

Rectangle coordinate system with x growing right and y growing down

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
Text

Paint cursor position readout showing 2403, 1653px

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
Text

Paint selection size readout showing 1031 × 214px

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);
C#

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);
C#

Notes and Limitations

  • The 1031 × 214px value in the status bar is the width and height of your selection. It is not a coordinate.
  • The 2403, 1653px cursor 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.Pixels to 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 width or height slightly, or lower x or y.
Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 6,236,385Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronOcr
nuget.org/packages/IronOcr/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronOCR"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronOCR to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronOCR.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required