GLBasic forum

Main forum => Bug Reports => Topic started by: MrTAToad on 2010-Apr-10

Title: BMP files are loaded upside down
Post by: MrTAToad on 2010-Apr-10
It appears that on Windows at least, BMP files are loaded upside down...
Title: Re: BMP files are loaded upside down
Post by: Kuron on 2010-Apr-10
Hmm... I am using the latest version and this is not happening for me.
Title: Re: BMP files are loaded upside down
Post by: Ian Price on 2010-Apr-10
They work fine for me.
Title: Re: BMP files are loaded upside down
Post by: Moru on 2010-Apr-10
BMP can both be written from bottom to top or from top to bottom, mabe you have some pictures where this isn't set correct? Or mabe GLBasic is interpreting them wrong. Can you upload the image you have problems with?
Title: Re: BMP files are loaded upside down
Post by: MrTAToad on 2010-Apr-11
I've included the zipped BMP file.

Also here is the result of using it...

It loads correctly in Paint...

[attachment deleted by admin]
Title: Re: BMP files are loaded upside down
Post by: Ian Price on 2010-Apr-11
It does load correctly in MSPaint, but not in GLB as mentioned. However, when changed to a .PNG then returned to a .BMP it displays correctly. It seems to be a problem with the .BMP not GLB.

My guess is that whatever you saved this image from is doing something non-standard/unusual to the image. MSPaint handles non-standard, as it doesn't exactly stick with standard itself (32 bit .PNG - I'm looking at you!).

What did you use to create the image with?
Title: Re: BMP files are loaded upside down
Post by: MrTAToad on 2010-Apr-11
I suspect they were created by BlitzMax - when loading in Mappy data.  The file is over 4 years old now :)
Title: Re: BMP files are loaded upside down
Post by: Ian Price on 2010-Apr-11
Funny you mention BlitzMax, as I created a utility with BMax a long while back and it displayed a normal image upside down for no obvious reason.
Title: Re: BMP files are loaded upside down
Post by: Moru on 2010-Apr-11
BMP images are normally written upside down, you have to correct for that while loading. The height is a signed int :-)
Title: Re: BMP files are loaded upside down
Post by: Kitty Hello on 2010-Apr-12
That image has a biSizeImage value of 768, which is not typical for BI_RGB images.
The pixels are indeed upside down in the image bits. Very odd.
I can't find any other difference that indicates that the image is not stored upside down. :(

Can you ask the author of who wrote the bitmap?
Title: Re: BMP files are loaded upside down
Post by: MrTAToad on 2010-Apr-12
Unfortunately I cant there - it was programmatically created...

Ah well - cant blame GLBasic this time :)
Title: Re: BMP files are loaded upside down
Post by: Moru on 2010-Apr-12
If I remember right: when the height of a BMP is positive, the image lines are stored upside down.
If the height is negative, the image lines are stored the right way...
Mabe it was MS that created this format? :-)
Title: Re: BMP files are loaded upside down
Post by: Kitty Hello on 2010-Apr-13
the height of the image is positive, there's no difference. A real shame that I don't know what's different in this image and why the pixels are stored upside down. There must be some way to tell that, because MSPaint can read it properly.
Title: Re: BMP files are loaded upside down
Post by: Moru on 2010-Apr-13
I checked the BMP and the width is 0x1000 0000, the height is 0xF0FF FFFF
I would say the image is stored with negative height which means the line order is inverted to normal BMP.
Title: Re: BMP files are loaded upside down
Post by: Kitty Hello on 2010-Apr-13
That was it!!
I fixed it in the next update!
Title: Re: BMP files are loaded upside down
Post by: MrTAToad on 2010-Apr-13
Yey!