Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 22, 2025

Screenshots captured on HDR-enabled Windows displays appear overly bright, degrading OCR accuracy. The issue occurs because Graphics.CopyFromScreen() captures pixels in HDR color space, which are incorrectly interpreted as SDR values.

Changes

  • HDR Detection: Added Windows API calls to detect HDR-enabled monitors via GetDeviceCaps(COLORMGMTCAPS)
  • Tone Mapping: Implemented modified Reinhard operator to compress HDR values to SDR range
    // Convert sRGB → linear RGB → tone map → sRGB
    rLinear = SrgbToLinear(r / 255.0);
    rLinear = (rLinear * 0.8) / (1.0 + rLinear * 0.8);
    r = LinearToSrgb(rLinear) * 255.0;
  • Automatic Conversion: Applied HDR→SDR conversion in GetRegionOfScreenAsBitmap() and GetWindowsBoundsBitmap() when HDR is detected

The conversion only activates on HDR displays, leaving non-HDR systems unaffected.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • az667904.vo.msecnd.net
    • Triggering command: /usr/bin/dotnet dotnet build Text-Grab/Text-Grab.csproj -p:EnableWindowsTargeting=true --no-restore dvancedColor ices/HistoryService.cs nfig/composer/vendor/bin/grep user.name (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>HDR support</issue_title>
<issue_description>Is it possible to have support for hdr?

When I use text grab on an image displayed in a browser, it will fail to recognize some words.
As an example, this is what text grab gives with hdr on:

Drug Facts
Active ingredient
Uses to decrease bactené
recommended for repeated
Waminqs
For enema use only: hands
Flammable, keep away from fire
When using this product • keep
flush thoroughty wrt water. avu
do not inhale or ingest
Stop use and ask a doctor if irrit-
Purpose
COuC cause
ame
eyes. In case of
r:act wth brokenect eyes,
and redness develop
Keep out of reach of children. If swaj„wed, get medical help or
Directions •
wet hands thoroughly wift product and al
mping for children under 6, use only under adult supemsl?n to dry Without
Other information n
do not store above 105'F
fabrics harmful to wood finishes and plastics
may discolor some
bactive ingredients
water, carbomer and/or ac
Tdate crosspolymer, fragrance, glycenn, isopro
pyl
zteatårunatng 99.99% of rzrrj common harmfu germs & barere
Distributed By VI-Jon, Inc.
nasQ15

with hdr off, it is much more accurate.

Drug Facts
Active ingredient
*cohol 62%
USBS'todecrease bderia .eskn
recommended for repeated
Warnings
For externa use only: hands
Flammable, keep away from fire cr 'iame
When using this product keep of eyes. In case of
msh thoroughty wifi water. ontactwth brokenem
do not inhale or ingest
stop use and aska doctor if • irrit nand redness develop
condltjon persists for more ten 72 ('ours
Keep out of reach of children. If swaikjwed, get medical telp or contäa
Poison Control Center right away.
Directions wet hands thoroughly wm product and allow to dry Withou
for children under 6, use only under adult supervision
•grecommended for infants
harmful to wood finishes and plastics
fabrts
Inactive ingredients
acrydate crosspoymer, fragrance, glycerin, isopropyl myristate,
•øedÜiÜ09999% of & n 15
Distributed By VI-Jon, 1m.
wrwgerrnx.com

I believe this may have to do with how text grab gets the image. Here is what the image looks like with hdr on:
image
hdr off:
image

When hdr is on, the screenshot is a lot brighter, and the text is harder to read.
Is it possible to fix this? I'm pretty sure it's possible since zoom screen sharing doesn't have this issue.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add support for HDR in text grab functionality Fix HDR screenshot brightness by applying tone mapping Dec 22, 2025
Copilot AI requested a review from TheJoeFin December 22, 2025 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HDR support

2 participants