Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


BMP Writing

This topic is 6296 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

K, i thought i was past BMP loading a saving, but when i came back to use the loader I wrote a year back, i noticed there was some garbage on the first line, just at the end of it. the writing code i used was: m_f.write( (char*)&bmfHeader, sizeof( bmfHeader ) ); m_f.write( (char*)&bmiHeader, sizeof( bmiHeader ) ); m_f.write( pBytes, ( m_pData->format->BytesPerPixel * m_pData->w + usPadBytes ) * m_pData->h ); where: bmfHeader = filled file header structure bmiHeader = filled info header structure pBytes = an array of size ( ( m_pData->format->BytesPerPixel * m_pData->w + usPadBytes ) * m_pData->h ) usPadBytes = the amount of pad bytes needed for each row m_pData = the Original SDL surface before i copied it into my array (pBytes) I filled my pBytes with pure green right before i called these writing lines, and the garbage still showed up, so i know its nothing to do with my copying an SDL surface to array of chars. Is there soemthing I''m missing about the BMP file format? thx in advance, THE WYMSICAL WYVERN

Share this post

Link to post
Share on other sites
Something similar came up recently on another thread (see "Why do I get wrong fileheader-values reading bitmaps"). Could be the same problem here.

Try writing out the values in your headers individually, rather than writing out the entire structures. Could be that the compiler is padding out the structures.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!