diff --git a/dlls/gdi/gdi16.c b/dlls/gdi/gdi16.c index 14e8826f84c..3ba6d17c853 100644 --- a/dlls/gdi/gdi16.c +++ b/dlls/gdi/gdi16.c @@ -21,6 +21,7 @@ #include "winbase.h" #include "wingdi.h" #include "wine/wingdi16.h" +#include "gdi.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(gdi); @@ -1593,6 +1594,24 @@ HPALETTE16 WINAPI CreatePalette16( const LOGPALETTE* palette ) } +/*********************************************************************** + * GDISelectPalette (GDI.361) + */ +HPALETTE16 WINAPI GDISelectPalette16( HDC16 hdc, HPALETTE16 hpalette, WORD wBkg ) +{ + return HPALETTE_16( GDISelectPalette( HDC_32(hdc), HPALETTE_32(hpalette), wBkg )); +} + + +/*********************************************************************** + * GDIRealizePalette (GDI.362) + */ +UINT16 WINAPI GDIRealizePalette16( HDC16 hdc ) +{ + return GDIRealizePalette( HDC_32(hdc) ); +} + + /*********************************************************************** * GetPaletteEntries (GDI.363) */ diff --git a/include/gdi.h b/include/gdi.h index 6947e9fd7e0..558379d9f0f 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -455,6 +455,10 @@ extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCSTR filename); /* region.c */ extern BOOL REGION_FrameRgn( HRGN dest, HRGN src, INT x, INT y ); +/* palette.c */ +extern HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg); +extern UINT WINAPI GDIRealizePalette( HDC hdc ); + #define WINE_GGO_GRAY16_BITMAP 0x7f #endif /* __WINE_GDI_H */ diff --git a/objects/dc.c b/objects/dc.c index 28f25bf2f02..50e0bea61b8 100644 --- a/objects/dc.c +++ b/objects/dc.c @@ -433,7 +433,7 @@ void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs ) SelectObject( hdc, dcs->hPen ); SetBkColor( hdc, dcs->backgroundColor); SetTextColor( hdc, dcs->textColor); - GDISelectPalette16( hdc, dcs->hPalette, FALSE ); + GDISelectPalette( hdc, dcs->hPalette, FALSE ); GDI_ReleaseObj( hdcs ); GDI_ReleaseObj( hdc ); } diff --git a/objects/palette.c b/objects/palette.c index bc441fb228e..238e7ad0324 100644 --- a/objects/palette.c +++ b/objects/palette.c @@ -53,8 +53,8 @@ static const struct gdi_obj_funcs palette_funcs = /* Pointers to USER implementation of SelectPalette/RealizePalette */ /* they will be patched by USER on startup */ -FARPROC pfnSelectPalette = NULL; -FARPROC pfnRealizePalette = NULL; +HPALETTE (WINAPI *pfnSelectPalette)(HDC hdc, HPALETTE hpal, WORD bkgnd ) = NULL; +UINT (WINAPI *pfnRealizePalette)(HDC hdc) = NULL; static UINT SystemPaletteUse = SYSPAL_STATIC; /* currently not considered */ @@ -657,11 +657,11 @@ static BOOL PALETTE_DeleteObject( HGDIOBJ handle, void *obj ) /*********************************************************************** - * GDISelectPalette (GDI.361) + * GDISelectPalette (Not a Windows API) */ -HPALETTE16 WINAPI GDISelectPalette16( HDC16 hdc, HPALETTE16 hpal, WORD wBkg) +HPALETTE WINAPI GDISelectPalette( HDC hdc, HPALETTE hpal, WORD wBkg) { - HPALETTE16 prev; + HPALETTE prev; DC *dc; TRACE("%04x %04x\n", hdc, hpal ); @@ -681,9 +681,9 @@ HPALETTE16 WINAPI GDISelectPalette16( HDC16 hdc, HPALETTE16 hpal, WORD wBkg) /*********************************************************************** - * GDIRealizePalette (GDI.362) + * GDIRealizePalette (Not a Windows API) */ -UINT16 WINAPI GDIRealizePalette16( HDC16 hdc ) +UINT WINAPI GDIRealizePalette( HDC hdc ) { UINT realized = 0; DC* dc = DC_GetDCPtr( hdc ); @@ -694,11 +694,10 @@ UINT16 WINAPI GDIRealizePalette16( HDC16 hdc ) if( dc->hPalette == GetStockObject( DEFAULT_PALETTE )) { - GDI_ReleaseObj( hdc ); - return RealizeDefaultPalette16( hdc ); + if (dc->funcs->pRealizeDefaultPalette) + realized = dc->funcs->pRealizeDefaultPalette( dc->physDev ); } - - if(dc->hPalette != hLastRealizedPalette ) + else if(dc->hPalette != hLastRealizedPalette ) { if (dc->funcs->pRealizePalette) realized = dc->funcs->pRealizePalette( dc->physDev, dc->hPalette, @@ -707,10 +706,10 @@ UINT16 WINAPI GDIRealizePalette16( HDC16 hdc ) pLastRealizedDC = dc->funcs; } else TRACE(" skipping (hLastRealizedPalette = %04x)\n", hLastRealizedPalette); - GDI_ReleaseObj( hdc ); + GDI_ReleaseObj( hdc ); TRACE(" realized %i colors.\n", realized ); - return (UINT16)realized; + return realized; }