Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > wrong BMP files?

Reply
Thread Tools

wrong BMP files?

 
 
Marcin P
Guest
Posts: n/a
 
      04-22-2005
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
 
Reply With Quote
 
 
 
 
Jakob Bieling
Guest
Posts: n/a
 
      04-22-2005
"Marcin P" <(E-Mail Removed)> wrote in message
news:4268d66b$(E-Mail Removed)
> 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)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BMP to TIFF or TIFF to BMP- any loss? Jenna Topping Digital Photography 5 01-23-2005 01:18 AM
32 dpp BMP to 24dpp BMP?? Harry Simpson ASP .Net 0 10-30-2003 07:36 PM
Re: VHDL testbench: read BMP Files? Amontec Team, Laurent Gauch VHDL 0 08-21-2003 02:43 PM
Re: VHDL testbench: read BMP Files? Martin Thompson VHDL 0 08-21-2003 10:57 AM
Re: VHDL testbench: read BMP Files? Allan Herriman VHDL 1 08-21-2003 09:15 AM



Advertisments