BMP header is corrupt

#1
I have created a night view for my photo realistic scenery and added a layer to paint in some lights.
I then select Flatten and export it as a 24 bit BMP image file.
Resample doesn't like it giving the error "BMP header is corrupt".
I searched this error message here and read replies asking the author had he saved as a 24 bit BMP file which is exactly what I have done.
What can I do (I am using GIMP)?
Thanks
 
Last edited:
#2
I have solved this.
It seems to be a problem with how GIMP saves a BMP image (export as).
I loaded the image file created by GIMP into Paint Shop Pro and just saved it as.
No problems now.
Is this an issue known about GIMP?
 
#3
Hi John:

I thought I had already linked to pertinent information regarding the CAVEATS for how to save BMPs and TIFs compatible with SDK Resample when using GIMP, within one of the prior threads where we were discussing GIMP; however, I cannot find such a prior thread at the moment, so it was probably posted / linked in one of the other discussions I was also having on similar topics with others here over the last couple of months.

FYI: You can find that info cited above, in this thread at PTSIM: :idea:

http://www.ptsim.com/forum/viewtopic.php?f=30&p=8557&sid=09a779362e05b2342f8b53839555eed6#p8555


GaryGB
 
Last edited:
#4
Hi Gary,

You probably did cover this in a previous post.
I started looking through all the posts/replies you have given (me) in the past and gave up after the nth page. Sorry but it seems you also could not find it.
As mentioned I did search for "BMP header is corrupt" and did find one thread and followed it without immediate success and then read something about using Photoshop and then wondered if I loaded it into PSP and just saved it might fix the problem and it did (my second post).

I had completely forgotten about the ptsim forum although the problem is related to GIMP and RESAMPLE not SBX.

Also I had read through the Microsoft SDK Terrain and Scenery document (https://msdn.microsoft.com/en-us/library/cc707102.aspx?f=255&MSPPError=-2147217396) and could not find anything pertinent there before I resorted to creating the thread.

Aha was it using TIF images? I had considered (in the past) that you only used them for the water and bland masks after only ever noticing them in INF files for those masks?

It might be better if I 'dump' GIMP and start to use my (new) PSP version which allows for large files (the reason I started using GIMP).
 
Last edited:
#5
Hi John:

I'm glad PaintShop Pro (aka "PSP") could load the GIMP BMP and output a corrected header for a Resample-compatible BMP file. ;)


The reason I suggest GIMP for those just beginning to work with custom photo-real aerial imagery BGLs that utilize Blend and Land-Water Masks, is to be able to refer them to the example work flow in the Tiberius et al tutorial on this subject over at flightsim.com which shows the actual graphics application brushwork and settings used, etc.. :pushpin:


Some people do not prefer videos, and yet other people do prefer videos; personally, I prefer illustrated written tutorials such as that by Tiberius et al, and those by Luis Feliz-Tirado ...so I tend to refer people to them moreso than videos.


After newcomers to this aspect of scenery design become more familiar with the fundamental of the above process, there are certainly some advantages to switching from GIMP to PSP / PhotoPaint / PhotoShop, etc.as their graphics application.


Hopefully the feature set in PSP for ex: creation of gradients in masks is comparable to that in PhotoShop, which was cited by Holger in the linked thread I referred to within your other thread here at FSDeveloper.


I encourage you to continue diligently searching and testing to find what seems best for your development work-flow. :)

GaryGB
 
Last edited:
#6
Thanks Gary,

I was happy to use GIMP when I started as my (old) PSP X2 would not handle the large image I had. And I'm also happy to continue using it. That is the only reason I started to use it but then became somewhat 'hooked' on it.
It is very strange that I never got the error (BMP header is corrupt) when I exported my water and blend masks as BMP files. Maybe the problem had something to do with one of the following -
I exported with "do not write color space information" unticked (not selected) - I selected it when creating water and blend masks. Maybe I should try that out as there has to be a reason.
OR
I had previously performed a 'flatten'
That is the only difference between when it works and when it doesn't.
I really should read up the GIMP manual.

I too like illustrated written tutorials too and have a number of illustrated books on other subjects.
Some videos are terrible especially those with NO spoken word and/or the author moves the mouse pointer around the screen and selects menu items "faster than a speeding bullet" :banghead:
 
#8
Thanks Tejal

It was the second 'link' that I found when I searched "BNP header is corrupt".
The problem I sometimes have with some of these threads is that they quote another link and so you click on it and read it and they too sometimes give another link which you click on and read and then you navigate back to the previous thread read on, another link, backwards and forwards and you end up 'bamboozled'.
Thanks anyway.
 
#10
I may have the 'answer'
I just exported my image as a 24 bit BMP file but this time I ticked (selected) Compatible Options - Do not write color space information.
I had always 'ticked' that box when creating water and blend masks and assumed it had something to do with making sure the saved image was black and white only. When I exported my image which has color in it the image file created has color in it.
Maybe it doesn't fix the problem (I didn't have the time to check) Googling "do not write color....' reveals -

this function save the color space information in the BMP header

on GIMP BMP export filter is actually the binary difference between a version 3 BMP file, and a version 4 bmp file, which was introduced as far back as Windows 95.

There maybe more but I can't be bothered looking and maybe this has nothing to do with getting the error.

Someone is now going to jump on me I suspect.
 
#11
http://www.fsdeveloper.com/forum/threads/bmp-header-is-corrupt.441662/#post-787244

I may have the 'answer'
I just exported my image as a 24 bit BMP file but this time I ticked (selected) Compatible Options - Do not write color space information.
I had always 'ticked' that box when creating water and blend masks and assumed it had something to do with making sure the saved image was black and white only. When I exported my image which has color in it the image file created has color in it.
Maybe it doesn't fix the problem (I didn't have the time to check) Googling "do not write color....' reveals -

this function save the color space information in the BMP header

on GIMP BMP export filter is actually the binary difference between a version 3 BMP file, and a version 4 bmp file, which was introduced as far back as Windows 95.

There maybe more but I can't be bothered looking and maybe this has nothing to do with getting the error.

Someone is now going to jump on me I suspect.
Hi John:

When I saw this, I thought I'd better "jump" in and point out the post I found, that I was originally looking for above: :p

http://www.fsdeveloper.com/forum/th...-scenery-achievable.440912/page-4#post-781748

< The 7th link (...not clicked ?) within the post I originally linked to above at PTSIM >:duck:



GaryGB :santahat:
 

Attachments

Last edited:
#12
Thanks Gary for finding that.
That thread carries over to 4 'pages' and many more 'screens full' to wade through.
Maybe I should cut and paste the entire thread into a printable document as I do find lately that reading from a printed page is MUCH easier on my eyes as reading from a bright screen (apart from not having to angle my head upwards). Getting too old.
There is heaps of expert information there from your good self.
Also I can do a 'find' much easier in a document than a thread which has multi 'pages'.

I must say that since receiving all your replies I have learned HEAPS and have experimented more too. Saying that I often realise what a complex 'thing' the FSX 'engine' is.

Added later

I have created a (Word) document containing every line from the thread and I was shocked.
83 pages after I removed all superfluous stuff like name, date joined, messages location etc (106 pages before). I would never have believed it.
 
Last edited:
#13
Hi Gary,

Could you please remind me again the advantage of creating TIF files for the masks.
I just created a blend mask in both BMP and TIF and the TIF was LARGER in size.
 
#14
Hi John:

I believe that the thread I linked to above:

http://www.fsdeveloper.com/forum/th...-scenery-achievable.440912/page-4#post-781748

...contains a rather thorough discussion of the options for source file format intended- and compatible- for use with SDK Resample.


Because there are differences in how various graphics applications output BMP files which could lead to inconsistent results when working with "BMP" (aka Bitmap") files intended for use as for Blend and Land-Water Masks, ACES and experienced FS Developers / "FS-Insiders" began mentioning in documentation, forum posts, and tutorials, the option to use TIFF files in specified formats for Blend and Land-Water Masks.

IIRC, this was in response to early feedback and observations from would-be FSX Developers on how problematic the roll-out of the "new" Blend and Land-Water Masks feature was, when actually implemented by the FS Community (where a 'plethora' of different graphics applications were in use that had differing internal names for features and differing file output formats) when BMPs and TIFFs were used with SDK Resample.

Thus, efforts were made to try and help minimize the risk of aspiring FS developers ending up with file formats and sizes that are either not compatible- or otherwise a "P.I.T.A."- to work with in SDK Resample, by utilizing TIFF files in specified formats.

TIFF files can use 'non-lossy' LZW compression (at the expense of longer processing times), and can be formatted as 1-Bit Black-and-White (2) Indexed 'Colors' for Land-Water Masks, and 8-Bit Grayscale (256) 'colors' for Blend Masks as data (not imagery) sources used to define transition thresholds for transparency in Raster processing of land class texture layers by the FS Rendering engine at run time.

The advantage of these lesser color 'Bit-Depth' (aka "Bit-ness") file formats is that they are smaller than a 24-Bit or 32-Bit (millions of colors) file, when all that is needed by SDK Resample for Mask 'data' source files are:

* 2 'colors' (as Black and White) for On-Off transparency in a Land-Water Mask

...and:

* 256 'colors' (as gray-scale steps) for incremental (aka "gradient") transparency in a Blend Mask

Any more 'colors' than those (which are implemented via increasing Bit-Depth of the texture file) are wasted space on disk, in RAM, and in USER Virtual Address Space (aka "USERVA") within the FS Windows Task Session itself.

[EDITED]

NOTE: Final output source file format for TIFF Masks must actually be 8-Bit gray-scale; see:

http://www.fsdeveloper.com/forum/th...-scenery-achievable.440912/page-4#post-789447

[END_EDIT]


Thus, I suggest that you use the above TIFF format(s) for your Land-Water Masks and Blend Masks, as you had expressed concern as to the size required to implement a high resolution custom photo-real aerial imagery land class BGL for your project's coverage area. ;)

GaryGB
 
Last edited:
#15
Hi Gary

Silly me. I had forgotten to transform my blend mask to grayscale before I exported to TIF image. That certainly made a difference to the file size.

I ended up with a big problem though and feel that I must have missed something when using TIF images for the masks.

The compiled BGL file is slightly smaller than the one when using BMP masks BUT it does NOT display in FSX. It is as if there was no satellite imagery there at all.

I went back through the entire thread (What is the highest resolution) I created in September and found nothing obvious.
I also went through Luis' document (Make photo-real ground textures in Flight Simulator X) and found nothing obvious.
I think maybe I came across the same 'problem' months ago when you suggested using TIF images for masks (to save space) so just went back to using BMP masks.

Strangely I am able to 'view' both BGL files using tmfviewer. So why doesn't the one made using TIF masks show in FSX I wonder.

Added later.
There seems to be another problem too with my blend mask and I have suspected this for a while (as I don't see a nice blend progression along the edge in FSX). When I view the image of my blend mask within GIMP I see grayscale along the edges where I have 'painted' it. When export it either as a BMP OR TIF image and view either image by either editing it or simply doing a right mouse click on the file and select PREVIEW) all I see is black and white - no grayscale blending where I painted it. I have reread a few times Tiberius' tutorial (which uses GIMP) and I am doing EXACTLY the same as he describes. I have even reworked the method 3 or 4 times without success.

This is annoying the hell out of me and I'm just about to "throw the towel in".

Here is part of my blend mask as I see it in GIMP (1st image) and the resulting blend mask image file (2nd image). Not only note the loss of grayscale blending but also black areas within the transparent parts which aren't in the GIMP mask.

FSD BLEND MASK.jpg


FSD IMAGE.jpg
 
Last edited:
#16
Hi John:

It is apparent that the gray-scale Blend Mask original in GIMP is losing the gray-scale attribute when saved as an output file.

If you try to create a gray-scale Blend Mask original in GIMP by saving it to a BMP file format without having derived it from a 24-Bit color source image and/or if output options are not configured correctly, the resulting image file is output likely to be treated the same as it would by PhotoShop: it will become 1-Bit "Indexed" (2)-color Black-and-White ...rather than the required 8-Bit gray-scale "paletted" color-to-gray version derived from a (custom ?) 'palette color mapping' conversion algorithm in GIMP.


NOTE: The 'Tiberius et al' tutorial creates a new layer with "Transparency" ticked in the dialog, then uses a '100 % hardness brush tip' for the Water Mask, and a '50-75% hardness' brush tip for Blend Mask; each mask is then saved as a 24-Bit color BMP file.

Thus
:

* '100 % hardness brush tip' for the Water Mask results in NO transparency at edges of the area painted Black (RGB 0,0,0)

* '50-75 % hardness brush tip' for the Blend Mask DOES result in transparency at edges of the area painted Black (RGB 0,0,0)


...when saved by GIMP as a BMP with:

* "Run Length Encoded" (aka "RLE") NOT checked

* "Do NOT write color space information" checked

* "24-Bits" (R8 G8 B8) 'ticked'



But, for smaller SDK Resample compiled custom aerial imagery land class BGLs, I recommend instead configuring GIMP to output your:

Water Mask
: as a 1-Bit Black (RGB 0,0,0) and White (RGB 255,255,255) only {=(2)-'indexed colors'}

...and

BlendMask
: as a 8-Bit gray-scale from Black (RGB 0,0,0) to White (RGB 255,255,255) {=(256)-'colors'}

...each in their own in separate TIFF file format, as previously discussed here:


http://www.fsdeveloper.com/forum/th...-scenery-achievable.440912/page-4#post-781748

http://www.fsdeveloper.com/forum/th...-scenery-achievable.440912/page-4#post-781748

Please convert Blend Mask files from 24-Bit color BMPs to 8-Bit gray-scale '(256)-colors', and please also convert Land-Water Masks to 1-Bit B-&-W '(2)-indexed colors' TIFF files ...as described in the context of the above quoted original discussions within this thread. ;)


Assuming you are still using GIMP, perhaps these documentation links may serve as a reminder of available options:

https://docs.gimp.org/en/gimp-tutorial-quickie-change-mode.html

https://docs.gimp.org/en/gimp-image-convert-indexed.html
[EDITED]

NOTE: Final output source file format for TIFF Masks must actually be 8-Bit gray-scale; see:

http://www.fsdeveloper.com/forum/th...-scenery-achievable.440912/page-4#post-789447

[END_EDIT]

Then, 'Export' (...do NOT merely "Save" / "Save As" :alert:) each Mask from GIMP, in a separate TIFF format file, as discussed here:

https://docs.gimp.org/en/gimp-images-out.html

GaryGB
 
Last edited:
#17
Thanks Gary for your expert guidance,

I will rework my masks later taking note of all you stated.
There are quite a few things which I am already doing (such as Export and not Save and even temporarily deleted unwanted layers before exporting just to ensure I was exporting the correct layer/mask) but it is good to have everything listed.

NOTE: The 'Tiberius et al' tutorial creates a new layer with "Transparency" ticked in the dialog, then uses a '100 % hardness brush tip' for the Water Mask, and a '50-75% hardness' brush tip for Blend Mask; each mask is then saved as a 24-Bit color BMP file.
When I use GIMP I always find "Transparency" ticked as the default and never change it.

Regards

John
 
#18
Gary

I have started doing what your 'tutorial' states and it does NOT work for me.
1) I load my saved GIMP file which contains all my layers (background, water and blend).
2) I temporarily delete all layers except my blend mask and check that it does contain grayscale 'blending' on the edges (as my example above shows).
3) I select COLORS > POSTERISE (reduce colors) and select 256.
4) Select File > Export as
5) Click on the + symbol at bottom of screen next to 'Select File type by extension' then select 'Windows BMP image' then enter my filename and then click on EXPORT
6) Select 'Do Not Write color space information' in compatibility
7) Select '24 bits R8 G8 B8' in advanced options
8) Click on Export
And as before my saved (BMP) image is only 2 colors and NO grayscale.

I give up.

What did I do which is incorrect?

NOTE Run Length Encoded is grayed out and not checked.

Added later
In desperation (and believe that is what it is coming to) I created a brand new blend mask exactly as shown in the tutorial and EXPORTED as a BMP image. SAME PROBLEM. Image is 2 colors and no grayscale.
 
Last edited:
#19
Hi John:

On the road now, so only have a moment.

Please double-click on my (Yellow) quote above and read the GIMP docs on Mode change and Indexed color. ;)

http://www.fsdeveloper.com/forum/threads/bmp-header-is-corrupt.441662/#post-787429

[EDITED]

CAVEAT: Image 'Mode change' and 'Indexed color' is done within GIMP's work-space before Export as a TIFF file format. :pushpin:

The 'Type' for those source files must be changed from BMP to TIFF in the INF file as well. :alert:

PS:

Since I don't personally use GIMP, at best, that might be merely "Export Guidance" ! :D

[END_EDIT]

GaryGB
 
Last edited:
#20
Thanks Gary

I must be dumb, blind or a mixture of both as I still cannot see it.

To make this all the more damned annoying is that if I draw on my background (satellite image) with a '50% brush' and export it when I view the exported image I see my black line together with the grayscale along the edge. So why doesn't the blend mask

Also I am following Tiberius tutorial "to the letter" and it doesn't work for me. You are quoting stuff (mode change and indexed color) which Tiberius does not yet his blend mask works.

Looking back at your statement "If you try to create a gray-scale Blend Mask original in GIMP by saving it to a BMP file format without having derived it from a 24-Bit color source image" I wonder if this is the 'key' to my problem and if it is what did I do wrong.
I started with a 32 bit BMP image (from SBX) of my satellite image and then simply created layers for the masks.


Added later

In another 'desperate' move I started a brand new project. Opened the (32bit) satellite image (BMP), added layers for water and blend masks and created a brand new blend mask and exported it using the same settings as per Tiberius. SAME PROBLEM. BMP blend mask is only 2 colours - no grayscale.
 
Last edited:
Top