Export to RASTER/BMP: wrong file header
Parasite
Global Mapper User
Hi guys,
I am experiencing a difficulties while exporting to the raster/BMP file. I bet I found a bug or something.
Global Mapper 13.00 trial.
Steps to reproduce:
1. Open an image in GM (ASTER GDEM tile in my case, square GeoTIFF 3601x3601 px)
2. Opened OK, shows a nice DEM visualisation.
3. Export->RASTER->BMP (all options by default)->OK.
4. Exported to the single BMP file OK, 38 905 258 bytes.
This file won't be opened nor accepted by the major GISes
Let's dig a little deeper now. On this bmp file we got a header:
The byte offset 22...25 is the image HEIGHT, and we got "FF FF F1 EF" there, which is the value "4294963694", OR "MINUS 3601".
The image HEIGHT cannot be negative nor THAT great in BMP headers.
Changing the bytes "FF FF F1 EF" to the correct ones "00 00 0E 11" is fixing the problem, and the file will be welcomed by all viewers\raster anupulation software.
Is this a bug, or how could I make PROPER BMP headers while exporting via GM?
Thanks.
I am experiencing a difficulties while exporting to the raster/BMP file. I bet I found a bug or something.
Global Mapper 13.00 trial.
Steps to reproduce:
1. Open an image in GM (ASTER GDEM tile in my case, square GeoTIFF 3601x3601 px)
2. Opened OK, shows a nice DEM visualisation.
3. Export->RASTER->BMP (all options by default)->OK.
4. Exported to the single BMP file OK, 38 905 258 bytes.
This file won't be opened nor accepted by the major GISes
Let's dig a little deeper now. On this bmp file we got a header:
00000000 42 4D AA A5 51 02 00 00 00 00 36 00 00 00 28 00 BMª¥Q.....6...(. 00000016 00 00 11 0E 00 00 EF F1 FF FF 01 00 18 00 00 00 ......ïñÿÿ...... 00000032 00 00 74 A5 51 02 00 00 00 00 00 00 00 00 00 00 ..t¥Q........... 00000048 00 00 00 00 00 00 00 96 99 00 AC B1 00 E8 EC 00 .......–™.¬±.èì.The byte offset 18...21 is the image WIDTH. We got "00 00 0E 11" there, which is clearly an "3601".
The byte offset 22...25 is the image HEIGHT, and we got "FF FF F1 EF" there, which is the value "4294963694", OR "MINUS 3601".
The image HEIGHT cannot be negative nor THAT great in BMP headers.
Changing the bytes "FF FF F1 EF" to the correct ones "00 00 0E 11" is fixing the problem, and the file will be welcomed by all viewers\raster anupulation software.
Is this a bug, or how could I make PROPER BMP headers while exporting via GM?
Thanks.
Comments
-
The BMP format stores the height in the header as negative if the BMP is a top-down image rather than a bottom-up image, but if other applications can't handle it I will go ahead and change the export to be bottom up to make everybody happy.
Thanks,
Mike
Global Mapper Guru
gmsupport@bluemarblegeo.com
http://www.globalmapper.com -
I have completed updating the BMP export to generate bottom-up rather than top-down BMP files so that they will work everywhere. I have placed a new build at http://www.globalmapper.com/global_mapper13.zip with the change for you to try. Simply download that file and extract the contents into your existing v13.xx installation folder to give it a try. If you are using the 64-bit v13 version there is a new build at http://www.globalmapper.com/global_mapper13_64bit.zip .
Let me know if I can be of further assistance.
Thanks,
Mike
Global Mapper Guru
gmsupport@bluemarblegeo.com
http://www.globalmapper.com -
Mmm...not pretty sure what you meant by that. I just open a GeoTIFF (a single file) - how could I check, is it a top-down or a bottom-up? It is not a mosaic nor any multi-file scene...The BMP format stores the height in the header as negative if the BMP is a top-down image rather than a bottom-up image
But anyway the IMAGE_SIZE can't be negative in both WIDTH and HEIGHT. It is just a violaton of the file format (a very old and obsolete one BTW, so many classic tools won't recognize any newest "tricks"), and also has no logical means anyway. How would you imagine the image with negative HEIGHT? An image behind the black hole's event horizon?
See attached the properties of the image with the negative value - and the memory needed to simply OPEN such of file.
Great! Now it is working as a charm.I have completed updating the BMP export to generate bottom-up rather than top-down BMP files so that they will work everywhere.
See attached the same file properties report from the same software.
Thanks. -
The TIFF format has a different way of storing orientation, but the fast majority are row-major and top down.
The negative height doesn't physically mean anything, the actual height in pixels is just the absolute value of the specified value. If it is positive then the first row of pixels in the file is at the bottom of the image and each successive row is further up the image. If the height value is negative then the first row is at the top of the image (which is much more common in image formats) and the subsequent rows are further down the image.
In any case Global Mapper can handle them either way and it was easy enough to switch.
Thanks,
Mike
Global Mapper Guru
gmsupport@bluemarblegeo.com
http://www.globalmapper.com -
But we do exporting to BMP - and there are no such things as negative values anywhere in da header (at least for backward-compatibility). As far as I know...The TIFF format has a different way of storing orientation, but the fast majority are row-major and top down.
Anyway, the troubles were detected while opening all of previously-generated BMPs in ERDAS Imagine, ArcGIS and GeoExpress all together (where all are up to date). The above screenshots were made on GeoExpress as a sample. I bet those software must be strictly following all the file\protocol standarts since long ago, and if they all reporting the issue - means something is really wrong with the file...
After the fix, everything is back to normal. Thanks again. You may now close the thread as [SOLVED]. -
The original BMP export was just tested by loading them with the built-in BMP handling applications in Windows, and they handle them just fine regardless of whether they use a negative or positive height (they also use that value to control the orientation so you can get a top-down one). No big deal though we are used to updating exports to make other applications happy

Thanks,
Mike
Global Mapper Guru
gmsupport@bluemarblegeo.com
http://www.globalmapper.com
Categories
- 12.9K All Categories
- 5.8K Features Discussion
- 349 Downloading Imagery
- 1.3K Elevation Data
- 385 Georeferencing Imagery Discussion
- 651 GM Script Language
- 55 User Scripts
- 115 GPS Features
- 420 Projection Questions
- 835 Raster Data
- 1.4K Vector Data
- 6.6K Support
- 181 Announcement and News
- 936 Bug Report
- 561 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 578 Other Discussion
- 132 GIS Data Sources
- 27 Global Mapper Showcase
- 244 How I use Global Mapper
- 109 Global Mapper Forum Website
