Bug on colors when loading bitmap file
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
Hello,
On some bitmap files, i saw that the color of pixels got with imagecreatefrombmp/imagecolorat/imagecolorsforindex are not the correct one.
To reproduce the issue, just load the image in attachment :
$bmp = imagecreatefrombmp($bitmapFilePath);
then read the color of the pixel in 0,0 :
$rgb = imagecolorat($bmp, 0, 0);
$px = imagecolorsforindex($bmp, $rgb);
You will have the color 0, 248, 0 (green) but the color should be 255,0,255 (magenta).
The bitmap file is correctly displayed on my OS (ubuntu) and in gimp software.
Here is my php version :
PHP 8.1.2-1ubuntu2.11 (cli) (built: Feb 22 2023 22:56:18) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
with Zend OPcache v8.1.2-1ubuntu2.11, Copyright (c), by Zend Technologies
PHP Version
8.1.2
Operating System
Ubuntu 22.04.2 LTS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the attached bg1.zip file using imagecreatefrombmp(), then inspect the values returned by imagecolorat() and imagecolorsforindex() for pixel 0,0. Trace the bitmap-loading path from these entry points and compare the observed RGB values with the expected magenta value; done means the reported bitmap color is decoded correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100