After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 303972 - BMP plugin writes incorrect image resolution
BMP plugin writes incorrect image resolution
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
2.2.x
Other All
: Normal minor
: 2.2
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2005-05-12 21:46 UTC by Brandon
Modified: 2008-01-15 12:54 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Brandon 2005-05-12 21:46:10 UTC
1) Create a new image in The Gimp, noting the image resolution.
2) Save the image as a Windows bitmap (BMP).
3) Close the image.
4) Open the image and view the image info, noting the resolution.
5) Repeat steps 2 through 4 several more times.

With each save operation the resolution is decreased by a small amount.  The
resolution should remain nearly constant throughout the save operations.  The
image resolution is stored in bitmaps as pixels per meter rather than dots per
inch.  The Gimp uses dots per inch, therefore, the BMP plugin converts the
values using the following bit of code:

        Bitmap_Head.biXPels = (long int) xresolution * 100.0 / 2.54;
        Bitmap_Head.biYPels = (long int) yresolution * 100.0 / 2.54;

xresolution and yresolution are gdoubles.  The problem is that the cast to long
int should encompass the entire expression, not just the resolution variables. 
The solution is to enclose the expression in parentheses as follows:

        Bitmap_Head.biXPels = (long int) (xresolution * 100.0 / 2.54);
        Bitmap_Head.biYPels = (long int) (yresolution * 100.0 / 2.54);

I have used this change successfully.
Comment 1 Sven Neumann 2005-05-12 23:34:35 UTC
Thanks a lot for spotting this problem. Fixed in both branches:

2005-05-13  Sven Neumann  <sven@gimp.org>

	* plug-ins/bmp/bmpwrite.c (WriteBMP): added missing brackets.
	Fixes bug #303972.