pharo icon indicating copy to clipboard operation
pharo copied to clipboard

BMPs are wrongly read

Open tinchodias opened this issue 7 months ago • 0 comments

Bug description

All BMP files I tested were wrongly read by BMPReadWriter (but BMPReadWriterTest passes).

To Reproduce

This is one BMP:

response := ZnEasy get: 'https://cdn-learn.adafruit.com/assets/assets/000/074/681/original/purple.bmp?1555717198'.

'original.bmp' asFileReference
	ensureDelete;
	binaryWriteStreamDo: [ :stream | stream nextPutAll: response contents ].

parsedForm := (BMPReadWriter on: response contents readStream) nextImage.
parsedForm writeBMPfileNamed: 'parsed.bmp'.

In an external tool, open both BMPs to see the difference. You can also inspect the forms inside Pharo IDE. You can also download externally the original file, in a web browser: https://cdn-learn.adafruit.com/assets/assets/000/074/681/original/purple.bmp?1555717198' and open it in your operating system.

I discovered this bug when playing with on Windows with the Clipboard API of SDL3 bindings. On this OS, when I right click on any image in the browser and choose "Copy" and then in Pharo-SDL3 bindings you "paste" and have to parse a byte array with the mime type "image/bmp". So, I use BMPReadWriter and get a wrongly parsed Form.

Screenshots

Original: Image

Parsed: Image

Version information:

Checked with a Pharo Version 12 in two OSs: Windows 11 and MacOS 15.4.1.

tinchodias avatar May 08 '25 16:05 tinchodias