本文整理汇总了C++中LPDIRECTDRAWPALETTE类的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWPALETTE类的具体用法?C++ LPDIRECTDRAWPALETTE怎么用?C++ LPDIRECTDRAWPALETTE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LPDIRECTDRAWPALETTE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SimpleFindClosestIndex
DWORD
CDirect2DRMDevice::GetColor(BYTE r, BYTE g, BYTE b)
{
HRESULT hr;
if (m_pddsBackBuffer == NULL)
return E_NOTINITIALIZED;
// REVIEW: this function is heavy weight when the device is palettized
DWORD nBPP = m_ddsd.ddpfPixelFormat.dwRGBBitCount;
if (nBPP <= 8) {
// palettized
PALETTEENTRY rgpe[nMAXPALETTEENTRIES];
LPDIRECTDRAWPALETTE pddp = NULL;
if (FAILED(hr = m_pddsBackBuffer->GetPalette(&pddp)) ||
FAILED(hr = pddp->GetEntries(0, 0, nMAXPALETTEENTRIES, rgpe))) {
MMRELEASE(pddp);
return hr;
}
MMRELEASE(pddp);
return SimpleFindClosestIndex(rgpe, 1 << nBPP, r, g, b);
} else {
// RGB
return m_pixi.Pack(r, g, b);
}
return 0;
}
示例2: SetPalette
HRESULT STDMETHODCALLTYPE SetPalette(LPDIRECTDRAWSURFACE7 surface, LPDIRECTDRAWPALETTE lpDDPalette)
{
//logOutput << CurrentTimeString() << "Hooked SetPalette()" << endl;
ddrawSurfaceSetPalette.Unhook();
HRESULT hr = surface->SetPalette(lpDDPalette);
ddrawSurfaceSetPalette.Rehook();
if (getFrontSurface(surface))
{
if (lpDDPalette)
lpDDPalette->AddRef();
SetupPalette(lpDDPalette);
}
return hr;
}
示例3: PaletteSetEntries
HRESULT STDMETHODCALLTYPE PaletteSetEntries(LPDIRECTDRAWPALETTE palette, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries)
{
//logOutput << CurrentTimeString() << "Hooked SetEntries()" << endl;
ddrawPaletteSetEntries.Unhook();
HRESULT hr = palette->SetEntries(dwFlags, dwStartingEntry, dwCount, lpEntries);
ddrawPaletteSetEntries.Rehook();
// update buffer palette
if (SUCCEEDED(hr))
{
if (g_CurrentPalette.bInitialized)
{
memcpy(g_CurrentPalette.entries + dwStartingEntry, lpEntries, 4 * dwCount); // each entry is 4 bytes if DDCAPS_8BITENTRIES flag is not set
}
}
return hr;
}
示例4: SetupPalette
bool SetupPalette(LPDIRECTDRAWPALETTE lpDDPalette)
{
if (!lpDDPalette)
{
//logOutput << CurrentTimeString() << "Detaching palette" << endl;
g_CurrentPalette.Free();
g_bUsePalette = false;
return false;
}
logOutput << CurrentTimeString() << "initializing palette" << endl;
DWORD caps;
HRESULT hr;
if (FAILED(hr = lpDDPalette->GetCaps(&caps)))
{
logOutput << CurrentTimeString() << "Failed to get palette caps" << endl;
printDDrawError(hr, "SetupPalette");
return false;
}
if (caps & DDPCAPS_8BITENTRIES)
{
logOutput << CurrentTimeString() << "8-bit index-palette used (lookup color is an index to another lookup table), not implemented" << endl;
return false;
}
DWORD numEntries = 0;
if (caps & DDPCAPS_8BIT)
numEntries = 0x100;
else if (caps & DDPCAPS_4BIT)
numEntries = 0x10;
else if (caps & DDPCAPS_2BIT)
numEntries = 0x04;
else if (caps & DDPCAPS_1BIT)
numEntries = 0x02;
else
{
logOutput << CurrentTimeString() << "Unrecognized palette format" << endl;
return false;
}
//logOutput << CurrentTimeString() << "Trying to retrieve " << numEntries << " palette entries" << endl;
g_CurrentPalette.Reallocate(numEntries);
hr = lpDDPalette->GetEntries(0, 0, numEntries, g_CurrentPalette.entries);
if (FAILED(hr))
{
logOutput << CurrentTimeString() << "Failed to retrieve palette entries" << endl;
printDDrawError(hr, "SetupPalette");
g_CurrentPalette.Free();
return false;
}
g_CurrentPalette.primary_surface_palette_ref = lpDDPalette;
g_CurrentPalette.bInitialized = true;
g_bUsePalette = true;
logOutput << CurrentTimeString() << "Initialized palette with " << numEntries << " color entries" << endl;
return true;
}
示例5: PisteDraw_Paletti_Pyorita
int PisteDraw_Paletti_Pyorita(UCHAR eka_vari, UCHAR vika_vari)
{
UCHAR i;
if (FAILED(PD_lpddpal->GetEntries(0,0,255,PD_paletti_nyt))) {
PisteLog_Kirjoita("[Error] Piste Draw: Palette get entries failed!\n");
return PD_VIRHE;
}
PALETTEENTRY temp_vari;
temp_vari.peRed = PD_paletti_nyt[vika_vari].peRed;
temp_vari.peGreen = PD_paletti_nyt[vika_vari].peGreen;
temp_vari.peBlue = PD_paletti_nyt[vika_vari].peBlue;
for (i=vika_vari;i>eka_vari;i--)
{
PD_paletti_nyt[i].peRed = PD_paletti_nyt[i-1].peRed;
PD_paletti_nyt[i].peGreen = PD_paletti_nyt[i-1].peGreen;
PD_paletti_nyt[i].peBlue = PD_paletti_nyt[i-1].peBlue;
}
PD_paletti_nyt[eka_vari].peRed = temp_vari.peRed;
PD_paletti_nyt[eka_vari].peGreen = temp_vari.peGreen;
PD_paletti_nyt[eka_vari].peBlue = temp_vari.peBlue;
if (FAILED(PD_lpddpal->SetEntries(0,0,255,PD_paletti_nyt))) {
PisteLog_Kirjoita("[Error] Piste Draw: Palette set entries failed!\n");
return PD_VIRHE;
}
return 0;
}
示例6: Game_Shutdown
int Game_Shutdown(void *parms = NULL, int num_parms = 0)
{
// this is called after the game is exited and the main event
// loop while is exited, do all you cleanup and shutdown here
// kill all the surfaces
// first the palette
if (lpddpal)
{
lpddpal->Release();
lpddpal = NULL;
} // end if
// now the primary surface
if (lpddsprimary)
{
lpddsprimary->Release();
lpddsprimary = NULL;
} // end if
// now blow away the IDirectDraw4 interface
if (lpdd)
{
lpdd->Release();
lpdd = NULL;
} // end if
// return success or failure or your own return code here
return(1);
} // end Game_Shutdown
示例7: DD_Shutdown
int DD_Shutdown(void)
{
// this function release all the resources directdraw
// allocated, mainly to com objects
// release the clipper first
if (lpddclipper)
lpddclipper->Release();
// release the palette
if (lpddpal)
lpddpal->Release();
// release the secondary surface
if (lpddsback)
lpddsback->Release();
// release the primary surface
if (lpddsprimary)
lpddsprimary->Release();
// finally, the main dd object
if (lpdd)
lpdd->Release();
// return success
return(1);
} // end DD_Shutdown
示例8: PisteDraw_Paletti_Set
int PisteDraw_Paletti_Set(void)
{
if (FAILED(PD_lpddpal->SetEntries(0,0,255,PD_paletti_nyt))) {
PisteLog_Kirjoita("[Error] Piste Draw: Palette set failed!\n");
return PD_VIRHE;
}
return 0;
}
示例9: CleanupGraphics
//-----------------------------------------------------------------------------
// Name: CleanupGraphics()
// Desc:
//-----------------------------------------------------------------------------
VOID CleanupGraphics()
{
for( DWORD i=0; i<4; i++ )
if( g_pddsShip[i] )
g_pddsShip[i]->Release();
if( g_pddsNumbers )
g_pddsNumbers->Release();
if( g_pddsFrontBuffer )
g_pddsFrontBuffer->Release();
if( g_pArtPalette )
g_pArtPalette->Release();
if( g_pSplashPalette )
g_pSplashPalette->Release();
if( !g_bFullscreen && g_pddsBackBuffer )
g_pddsBackBuffer->Release();
if( g_pDD )
g_pDD->Release();
}
示例10: PisteDraw_Paletti_Get
int PisteDraw_Paletti_Get(PALETTEENTRY *&paletti)
{
if (FAILED(PD_lpddpal->GetEntries(0,0,255,PD_paletti_nyt))) {
PisteLog_Kirjoita("[Error] Piste Draw: Palette get failed!\n");
return PD_VIRHE;
}
paletti = (PALETTEENTRY *)PD_paletti_nyt;
return 0;
}
示例11: ReloadPrimarySurfacePaletteEntries
void ReloadPrimarySurfacePaletteEntries()
{
if (!primary_surface_palette_ref)
return;
HRESULT err;
ddrawPaletteSetEntries.Unhook();
if (FAILED(err = primary_surface_palette_ref->SetEntries(0, 0, numEntries, entries)))
{
logOutput << CurrentTimeString() << "ReloadPrimarySurfacePaletteEntries(): could not set entires" << endl;
printDDrawError(err);
}
ddrawPaletteSetEntries.Rehook();
}
示例12: Game_Shutdown
int Game_Shutdown(void *parms = NULL, int num_parms = 0)
{
// this is called after the game is exited and the main event
// loop while is exited, do all you cleanup and shutdown here
// first the palette
if (lpddpal)
{
lpddpal->Release();
lpddpal = NULL;
} // end if
// now the lpddsbackground surface
if (lpddsbackground)
{
lpddsbackground->Release();
lpddsbackground = NULL;
} // end if
// now the lpddsback surface
if (lpddsback)
{
lpddsback->Release();
lpddsback = NULL;
} // end if
// now the primary surface
if (lpddsprimary)
{
lpddsprimary->Release();
lpddsprimary = NULL;
} // end if
// now blow away the IDirectDraw4 interface
if (lpdd)
{
lpdd->Release();
lpdd = NULL;
} // end if
// unload the bitmap file, we no longer need it
Unload_Bitmap_File(&bitmap);
// return success or failure or your own return code here
return(1);
} // end Game_Shutdown
示例13: PisteDraw_Fade_Paletti_Do
int PisteDraw_Fade_Paletti_Do(int pros)
{
UCHAR i;
if (FAILED(PD_lpddpal->GetEntries(0,0,255,PD_paletti_nyt))) {
PisteLog_Kirjoita("[Error] Piste Draw: Palette get entries failed!\n");
return PD_VIRHE;
}
for (i=0;i<255;i++)
{
PD_paletti_nyt[i].peRed = (PD_paletti[i].peRed * pros / 100);
PD_paletti_nyt[i].peGreen = (PD_paletti[i].peGreen * pros / 100);
PD_paletti_nyt[i].peBlue = (PD_paletti[i].peBlue * pros / 100);
}
if (FAILED(PD_lpddpal->SetEntries(0,0,255,PD_paletti_nyt))) {
PisteLog_Kirjoita("[Error] Piste Draw: Palette set entries failed!\n");
return PD_VIRHE;
}
return 0;
}
示例14: Set_Palette_Entry
int Set_Palette_Entry(int index, int red, int blue, int green)
{
PALETTEENTRY colour;
colour.peRed = (BYTE)red;
colour.peGreen = (BYTE)green;
colour.peBlue = (BYTE)blue;
colour.peFlags = PC_NOCOLLAPSE;
lpddpal->SetEntries(0,index,1,&colour);
memcpy(&colour_palette[index], &colour, sizeof(PALETTEENTRY));
return 1;
}
示例15: screen_updatepalette
static void screen_updatepalette(void)
{
HRESULT ret;
int idx;
if (!lpDDPal)
return;
//log("screen_updatepalette\n");
// for (idx = 1; idx < 17; idx ++)
// DD_RGBTOPAL(idx, win_rgbmap[idx]);
/* ret = lpDDPal->SetEntries(0, 0, 17, pals+rand()%16);
if (ret != DD_OK)
error(_("videoupdatepalette: SetPalette failed (%d)\n"), ret);*/
for (idx = 0; idx < 17; idx ++)
DD_RGBTOPAL(idx, win_rgbmap[idx]);
ret = lpDDPal->SetEntries(0, 0, 17, pals);
if (ret != DD_OK)
module_logger(&win32DirectDrawVideo, _L|LOG_ERROR|LOG_USER, _("videoupdatepalette: SetPalette failed (%d)\n"), ret);
}