GNOME Bugzilla – Bug 303972
BMP plugin writes incorrect image resolution
Last modified: 2008-01-15 12:54:01 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.
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.