RSS/Atom feed Twitter
Site is read-only, email is disabled

Problem loading BMP; invalid BMP or bug in GIMP?

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

13 of 13 messages available
Toggle history

Please log in to manage your subscriptions.

Problem loading BMP; invalid BMP or bug in GIMP? Roel Schroeven 29 Dec 09:56
  Problem loading BMP; invalid BMP or bug in GIMP? peter kostov 29 Dec 11:50
  Problem loading BMP; invalid BMP or bug in GIMP? Martin Nordholts 29 Dec 12:01
  Problem loading BMP; invalid BMP or bug in GIMP? Sven Neumann 29 Dec 12:14
   Problem loading BMP; invalid BMP or bug in GIMP? peter kostov 29 Dec 12:36
    Problem loading BMP; invalid BMP or bug in GIMP? Sven Neumann 29 Dec 12:42
     Problem loading BMP; invalid BMP or bug in GIMP? peter kostov 29 Dec 15:58
      Problem loading BMP; invalid BMP or bug in GIMP? Roel Schroeven 29 Dec 16:16
    Problem loading BMP; invalid BMP or bug in GIMP? Roel Schroeven 29 Dec 16:14
   Problem loading BMP; invalid BMP or bug in GIMP? Roel Schroeven 29 Dec 14:55
    Problem loading BMP; invalid BMP or bug in GIMP? Ernie Wright 30 Dec 19:30
     Problem loading BMP; invalid BMP or bug in GIMP? Jerry 26 Jan 17:40
      Problem loading BMP; invalid BMP or bug in GIMP? Michael Schumacher 26 Jan 18:53
Roel Schroeven
2008-12-29 09:56:38 UTC (almost 16 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

Hi,

I have some BMP-files that GIMP doesn't load correctly; GIMP shows almost the whole image as transparent instead of the real image data. Only a small region is visible, and even that with partial transparency. The image doesn't contain any transparency though (I don't even think BMP supports transparency).

Other image editors and viewers such as Irfanview and Paint.NET open the image correctly.

I'm using GIMP 2.6.2 on Windows XP. If you want to see the image, get it at http://rschroev.fastmail.fm/radar-20081222T090636-00.bmp (5 MB) or http://rschroev.fastmail.fm/radar-20081222T090636-00.zip (854 kB).

Should I report this as a bug? Or is the BMP maybe written in an invalid format?

peter kostov
2008-12-29 11:50:04 UTC (almost 16 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

Roel Schroeven wrote:

Hi,

I have some BMP-files that GIMP doesn't load correctly; GIMP shows almost the whole image as transparent instead of the real image data. Only a small region is visible, and even that with partial transparency. The image doesn't contain any transparency though (I don't even think BMP supports transparency).

Other image editors and viewers such as Irfanview and Paint.NET open the image correctly.

I'm using GIMP 2.6.2 on Windows XP. If you want to see the image, get it at http://rschroev.fastmail.fm/radar-20081222T090636-00.bmp (5 MB) or http://rschroev.fastmail.fm/radar-20081222T090636-00.zip (854 kB).

Should I report this as a bug? Or is the BMP maybe written in an invalid format?

Hi,

I can't help you :( I can only confirm what you are saying: On Linux (Gentoo) - identify:
identify "radar-20081222T090636-00.bmp" (9575) radar-20081222T090636-00.bmp BMP 1024x1280 1024x1280+0+0 8-bit DirectClass 5mb

In gqview and cinepaint the image looks normal, so it is when imported in Inkscape too.
In Gimp both 2.4 and 2.6.0 the image looks like you are describing - transparent.

Greetings,
Peter

Martin Nordholts
2008-12-29 12:01:56 UTC (almost 16 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

Roel Schroeven wrote:

Hi,

I have some BMP-files that GIMP doesn't load correctly; GIMP shows almost the whole image as transparent instead of the real image data. Only a small region is visible, and even that with partial transparency. The image doesn't contain any transparency though (I don't even think BMP supports transparency).

Other image editors and viewers such as Irfanview and Paint.NET open the image correctly.

I'm using GIMP 2.6.2 on Windows XP. If you want to see the image, get it at http://rschroev.fastmail.fm/radar-20081222T090636-00.bmp (5 MB) or http://rschroev.fastmail.fm/radar-20081222T090636-00.zip (854 kB).

Should I report this as a bug? Or is the BMP maybe written in an invalid format?

Hi

If other editors are able to open the file it is not corrupt. (Maybe it is but the other loaders are then at least able to adjust for this.)

Feel free to file a bug report and attach the BMP.

- Martin

Sven Neumann
2008-12-29 12:14:35 UTC (almost 16 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

Hi,

On Mon, 2008-12-29 at 09:56 +0100, Roel Schroeven wrote:

I have some BMP-files that GIMP doesn't load correctly; GIMP shows almost the whole image as transparent instead of the real image data. Only a small region is visible, and even that with partial transparency. The image doesn't contain any transparency though (I don't even think BMP supports transparency).

Other image editors and viewers such as Irfanview and Paint.NET open the image correctly.

I am not so sure about that. The image opened in GIMP has all the information and an alpha channel. If you change the alpha channel to be all opaque, then you will see the image as shown by other viewers you tried. So I would rather assume that the other viewers don't support masks in BMP files and just ignore that extra information. As long as that is not sorted out, you should not file this as a bug report against GIMP. It is quite likely that the bug is elsewhere.

Sven

peter kostov
2008-12-29 12:36:40 UTC (almost 16 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

Sven Neumann wrote:

Hi,

On Mon, 2008-12-29 at 09:56 +0100, Roel Schroeven wrote:

I have some BMP-files that GIMP doesn't load correctly; GIMP shows almost the whole image as transparent instead of the real image data. Only a small region is visible, and even that with partial transparency. The image doesn't contain any transparency though (I don't even think BMP supports transparency).

Other image editors and viewers such as Irfanview and Paint.NET open the image correctly.

I am not so sure about that. The image opened in GIMP has all the information and an alpha channel. If you change the alpha channel to be all opaque, then you will see the image as shown by other viewers you tried. So I would rather assume that the other viewers don't support masks in BMP files and just ignore that extra information. As long as that is not sorted out, you should not file this as a bug report against GIMP. It is quite likely that the bug is elsewhere.

Sven

Hi,
Sven is right. I just did:
"Add Layer Mask" -> "Transfer layer's alpha channel", check "Invert Mask", then file -> open as layers -> open the original image, flatten and the image is O.K.
So it is not a bug in GIMP, but maybe in the way the image was saved with this mask.

Peter

Sven Neumann
2008-12-29 12:42:34 UTC (almost 16 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

Hi,

On Mon, 2008-12-29 at 13:36 +0200, peter kostov wrote:

Sven is right. I just did:
"Add Layer Mask" -> "Transfer layer's alpha channel", check "Invert Mask", then file -> open as layers -> open the original image, flatten and the image is O.K.
So it is not a bug in GIMP, but maybe in the way the image was saved with this mask.

One could argue though that the BMP loader in GIMP should use a layer mask to represent the mask in the BMP file instead of using an alpha channel for this. You would probably have discovered this more easily then and it appears to be a better way to represent the BMP image structure. So I think we should accept a patch that changed the BMP file plug-in in this way.

Sven

Roel Schroeven
2008-12-29 14:55:11 UTC (almost 16 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

Sven Neumann schreef:

Hi,

On Mon, 2008-12-29 at 09:56 +0100, Roel Schroeven wrote:

I have some BMP-files that GIMP doesn't load correctly; GIMP shows almost the whole image as transparent instead of the real image data. Only a small region is visible, and even that with partial transparency. The image doesn't contain any transparency though (I don't even think BMP supports transparency).

Other image editors and viewers such as Irfanview and Paint.NET open the image correctly.

I am not so sure about that. The image opened in GIMP has all the information and an alpha channel. If you change the alpha channel to be all opaque, then you will see the image as shown by other viewers you tried. So I would rather assume that the other viewers don't support masks in BMP files and just ignore that extra information. As long as that is not sorted out, you should not file this as a bug report against GIMP. It is quite likely that the bug is elsewhere.

The image is a screenshot that I make using this simple Win32/VCL code:

// Graphics::TBitmap is a Borland VCL wrapper around a Windows bitmap void CaptureFromDC(HDC hDcSource, TRect Rect, Graphics::TBitmap *Bitmap) {
Bitmap->Width = Rect.Width();
Bitmap->Height = Rect.Height();
Bitmap->HandleType = bmDIB;

if (!BitBlt(Bitmap->Canvas->Handle, 0, 0,
Rect.Width(), Rect.Height(), hDcSource,
Rect.left, Rect.top,
SRCCOPY))
throw ECaptureError();
}

I can easily convert the bitmap to 24 bits, and then the image looks good in GIMP, which is to be expected since it doesn't contain any alpha information anymore. And it has the added benefit that the image files are smaller.

Either way it's no big deal to me. I only wonder exactly where the alpha values come from, but I guess that's more a question for a win32 programming mailing list.

peter kostov
2008-12-29 15:58:24 UTC (almost 16 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

Sven Neumann wrote:

Hi,

On Mon, 2008-12-29 at 13:36 +0200, peter kostov wrote:

Sven is right. I just did:
"Add Layer Mask" -> "Transfer layer's alpha channel", check "Invert Mask", then file -> open as layers -> open the original image, flatten and the image is O.K.
So it is not a bug in GIMP, but maybe in the way the image was saved with this mask.

Apparently Sven's answer didn't reach the list, so here it is:

One could argue though that the BMP loader in GIMP should use a layer mask to represent the mask in the BMP file instead of using an alpha channel for this. You would probably have discovered this more easily then and it appears to be a better way to represent the BMP image structure. So I think we should accept a patch that changed the BMP file plug-in in this way.

Sven

Roel, I don't understand your technique of creating this screenshot, but it looks like the BMP file has a mask in it. This is the source of the transparency, because the file-bmp plug-in transforms this into transparency. Unfortunately I can't understand exactly how to change the file-bmp plug-in to implement that what Sven is suggesting because at this time I know just a little python, but not C. Peter

Roel Schroeven
2008-12-29 16:14:18 UTC (almost 16 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

peter kostov schreef:

"Add Layer Mask" -> "Transfer layer's alpha channel", check "Invert Mask", then file -> open as layers -> open the original image, flatten and the image is O.K.

That doesn't seem to work for me. I get an image that is almost completely white. No big deal though: I just use Irfanview to read and save it, which removes the alpha channel.

So it is not a bug in GIMP, but maybe in the way the image was saved with this mask.

I suppose so. I'll just save the images with 24 bpp instead of 32 bpp; that way the image doesn't include an alpha channel.

Roel Schroeven
2008-12-29 16:16:22 UTC (almost 16 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

peter kostov schreef:

Roel, I don't understand your technique of creating this screenshot, but it looks like the BMP file has a mask in it. This is the source of the transparency, because the file-bmp plug-in transforms this into transparency.

Yes, I understand that now.

Unfortunately I can't understand exactly how to change the file-bmp plug-in to implement that what Sven is suggesting because at this time I know just a little python, but not C.

I know C but not much about GIMP's internals or the BMP image structure. I might try to create a patch if I find some time to study those.

Ernie Wright
2008-12-30 19:30:48 UTC (almost 16 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

Roel Schroeven wrote:

I can easily convert the bitmap to 24 bits, and then the image looks good in GIMP, which is to be expected since it doesn't contain any alpha information anymore. And it has the added benefit that the image files are smaller.

Either way it's no big deal to me. I only wonder exactly where the alpha values come from,

They could come from anywhere.

Historically, neither the BMP format nor the internal Windows structures that it maps to formally define an alpha channel. The BITMAPINFOHEADER biBitCount field can be set to 32, but the Windows SDK documentation says that in that case "the high byte...is not used." In the RGBQUAD structure used to hold 32-bpp pixels, the fourth field is "rgbReserved," not "rgbAlpha," and the description is "Reserved; must be zero."

The rationale for 32-bpp BMPs with an unused byte per pixel was that it kept pixels longword-aligned, which in long-ago times sped up image processing.

Naturally, BMP has been extended so that alpha is sometimes stored in that fourth byte, and sometimes this is done out of ignorance, because people *assume* that a 32-bpp format supports alpha. But alpha in BMP is by no means widely supported. There's no easy way to tell whether a given 32-bpp BMP contains a real alpha channel. And Windows itself doesn't directly support BMP with alpha.

Since most 32-bpp BMPs *don't* contain alpha, and in those images the fourth byte is 0, most image readers ignore the fourth byte.

A useful extension to any image loader/saver would be a preference setting with options like

* Assume 32-bpp BMPs have alpha * Assume that they don't
* Ask me each time

- Ernie http://home.comcast.net/~erniew

2014-01-26 17:40:36 UTC (almost 11 years ago)
postings
1

Problem loading BMP; invalid BMP or bug in GIMP?

Guys,
I'm enjoying GIMP for some time. For some time I use it for editing BMP images with alpha channel. These images are standard under Windows CE. Many GPS Navigation programs use it. GIMP version 8.2.6 was able to recognize such images and I was able to export As A8. These were perfectly compatible with Windows CE 5 and 6, as long as checked "do not write color space information". When not checked, image was shifted. GIMP 8.2.10 cannot recognize alpha channel in BMP. In addition, when proper image is exported as BMP alpha, it's not readable by Windows CE. Please fix this. Please return to 8.2.6 release that handled such images properly. If you could make GIMP to remember latest status of "do not write color space information" after exit, that would be nice. Maybe, introduction of Windows CE compatibility setup feature can be considered. Thanks for great work on this project.

And "Captcha" is insanely annoying :(

Michael Schumacher
2014-01-26 18:53:59 UTC (almost 11 years ago)

Problem loading BMP; invalid BMP or bug in GIMP?

Am 26.01.2014 18:40, schrieb Jerry:

I'm enjoying GIMP for some time. For some time I use it for editing BMP images with alpha channel. These images are standard under Windows CE. Many GPS Navigation programs use it.
GIMP version 8.2.6 was able to recognize such images and I was able to export As A8. These were perfectly compatible with Windows CE 5 and 6, as long as checked "do not write color space information". When not checked, image was shifted. GIMP 8.2.10 cannot recognize alpha channel in BMP. In addition, when proper image is exported as BMP alpha, it's not readable by Windows CE.

Do you have an example of a working and a non-working image somewhere?

And "Captcha" is insanely annoying :(

This is a mailing list, you could sign up directly instead of using it via the third-party gimpusers.* site.

Go to https://mail.gnome.org/mailman/listinfo/gimp-user-list to subscribe.

Regards,
Michael
GPG: 96A8 B38A 728A 577D 724D 60E5 F855 53EC B36D 4CDD