Archived

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

WymsicalWyvern

BMP Writing

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.

Mike.

Share this post


Link to post
Share on other sites