[php-src] PR #23485: Fix GH-23459: Improve imagegrabscreen() performance on Windows
| From: | LamentXU123 | Date: | Fri, 28 Aug 2026 07:55:29 +0000 |
| Subject: | [php-src] PR #23485: Fix GH-23459: Improve imagegrabscreen() performance on Windows | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-38179@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23485
Author: LamentXU123
The original implementation of
imagegrabscreen is super weird. It currently calls
GetPixel() once for every pixel after capturing the desktop. On a 1560x1040 display,
this results in more than 1.6 million GDI calls and takes around 3.2 seconds. (???)
This is a easy fix. Besides, I find a out-of-bound read in the original implementation. Anyways, now
we retrieve the bitmap in a single GetDIBits() call as a top-down 32-bit DIB, then
convert the returned RGBQUAD buffer directly into the GD true-color image.
I run the benchmark locally with a 1560×1040 pic.
Before: 2.997434s
After: 0.003682s
A 814x optimization in total.