~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/gdi32/enhmfdrv/objects.c

Version: ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Enhanced MetaFile objects
  3  *
  4  * Copyright 1999 Huw D M Davies
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include <stdlib.h>
 22 #include <stdio.h>
 23 #include <string.h>
 24 
 25 #include "enhmfdrv/enhmetafiledrv.h"
 26 #include "gdi_private.h"
 27 #include "wine/debug.h"
 28 
 29 WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile);
 30 
 31 
 32 /******************************************************************
 33  *         EMFDRV_AddHandle
 34  */
 35 static UINT EMFDRV_AddHandle( PHYSDEV dev, HGDIOBJ obj )
 36 {
 37     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE *)dev;
 38     UINT index;
 39 
 40     for(index = 0; index < physDev->handles_size; index++)
 41         if(physDev->handles[index] == 0) break;
 42     if(index == physDev->handles_size) {
 43         physDev->handles_size += HANDLE_LIST_INC;
 44         physDev->handles = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
 45                                        physDev->handles,
 46                                        physDev->handles_size * sizeof(physDev->handles[0]));
 47     }
 48     physDev->handles[index] = obj;
 49 
 50     physDev->cur_handles++;
 51     if(physDev->cur_handles > physDev->emh->nHandles)
 52         physDev->emh->nHandles++;
 53 
 54     return index + 1; /* index 0 is reserved for the hmf, so we increment everything by 1 */
 55 }
 56 
 57 /******************************************************************
 58  *         EMFDRV_FindObject
 59  */
 60 static UINT EMFDRV_FindObject( PHYSDEV dev, HGDIOBJ obj )
 61 {
 62     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
 63     UINT index;
 64 
 65     for(index = 0; index < physDev->handles_size; index++)
 66         if(physDev->handles[index] == obj) break;
 67 
 68     if(index == physDev->handles_size) return 0;
 69 
 70     return index + 1;
 71 }
 72 
 73 
 74 /******************************************************************
 75  *         EMFDRV_DeleteObject
 76  */
 77 BOOL EMFDRV_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
 78 {
 79     EMRDELETEOBJECT emr;
 80     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*) dev;
 81     UINT index;
 82     BOOL ret = TRUE;
 83 
 84     if(!(index = EMFDRV_FindObject(dev, obj))) return 0;
 85 
 86     emr.emr.iType = EMR_DELETEOBJECT;
 87     emr.emr.nSize = sizeof(emr);
 88     emr.ihObject = index;
 89 
 90     if(!EMFDRV_WriteRecord( dev, &emr.emr ))
 91         ret = FALSE;
 92 
 93     physDev->handles[index - 1] = 0;
 94     physDev->cur_handles--;
 95     return ret;
 96 }
 97 
 98 
 99 /***********************************************************************
100  *           EMFDRV_SelectBitmap
101  */
102 HBITMAP EMFDRV_SelectBitmap( PHYSDEV dev, HBITMAP hbitmap )
103 {
104     return 0;
105 }
106 
107 
108 /* Internal helper for EMFDRV_CreateBrushIndirect():
109  * Change the padding of a bitmap from 16 (BMP) to 32 (DIB) bits.
110  */
111 static inline void EMFDRV_PadTo32(LPBYTE lpRows, int height, int width)
112 {
113     int bytes16 = 2 * ((width + 15) / 16);
114     int bytes32 = 4 * ((width + 31) / 32);
115     LPBYTE lpSrc, lpDst;
116     int i;
117 
118     if (!height)
119         return;
120 
121     height = abs(height) - 1;
122     lpSrc = lpRows + height * bytes16;
123     lpDst = lpRows + height * bytes32;
124 
125     /* Note that we work backwards so we can re-pad in place */
126     while (height >= 0)
127     {
128         for (i = bytes32; i > bytes16; i--)
129             lpDst[i - 1] = 0; /* Zero the padding bytes */
130         for (; i > 0; i--)
131             lpDst[i - 1] = lpSrc[i - 1]; /* Move image bytes into alignment */
132         lpSrc -= bytes16;
133         lpDst -= bytes32;
134         height--;
135     }
136 }
137 
138 /***********************************************************************
139  *           EMFDRV_CreateBrushIndirect
140  */
141 DWORD EMFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush )
142 {
143     DWORD index = 0;
144     LOGBRUSH logbrush;
145 
146     if (!GetObjectA( hBrush, sizeof(logbrush), &logbrush )) return 0;
147 
148     switch (logbrush.lbStyle) {
149     case BS_SOLID:
150     case BS_HATCHED:
151     case BS_NULL:
152       {
153         EMRCREATEBRUSHINDIRECT emr;
154         emr.emr.iType = EMR_CREATEBRUSHINDIRECT;
155         emr.emr.nSize = sizeof(emr);
156         emr.ihBrush = index = EMFDRV_AddHandle( dev, hBrush );
157         emr.lb.lbStyle = logbrush.lbStyle;
158         emr.lb.lbColor = logbrush.lbColor;
159         emr.lb.lbHatch = logbrush.lbHatch;
160 
161         if(!EMFDRV_WriteRecord( dev, &emr.emr ))
162             index = 0;
163       }
164       break;
165     case BS_DIBPATTERN:
166       {
167         EMRCREATEDIBPATTERNBRUSHPT *emr;
168         DWORD bmSize, biSize, size;
169         BITMAPINFO *info = GlobalLock16(logbrush.lbHatch);
170 
171         if (info->bmiHeader.biCompression)
172             bmSize = info->bmiHeader.biSizeImage;
173         else
174             bmSize = DIB_GetDIBImageBytes(info->bmiHeader.biWidth,
175                                           info->bmiHeader.biHeight,
176                                           info->bmiHeader.biBitCount);
177         biSize = bitmap_info_size(info, LOWORD(logbrush.lbColor));
178         size = sizeof(EMRCREATEDIBPATTERNBRUSHPT) + biSize + bmSize;
179         emr = HeapAlloc( GetProcessHeap(), 0, size );
180         if(!emr) break;
181         emr->emr.iType = EMR_CREATEDIBPATTERNBRUSHPT;
182         emr->emr.nSize = size;
183         emr->ihBrush = index = EMFDRV_AddHandle( dev, hBrush );
184         emr->iUsage = LOWORD(logbrush.lbColor);
185         emr->offBmi = sizeof(EMRCREATEDIBPATTERNBRUSHPT);
186         emr->cbBmi = biSize;
187         emr->offBits = sizeof(EMRCREATEDIBPATTERNBRUSHPT) + biSize;
188         emr->cbBits = bmSize;
189         memcpy((char *)emr + sizeof(EMRCREATEDIBPATTERNBRUSHPT), info,
190                biSize + bmSize );
191 
192         if(!EMFDRV_WriteRecord( dev, &emr->emr ))
193             index = 0;
194         HeapFree( GetProcessHeap(), 0, emr );
195         GlobalUnlock16(logbrush.lbHatch);
196       }
197       break;
198 
199     case BS_PATTERN:
200       {
201         EMRCREATEDIBPATTERNBRUSHPT *emr;
202         BITMAPINFOHEADER *info;
203         BITMAP bm;
204         DWORD bmSize, biSize, size;
205 
206         GetObjectA((HANDLE)logbrush.lbHatch, sizeof(bm), &bm);
207 
208         if (bm.bmBitsPixel != 1 || bm.bmPlanes != 1)
209         {
210             FIXME("Trying to create a color pattern brush\n");
211             break;
212         }
213 
214         /* BMP will be aligned to 32 bits, not 16 */
215         bmSize = DIB_GetDIBImageBytes(bm.bmWidth, bm.bmHeight, bm.bmBitsPixel);
216 
217         biSize = sizeof(BITMAPINFOHEADER);
218         /* FIXME: There is an extra DWORD written by native before the BMI.
219          *        Not sure what its meant to contain.
220          */
221         size = sizeof(EMRCREATEDIBPATTERNBRUSHPT) + biSize + bmSize + sizeof(DWORD);
222 
223         emr = HeapAlloc( GetProcessHeap(), 0, size );
224         if(!emr)
225           break;
226 
227         info = (BITMAPINFOHEADER *)((LPBYTE)emr +
228                 sizeof(EMRCREATEDIBPATTERNBRUSHPT) + sizeof(DWORD));
229         info->biSize = sizeof(BITMAPINFOHEADER);
230         info->biWidth = bm.bmWidth;
231         info->biHeight = bm.bmHeight;
232         info->biPlanes = bm.bmPlanes;
233         info->biBitCount = bm.bmBitsPixel;
234         info->biSizeImage = bmSize;
235         GetBitmapBits((HANDLE)logbrush.lbHatch,
236                       bm.bmHeight * BITMAP_GetWidthBytes(bm.bmWidth, bm.bmBitsPixel),
237                       (LPBYTE)info + sizeof(BITMAPINFOHEADER));
238 
239         /* Change the padding to be DIB compatible if needed */
240         if (bm.bmWidth & 31)
241             EMFDRV_PadTo32((LPBYTE)info + sizeof(BITMAPINFOHEADER), bm.bmWidth, bm.bmHeight);
242 
243         emr->emr.iType = EMR_CREATEMONOBRUSH;
244         emr->emr.nSize = size;
245         emr->ihBrush = index = EMFDRV_AddHandle( dev, hBrush );
246         /* Presumably to reduce the size of the written EMF, MS supports an
247          * undocumented iUsage value of 2, indicating a mono bitmap without the
248          * 8 byte 2 entry black/white palette. Stupidly, they could have saved
249          * over 20 bytes more by also ignoring the BITMAPINFO fields that are
250          * irrelevant/constant for monochrome bitmaps.
251          * FIXME: It may be that the DIB functions themselves accept this value.
252          */
253         emr->iUsage = DIB_PAL_MONO;
254         emr->offBmi = (LPBYTE)info - (LPBYTE)emr;
255         emr->cbBmi = biSize;
256         emr->offBits = emr->offBmi + biSize;
257         emr->cbBits = bmSize;
258 
259         if(!EMFDRV_WriteRecord( dev, &emr->emr ))
260             index = 0;
261         HeapFree( GetProcessHeap(), 0, emr );
262       }
263       break;
264 
265     default:
266         FIXME("Unknown style %x\n", logbrush.lbStyle);
267         break;
268     }
269     return index;
270 }
271 
272 
273 /***********************************************************************
274  *           EMFDRV_SelectBrush
275  */
276 HBRUSH EMFDRV_SelectBrush(PHYSDEV dev, HBRUSH hBrush )
277 {
278     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
279     EMRSELECTOBJECT emr;
280     DWORD index;
281     int i;
282 
283     /* If the object is a stock brush object, do not need to create it.
284      * See definitions in  wingdi.h for range of stock brushes.
285      * We do however have to handle setting the higher order bit to
286      * designate that this is a stock object.
287      */
288     for (i = WHITE_BRUSH; i <= NULL_BRUSH; i++)
289     {
290         if (hBrush == GetStockObject(i))
291         {
292             index = i | 0x80000000;
293             goto found;
294         }
295     }
296     if((index = EMFDRV_FindObject(dev, hBrush)) != 0)
297         goto found;
298 
299     if (!(index = EMFDRV_CreateBrushIndirect(dev, hBrush ))) return 0;
300     GDI_hdc_using_object(hBrush, physDev->hdc);
301 
302  found:
303     emr.emr.iType = EMR_SELECTOBJECT;
304     emr.emr.nSize = sizeof(emr);
305     emr.ihObject = index;
306     return EMFDRV_WriteRecord( dev, &emr.emr ) ? hBrush : 0;
307 }
308 
309 
310 /******************************************************************
311  *         EMFDRV_CreateFontIndirect
312  */
313 static BOOL EMFDRV_CreateFontIndirect(PHYSDEV dev, HFONT hFont )
314 {
315     DWORD index = 0;
316     EMREXTCREATEFONTINDIRECTW emr;
317     int i;
318 
319     if (!GetObjectW( hFont, sizeof(emr.elfw.elfLogFont), &emr.elfw.elfLogFont )) return 0;
320 
321     emr.emr.iType = EMR_EXTCREATEFONTINDIRECTW;
322     emr.emr.nSize = (sizeof(emr) + 3) / 4 * 4;
323     emr.ihFont = index = EMFDRV_AddHandle( dev, hFont );
324     emr.elfw.elfFullName[0] = '\0';
325     emr.elfw.elfStyle[0]    = '\0';
326     emr.elfw.elfVersion     = 0;
327     emr.elfw.elfStyleSize   = 0;
328     emr.elfw.elfMatch       = 0;
329     emr.elfw.elfReserved    = 0;
330     for(i = 0; i < ELF_VENDOR_SIZE; i++)
331         emr.elfw.elfVendorId[i] = 0;
332     emr.elfw.elfCulture                 = PAN_CULTURE_LATIN;
333     emr.elfw.elfPanose.bFamilyType      = PAN_NO_FIT;
334     emr.elfw.elfPanose.bSerifStyle      = PAN_NO_FIT;
335     emr.elfw.elfPanose.bWeight          = PAN_NO_FIT;
336     emr.elfw.elfPanose.bProportion      = PAN_NO_FIT;
337     emr.elfw.elfPanose.bContrast        = PAN_NO_FIT;
338     emr.elfw.elfPanose.bStrokeVariation = PAN_NO_FIT;
339     emr.elfw.elfPanose.bArmStyle        = PAN_NO_FIT;
340     emr.elfw.elfPanose.bLetterform      = PAN_NO_FIT;
341     emr.elfw.elfPanose.bMidline         = PAN_NO_FIT;
342     emr.elfw.elfPanose.bXHeight         = PAN_NO_FIT;
343 
344     if(!EMFDRV_WriteRecord( dev, &emr.emr ))
345         index = 0;
346     return index;
347 }
348 
349 
350 /***********************************************************************
351  *           EMFDRV_SelectFont
352  */
353 HFONT EMFDRV_SelectFont( PHYSDEV dev, HFONT hFont, HANDLE gdiFont )
354 {
355     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
356     EMRSELECTOBJECT emr;
357     DWORD index;
358     int i;
359 
360     /* If the object is a stock font object, do not need to create it.
361      * See definitions in  wingdi.h for range of stock fonts.
362      * We do however have to handle setting the higher order bit to
363      * designate that this is a stock object.
364      */
365 
366     for (i = OEM_FIXED_FONT; i <= DEFAULT_GUI_FONT; i++)
367     {
368         if (i != DEFAULT_PALETTE && hFont == GetStockObject(i))
369         {
370             index = i | 0x80000000;
371             goto found;
372         }
373     }
374 
375     if((index = EMFDRV_FindObject(dev, hFont)) != 0)
376         goto found;
377 
378     if (!(index = EMFDRV_CreateFontIndirect(dev, hFont ))) return HGDI_ERROR;
379     GDI_hdc_using_object(hFont, physDev->hdc);
380 
381  found:
382     emr.emr.iType = EMR_SELECTOBJECT;
383     emr.emr.nSize = sizeof(emr);
384     emr.ihObject = index;
385     if(!EMFDRV_WriteRecord( dev, &emr.emr ))
386         return HGDI_ERROR;
387     return 0;
388 }
389 
390 
391 
392 /******************************************************************
393  *         EMFDRV_CreatePenIndirect
394  */
395 static DWORD EMFDRV_CreatePenIndirect(PHYSDEV dev, HPEN hPen)
396 {
397     EMRCREATEPEN emr;
398     DWORD index = 0;
399 
400     if (!GetObjectW( hPen, sizeof(emr.lopn), &emr.lopn ))
401     {
402         /* must be an extended pen */
403         EXTLOGPEN *elp;
404         INT size = GetObjectW( hPen, 0, NULL );
405 
406         if (!size) return 0;
407 
408         elp = HeapAlloc( GetProcessHeap(), 0, size );
409 
410         GetObjectW( hPen, size, elp );
411         /* FIXME: add support for user style pens */
412         emr.lopn.lopnStyle = elp->elpPenStyle;
413         emr.lopn.lopnWidth.x = elp->elpWidth;
414         emr.lopn.lopnWidth.y = 0;
415         emr.lopn.lopnColor = elp->elpColor;
416 
417         HeapFree( GetProcessHeap(), 0, elp );
418     }
419 
420     emr.emr.iType = EMR_CREATEPEN;
421     emr.emr.nSize = sizeof(emr);
422     emr.ihPen = index = EMFDRV_AddHandle( dev, hPen );
423 
424     if(!EMFDRV_WriteRecord( dev, &emr.emr ))
425         index = 0;
426     return index;
427 }
428 
429 /******************************************************************
430  *         EMFDRV_SelectPen
431  */
432 HPEN EMFDRV_SelectPen(PHYSDEV dev, HPEN hPen )
433 {
434     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
435     EMRSELECTOBJECT emr;
436     DWORD index;
437     int i;
438 
439     /* If the object is a stock pen object, do not need to create it.
440      * See definitions in  wingdi.h for range of stock pens.
441      * We do however have to handle setting the higher order bit to
442      * designate that this is a stock object.
443      */
444 
445     for (i = WHITE_PEN; i <= NULL_PEN; i++)
446     {
447         if (hPen == GetStockObject(i))
448         {
449             index = i | 0x80000000;
450             goto found;
451         }
452     }
453     if((index = EMFDRV_FindObject(dev, hPen)) != 0)
454         goto found;
455 
456     if (!(index = EMFDRV_CreatePenIndirect(dev, hPen))) return 0;
457     GDI_hdc_using_object(hPen, physDev->hdc);
458 
459  found:
460     emr.emr.iType = EMR_SELECTOBJECT;
461     emr.emr.nSize = sizeof(emr);
462     emr.ihObject = index;
463     return EMFDRV_WriteRecord( dev, &emr.emr ) ? hPen : 0;
464 }
465 
466 
467 /******************************************************************
468  *         EMFDRV_CreatePalette
469  */
470 static DWORD EMFDRV_CreatePalette(PHYSDEV dev, HPALETTE hPal)
471 {
472     WORD i;
473     struct {
474         EMRCREATEPALETTE hdr;
475         PALETTEENTRY entry[255];
476     } pal;
477 
478     memset( &pal, 0, sizeof(pal) );
479 
480     if (!GetObjectW( hPal, sizeof(pal.hdr.lgpl) + sizeof(pal.entry), &pal.hdr.lgpl ))
481         return 0;
482 
483     for (i = 0; i < pal.hdr.lgpl.palNumEntries; i++)
484         pal.hdr.lgpl.palPalEntry[i].peFlags = 0;
485 
486     pal.hdr.emr.iType = EMR_CREATEPALETTE;
487     pal.hdr.emr.nSize = sizeof(pal.hdr) + pal.hdr.lgpl.palNumEntries * sizeof(PALETTEENTRY);
488     pal.hdr.ihPal = EMFDRV_AddHandle( dev, hPal );
489 
490     if (!EMFDRV_WriteRecord( dev, &pal.hdr.emr ))
491         pal.hdr.ihPal = 0;
492     return pal.hdr.ihPal;
493 }
494 
495 /******************************************************************
496  *         EMFDRV_SelectPalette
497  */
498 HPALETTE EMFDRV_SelectPalette( PHYSDEV dev, HPALETTE hPal, BOOL force )
499 {
500     EMFDRV_PDEVICE *physDev = (EMFDRV_PDEVICE*)dev;
501     EMRSELECTPALETTE emr;
502     DWORD index;
503 
504     if (hPal == GetStockObject( DEFAULT_PALETTE ))
505     {
506         index = DEFAULT_PALETTE | 0x80000000;
507         goto found;
508     }
509 
510     if ((index = EMFDRV_FindObject( dev, hPal )) != 0)
511         goto found;
512 
513     if (!(index = EMFDRV_CreatePalette( dev, hPal ))) return 0;
514     GDI_hdc_using_object( hPal, physDev->hdc );
515 
516 found:
517     emr.emr.iType = EMR_SELECTPALETTE;
518     emr.emr.nSize = sizeof(emr);
519     emr.ihPal = index;
520     return EMFDRV_WriteRecord( dev, &emr.emr ) ? hPal : 0;
521 }
522 
523 
524 /******************************************************************
525  *         EMFDRV_GdiComment
526  */
527 BOOL EMFDRV_GdiComment(PHYSDEV dev, UINT bytes, CONST BYTE *buffer)
528 {
529     EMRGDICOMMENT *emr;
530     UINT total, rounded_size;
531     BOOL ret;
532 
533     rounded_size = (bytes+3) & ~3;
534     total = offsetof(EMRGDICOMMENT,Data) + rounded_size;
535 
536     emr = HeapAlloc(GetProcessHeap(), 0, total);
537     emr->emr.iType = EMR_GDICOMMENT;
538     emr->emr.nSize = total;
539     emr->cbData = bytes;
540     memset(&emr->Data[bytes], 0, rounded_size - bytes);
541     memcpy(&emr->Data[0], buffer, bytes);
542 
543     ret = EMFDRV_WriteRecord( dev, &emr->emr );
544 
545     HeapFree(GetProcessHeap(), 0, emr);
546 
547     return ret;
548 }
549 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.