Commit b9b159e5 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

gdi32: Fix EMR_CREATEPALETTE recording.

parent c752e845
...@@ -651,27 +651,27 @@ static BOOL emfdc_select_pen( DC_ATTR *dc_attr, HPEN pen ) ...@@ -651,27 +651,27 @@ static BOOL emfdc_select_pen( DC_ATTR *dc_attr, HPEN pen )
static DWORD emfdc_create_palette( struct emf *emf, HPALETTE hPal ) static DWORD emfdc_create_palette( struct emf *emf, HPALETTE hPal )
{ {
BYTE data[offsetof( EMRCREATEPALETTE, lgpl.palPalEntry[256] )];
EMRCREATEPALETTE *hdr = (EMRCREATEPALETTE *)data;
WORD i; WORD i;
struct {
EMRCREATEPALETTE hdr;
PALETTEENTRY entry[255];
} pal;
memset( &pal, 0, sizeof(pal) ); memset( data, 0, sizeof(data) );
if (!GetObjectW( hPal, sizeof(pal.hdr.lgpl) + sizeof(pal.entry), &pal.hdr.lgpl )) hdr->lgpl.palVersion = 0x300;
hdr->lgpl.palNumEntries = GetPaletteEntries( hPal, 0, 256, hdr->lgpl.palPalEntry );
if (!hdr->lgpl.palNumEntries)
return 0; return 0;
for (i = 0; i < pal.hdr.lgpl.palNumEntries; i++) for (i = 0; i < hdr->lgpl.palNumEntries; i++)
pal.hdr.lgpl.palPalEntry[i].peFlags = 0; hdr->lgpl.palPalEntry[i].peFlags = 0;
pal.hdr.emr.iType = EMR_CREATEPALETTE; hdr->emr.iType = EMR_CREATEPALETTE;
pal.hdr.emr.nSize = sizeof(pal.hdr) + pal.hdr.lgpl.palNumEntries * sizeof(PALETTEENTRY); hdr->emr.nSize = offsetof( EMRCREATEPALETTE, lgpl.palPalEntry[hdr->lgpl.palNumEntries] );
pal.hdr.ihPal = emfdc_add_handle( emf, hPal ); hdr->ihPal = emfdc_add_handle( emf, hPal );
if (!emfdc_record( emf, &pal.hdr.emr )) if (!emfdc_record( emf, &hdr->emr ))
pal.hdr.ihPal = 0; hdr->ihPal = 0;
return pal.hdr.ihPal; return hdr->ihPal;
} }
BOOL EMFDC_SelectPalette( DC_ATTR *dc_attr, HPALETTE palette ) BOOL EMFDC_SelectPalette( DC_ATTR *dc_attr, HPALETTE palette )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment