🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
help with .bmp
could someone show me what i need to do to get this to take bmps with nonmultiple of 4 widths
for (int index_y = 0; index_y < bitmap.bitmapinfoheader.biHeight; index_y++)
{
for (int index_x = 0; index_x < bitmap.bitmapinfoheader.biWidth; index_x++)
{
UCHAR blue = (bitmap.buffer[index_y * bitmap.bitmapinfoheader.biWidth * 3 + index_x * 3 + 0]),
green = (bitmap.buffer[index_y * bitmap.bitmapinfoheader.biWidth * 3 + index_x * 3 + 1]),
red = (bitmap.buffer[index_y * bitmap.bitmapinfoheader.biWidth * 3 + index_x * 3 + 2]);
UINT pixel = _RGB32BIT(0, red, green, blue);
back_buffer[(index_y * ddsd.lPitch >> 2) + index_x] = pixel;
}
}
You need to skip ahead
sizof(DWORD) - (sizeof(whatever color format) * width % 4)
for 24 bit color sizeof(whatever color format) would be sizeof(UCHAR) * 3
Instead of trying to implement that logic into your assignments, you might want to use a dummy variable for the bitmat.buffer[] index.
int i=0;for(height){ for(width) { UCHAR blue = bitmap.buffer;<BR> green = bitmap.buffer[i+1];<BR> red = bitmat.buffer [i+2];<BR> <BR> i += 3;<BR> }<BR> i += sizeof(DWORD) - (sizeof(UCHAR) * 3 * width %4)<BR>}<P></pre><P>Or, alternately, since youre using 32 bit color you can just save 32 bit .BMP's which should have properly aligned scan lines. <IMG SRC="http://www.gamedev.net/community/forums/ubb/wink.gif"><BR>