Re: [Gimp-user] Problem loading BMP; invalid BMP or bug in GIMP?

2008-12-30 Thread Ernie Wright
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
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Problem loading BMP; invalid BMP or bug in GIMP?

2008-12-29 Thread Roel Schroeven
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.

-- 
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven

___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Problem loading BMP; invalid BMP or bug in GIMP?

2008-12-29 Thread Roel Schroeven
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.

-- 
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven

___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Problem loading BMP; invalid BMP or bug in GIMP?

2008-12-29 Thread peter kostov
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

___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Problem loading BMP; invalid BMP or bug in GIMP?

2008-12-29 Thread Roel Schroeven
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.

-- 
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven

___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Problem loading BMP; invalid BMP or bug in GIMP?

2008-12-29 Thread Sven Neumann
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


___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Problem loading BMP; invalid BMP or bug in GIMP?

2008-12-29 Thread peter kostov
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
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Problem loading BMP; invalid BMP or bug in GIMP?

2008-12-29 Thread Sven Neumann
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


___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Problem loading BMP; invalid BMP or bug in GIMP?

2008-12-29 Thread Martin Nordholts
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

___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


Re: [Gimp-user] Problem loading BMP; invalid BMP or bug in GIMP?

2008-12-29 Thread peter kostov
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
___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user


[Gimp-user] Problem loading BMP; invalid BMP or bug in GIMP?

2008-12-29 Thread Roel Schroeven
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?

-- 
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven

___
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user