Page 1 of 1

BMP resolution units

Posted: 2006-02-13T12:14:14-07:00
by el_supremo
There's a bug in the bmp.c coder. It correctly converts the x and y resolution values from pixels per metre to pixels per centimetre but it leaves the units as undefined which means that the resolution and units won't be correctly propagated when converting to other image formats (such as PNG,JPG etc).
In the ReadBMPImage function there is this code at about line 893:
/*
Initialize image structure.
*/
image->x_resolution=(double) bmp_info.x_pixels/100.0;
image->y_resolution=(double) bmp_info.y_pixels/100.0;

Add the statement:
image->units=PixelsPerCentimeterResolution;

When this statement is added, converting a BMP to another image format will result in the correct resolution and units in the output file (if it supports resolution units at all).

<spelling nitpick>
The "metre" is the unit of length. A "meter" is used to measure quantities such as volts or amps. It took me a while to figure out why my fix to bmp.c kicked out a compiler error for PixelsPerCentimetreResolution.
It would be nice if ImageMagick.h could have the statement:
#define PixelsPerCentimeterResolution PixelsPerCentimetreResolution
added immediately before the enum that defines it.
</spelling nitpick>

Pete

Posted: 2006-02-13T13:50:48-07:00
by magick
Thanks for the problem report and patch. We will get it into the latest the ImageMagick development version.