Archived

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

Merwin van Dijk

RGBQUAD/PALETTEENTRY

Recommended Posts

Hello, I am trying to make my own CBmp class which can load a 8-bit bmp-file, draw it in the screen and give the palette from the bmp-file to a LPDIRETDRAWPALETTE interface. I''ve seen a similar class in which the palette is loaded first to an array (m_rgbPalette) of the structure RGBQUAD. if(OK)OK=ReadFile(hfile,m_rgbPalette,sizeof(m_rgbPalette), &actualRead,NULL); If the palette must be set to a LPDIRETDRAWPALETTE interface, the RGBQUAD structure must be converted to a PALLETTEENTRY structure. BOOL CBmpFileReader::setpalette(LPDIRECTDRAWPALETTE palette){ PALETTEENTRY pe[COLORS]; //intermediate palette //construct pe[] for(int i=0; i.peRed=m_rgbPalette[i].rgbRed; //set red pe[i].peGreen=m_rgbPalette[i].rgbGreen; //set green pe[i].peBlue=m_rgbPalette[i].rgbBlue; //set blue } //load direct draw palette to surface palette->SetEntries(NULL,0,COLORS,pe); return TRUE; } My question is; ''Why don''t they load the palette of the bmp-file directly to a PALETTEENTRY structure?''. PS: The source is from a book called ''Learn computer game programming with direct 7.0''.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
because a RGBQUAD is a struct with 4 values... and in BMP files it''s BGR.... so you read BGR and you fill the RGBQUAD with RGB that all

Share this post


Link to post
Share on other sites