Jump to content

Image file header issue when saving 24bit Bitmap (.BMP) files


Go to solution Solved by null54,

Recommended Posts

Hello. It seems I've ran into an issue using Paint.Net to save 24bit Bitmap (BMP) files...

 

In short, the biSizeImage field of the Bitmap file header is always set to 0!

 

I am using the latest version, 5.0.3, portable x64 from the github release page.

 

I have attached an image showing the header files for a bitmap I saved using PDN. The highlighted line has the field I'm talking about.

 

This doesn't seem to negatively impact anything I use the file for under windows... However, when I sent the file to a friend using some version of Linux (I don't know which one exactly), it would seem that this caused some problems for him and he was unable to use the image.

 

Saving image using a different editor like MS Paint seems to work fine, and the biSizeImage field gets set correctly as expected...

my-bad-header.png

Link to comment
Share on other sites

According to Microsoft's documentation, a value of 0 is acceptable for an uncompressed RGB bitmap.

https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader

 

 

Your friend should submit a bug report for whatever software he is using.

As a workaround, he can also re-encode the bitmap using a tool like Imagemagick, which is included by default with many GNU/Linux distros.

  • Like 1
  • Upvote 1

(September 25th, 2023)  Sorry about any broken images in my posts. I am aware of the issue.

bp-sig.png
My Gallery  |  My Plugin Pack

Layman's Guide to CodeLab

Link to comment
Share on other sites

  • Solution
22 minutes ago, drone1400 said:

However, when I sent the file to a friend using some version of Linux (I don't know which one exactly), it would seem that this caused some problems for him and he was unable to use the image.

 

That sounds like a bug in that version of Linux.

The BMP format specification allows biSizeImage to be 0 when biCompression is BI_RGB, see https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader.

 

22 minutes ago, drone1400 said:

Saving image using a different editor like MS Paint seems to work fine, and the biSizeImage field gets set correctly as expected...

 

Paint.NET uses the BMP read/write functionality that is built-in to Windows (Windows Imaging Component).

  • Like 1
  • Upvote 1

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint Shop Pro Filetype | RAW Filetype | WebP Filetype

The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait

 

Link to comment
Share on other sites

  • 9 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...