From 4665deda9e137dfa217e2a4c89d1f268bc886168 Mon Sep 17 00:00:00 2001 From: Lionel Ulmer Date: Mon, 14 Nov 2005 12:27:55 +0000 Subject: [PATCH] Use the front buffer palette for DC operations on off-screen buffers. --- dlls/ddraw/surface_main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dlls/ddraw/surface_main.c b/dlls/ddraw/surface_main.c index d01d6331aae..fd10394f055 100644 --- a/dlls/ddraw/surface_main.c +++ b/dlls/ddraw/surface_main.c @@ -900,6 +900,31 @@ Main_DirectDrawSurface_GetDC(LPDIRECTDRAWSURFACE7 iface, HDC *phDC) } hr = This->get_dc(This, &This->hDC); + + if ((This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) && + (This->palette == NULL)) { + IDirectDrawImpl *ddraw = This->ddraw_owner; + IDirectDrawSurfaceImpl *surf; + + for (surf = ddraw->surfaces; surf != NULL; surf = surf->next_ddraw) { + if (((surf->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER)) == (DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER)) && + (surf->palette != NULL)) { + RGBQUAD col[256]; + IDirectDrawPaletteImpl *pal = surf->palette; + unsigned int n; + for (n=0; n<256; n++) { + col[n].rgbRed = pal->palents[n].peRed; + col[n].rgbGreen = pal->palents[n].peGreen; + col[n].rgbBlue = pal->palents[n].peBlue; + col[n].rgbReserved = 0; + } + SetDIBColorTable(This->hDC, 0, 256, col); + break; + } + } + + } + if (SUCCEEDED(hr)) { TRACE("returning %p\n",This->hDC);