wrong BMP files?

Discussion in 'C++' started by Marcin P, Apr 22, 2005.

  1. Marcin P

    Marcin P Guest

    When you build a 24-bit BMP file (without compression), its size should be:
    width*height*bitperpixel+54bytes (54 bytes from file and bitmap headers).

    When I create BMP files in MS Paint in "non-standard" dimensions
    (different than 1024x768 or 512x384) sizes of files are bigger than they
    sholud be.
    When dimensions are standard everything is OK.

    Example from Paint:
    white picture->173x14->save as 24bit BMP...
    and size written in bitmapfileheader is 7334 bytes... but it should be
    173*14*3+54=7320. The difference is 14 bytes. Why?

    When dimensions are 100x100 or 1024x768 - everything is OK.
    --
    Marcin P
    GG1020924
    skype: marcin_pil
     
    Marcin P, Apr 22, 2005
    #1
    1. Advertising

  2. "Marcin P" <> wrote in message
    news:4268d66b$
    > When you build a 24-bit BMP file (without compression), its size
    > should be: width*height*bitperpixel+54bytes (54 bytes from file and
    > bitmap headers).
    > When I create BMP files in MS Paint in "non-standard" dimensions
    > (different than 1024x768 or 512x384) sizes of files are bigger than
    > they sholud be.
    > When dimensions are standard everything is OK.
    >
    > Example from Paint:
    > white picture->173x14->save as 24bit BMP...
    > and size written in bitmapfileheader is 7334 bytes... but it should be
    > 173*14*3+54=7320. The difference is 14 bytes. Why?
    >
    > When dimensions are 100x100 or 1024x768 - everything is OK.


    In bitmaps, each scanline (ie row of pixels) must be dword aligned.
    To achieve that, padding is added, if neccessary. i you have 173 pixels
    in widthwith 3 bytes per pixel, you have a total of 519 bytes per
    scanline. Now the next dword boundary is 520, so you have to add1
    padding byte. Do that for all 14 scanlines and you have the difference
    of 14 bytes.

    hth
    --
    jb

    (reply address in rot13, unscramble first)
     
    Jakob Bieling, Apr 22, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Allan Herriman

    Re: VHDL testbench: read BMP Files?

    Allan Herriman, Aug 21, 2003, in forum: VHDL
    Replies:
    1
    Views:
    5,188
    Allan Herriman
    Aug 21, 2003
  2. Martin Thompson

    Re: VHDL testbench: read BMP Files?

    Martin Thompson, Aug 21, 2003, in forum: VHDL
    Replies:
    0
    Views:
    976
    Martin Thompson
    Aug 21, 2003
  3. Amontec Team, Laurent Gauch

    Re: VHDL testbench: read BMP Files?

    Amontec Team, Laurent Gauch, Aug 21, 2003, in forum: VHDL
    Replies:
    0
    Views:
    757
    Amontec Team, Laurent Gauch
    Aug 21, 2003
  4. Harry Simpson

    32 dpp BMP to 24dpp BMP??

    Harry Simpson, Oct 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    348
    Harry Simpson
    Oct 30, 2003
  5. Craig
    Replies:
    2
    Views:
    681
    Soni Bergraj
    Dec 4, 2006
Loading...

Share This Page