[GIT-PULLS] [php-src] PR #23485: Fix GH-23459: Improve imagegrabscreen() performance on Windows
[email protected] (LamentXU123)
| Newsgroups | php.git-pulls |
|---|---|
| Message-ID | <[email protected]> |
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.