Jump to content
  • Advertisement

Archived

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

Cant load dark pixels from BMP ???

This topic is 5542 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

Hi I got a really wierd problem whit my BMP loaders they cant load too dark pixels! I mean color RGB(60,60,60) is ok but RGB(20,20,20) is too dark to load and the color shows incorrectly. Im really confused and dont have a glue what is causing this, any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Here comes the full code:

    

void Istream_Read(fstream& hfile,LPVOID wbuffer,int size)
{
hfile.read(reinterpret_cast<char*>(wbuffer),size);
}


int LoadBitmapFile(char *filename,int offset)
{
fstream file;
int padding;

file.open(filename, ios::in | ios::binary);

if(file.fail() ) return(0);

file.seekg(offset,ios::cur);

Istream_Read(file,&bitmap.bitmapfileheader,sizeof(BITMAPFILEHEADER));

// test if this is a bitmap file

if (bitmap.bitmapfileheader.bfType!=0x4D42)
{
file.close();
return(0);
} // end if


Istream_Read(file,&bitmap.bitmapinfoheader,sizeof(BITMAPINFOHEADER));

bitmap.sizeof_image = bitmap.bitmapfileheader.bfSize - bitmap.bitmapfileheader.bfOffBits;

padding = 4 - ((bitmap.bitmapinfoheader.biWidth * 3) % 4);
if(padding == 4) padding = 0;

if(bitmap.bitmapinfoheader.biBitCount==24)
{
int index;

if(bitmap.buffer) delete [] bitmap.buffer;
bitmap.buffer = new BYTE[bitmap.bitmapinfoheader.biSizeImage];
index=0;

for(int y=(bitmap.bitmapinfoheader.biHeight-1);y >= 0; y--)
{
for(int x=0;x < (bitmap.bitmapinfoheader.biWidth*3); x+=3)
{
index = y * (bitmap.bitmapinfoheader.biWidth*3) + x;

Istream_Read(file,&bitmap.buffer[index+2],1);
Istream_Read(file,&bitmap.buffer[index+1],1);
Istream_Read(file,&bitmap.buffer[index+0],1);
}
file.seekg(padding,ios::cur);
}

} // end if 24bit

else
return 0;

file.close();

return(1);

} // end Load_Bitmap_File




[edited by - Craazer on March 19, 2003 3:23:31 PM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!