Skip to main content
gamedev.net
🔒 Locked

256 palette loading example please?

Started by xtrmntr 1 reply 550+ views
Original Post
xtrmntr
xtrmntr
i have paint shop pro and have saved the 256 color palette that it uses and that i used to create some bitmaps. how do i load the palette into a palette structure from that so my bitmaps look correct? any code will be greatly appreciated
bogdanontanu
bogdanontanu
hi

well u can try save the pallete as a jasc pallete and u will see its a text file with a little header and folowing pallete entryes

i am sure u can write some code to read a text file ...

another way is to read the a bitmap file (8 bits) int memory and figure out pallete from it...a little harder... but u can do it is u check BITMAPCOREINFO and like win32api structures

sorry for no code but i work in asm and belive me i set the pallete manually (the single pallete of course)


Bogdan
obysoft
Priesty
Priesty
Check the part of my old DD class. It reads file (fn) and reads 768 bytes of the data. Than it sets it. Don''t pay attention on this ugly style, that were a few years ago.

    
PALETTEENTRY palEntries[256];
ifstream FO(fn);
if (FO.fail()) return FALSE;
FO.read((char*)&palEntries,sizeof(palEntries));
FO.close();

// Create a DirectDrawPalette object.

HRESULT result = m_pDirectDrawObj->CreatePalette(DDPCAPS_8BIT,
palEntries, &m_pDirectDrawPal, NULL);

// If the palette is created unsuccessfully,
// make the palette''s pointer NULL.

if (result != DD_OK)
{
m_pDirectDrawPal = NULL;
success = FALSE;
}
else
{
result = m_pPrimarySurface->SetPalette(m_pDirectDrawPal);
if (result != DD_OK)
success = FALSE;
}





------------------------------
DISCLAIMER: Im not responsible for any harm that my english can cause to your eyes, brains or programming skills.

------------------------------DISCLAIMER: Im not responsible for any harm that my english can cause to your eyes, brains or programming skills.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.