Jump to content
  • Advertisement

Archived

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

Sponge99

Loading bitmaps

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

Arghhh! Loading images is so hard. Currently I''m loading bitmaps, and have loaded the file header and info (which includes infoheader and rgbquad structures). All done correctly, i''ve checked the bit depth and all that rot with it -- just assume..., And now I need to find the actual image data. I''ve got it to something like: fseek(file, -imagesize, SEEK_END); but then how would I read it in? It''s a 24 bit bitmap, where, how, etc, do I retreive and store the actual pixel information? I need some help bad... Thanks! Sponge99

Share this post


Link to post
Share on other sites
Advertisement
  

unsigned char * imagedata;
imagedata = new unsigned char[SizeOfData];
fread(imagedata, sizeof(unsigned char), SizeOfData, fp);



every 3 bytes in the imagedata buffer = 1 pixel;

Byte 1 = Red
Byte 2 = Green
Byte 3 = Blue

Share this post


Link to post
Share on other sites
Here's the code I have:
    
BYTE * bmpbuffer = (BYTE*) malloc(bmi.bmiHeader.biSizeImage);
memset(&bmpbuffer, 0, bmi.bmiHeader.biSizeImage);
fseek(bmpfile, -(int)bmi.bmiHeader.biSizeImage, SEEK_END);
fread(&bmpbuffer, bmi.bmiHeader.biSizeImage, 1, bmpfile);

memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);

lpDDSBack->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL);
USHORT * vid = (USHORT*) ddsd.lpSurface;

for (x = y = i = 0; y < bmi.bmiHeader.biHeight; x++)
{
vid[x+y*(ddsd.lPitch >> 1)] = RGB16BIT_565(bmpbuffer[i*3+0],bmpbuffer[i*3+1],bmpbuffer[i*3+2]);

if (x > bmi.bmiHeader.biWidth)
{
x = -1; // will be ++'ed

y++;
}
i++;
}

lpDDSBack->Unlock(NULL);


So...I'm reading all of the image data (correct?) into a buffer, defined as the size of bytes of the image. Then, each three bytes in that buffer should be the RGB (in bmp, BGR?) values. When I use this code, it writes a bunch of junk pixels. I don't get it!! What's goin' wrong?

The bmp is 24-bit, not compressed (RGB compression value)

Thanks!
-Sponge99

Edited by - Sponge99 on August 7, 2001 9:43:49 AM

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!