1 /*
2  * Fig2dev: Translate Fig code to various Devices
3  * Copyright (c) 1991 by Micah Beck
4  * Parts Copyright (c) 1985-1988 by Supoj Sutanthavibul
5  * Parts Copyright (c) 1989-2015 by Brian V. Smith
6  * Parts Copyright (c) 2015-2020 by Thomas Loimer
7  *
8  * Any party obtaining a copy of these files is granted, free of charge, a
9  * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
10  * nonexclusive right and license to deal in this software and documentation
11  * files (the "Software"), including without limitation the rights to use,
12  * copy, modify, merge, publish, distribute, sublicense and/or sell copies
13  * of the Software, and to permit persons who receive copies from any such
14  * party to do so, with the only requirement being that the above copyright
15  * and this permission notice remain intact.
16  *
17  */
18 
19 /*
20  * genemf.h: convert fig to Enhanced MetaFile header file
21  *
22  * Written by Michael Schrick (2001-03-04)
23  *
24  */
25 
26 #ifndef GENEMF_H
27 #define GENEMF_H
28 
29 #if defined HAVE_CONFIG_H && !defined VERSION
30 #include "config.h"
31 #endif
32 
33 
34 typedef unsigned char  uchar;
35 typedef unsigned short TCHAR;
36 
37 /* 16bit value */
38 typedef short		EMFshort;
39 typedef unsigned short	EMFushort;
40 
41 /* 32bit value (use int, not long, for LP64 platforms) */
42 typedef int		EMFlong;
43 typedef unsigned int	EMFulong;
44 
45 /* 32bit floating value */
46 typedef union {
47 	EMFulong	bit_uint;	/* bit pattern */
48 	/* float	val_float; */	/* floating value (not portable) */
49 } EMFfloat;
50 
51 
52 /*
53  * Macros for conversion between host and file byte order.
54  */
55 
56 #ifndef BYTE_ORDER
57 # define BIG_ENDIAN	4321
58 # define LITTLE_ENDIAN	1234
59 
60 # ifdef WORDS_BIGENDIAN
61 #  define BYTE_ORDER	BIG_ENDIAN
62 # else
63 #  define BYTE_ORDER	LITTLE_ENDIAN
64 # endif
65 
66 #endif
67 
68 #if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
69 
70 # define htofs(x) (x)
71 # define htofl(x) (x)
72 
73 # define ftohs(x) (x)
74 # define ftohl(x) (x)
75 
76 #else
77 # if defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)
78 
79 #  define htofs(x) ((EMFushort)( \
80 		(((EMFushort)(x) & (EMFushort)0x00ffU) << 8) | \
81 		(((EMFushort)(x) & (EMFushort)0xff00U) >> 8) ))
82 #  define htofl(x) ((EMFulong)( \
83 		(((EMFulong)(x) & (EMFulong)0x000000ffUL) << 24) | \
84 		(((EMFulong)(x) & (EMFulong)0x0000ff00UL) <<  8) | \
85 		(((EMFulong)(x) & (EMFulong)0x00ff0000UL) >>  8) | \
86 		(((EMFulong)(x) & (EMFulong)0xff000000UL) >> 24) ))
87 
88 #  define ftohs(x) (htofs(x))
89 #  define ftohl(x) (htofl(x))
90 
91 # else
92 
93 /* Unknwon endian.  This is not efficient but should work. */
94 #  include <netinet/in.h>
95 
96 #  define htofs(x) ((EMFushort)htons( \
97 		(((EMFushort)(x) & (EMFushort)0x00ffU) << 8) | \
98 		(((EMFushort)(x) & (EMFushort)0xff00U) >> 8) ))
99 #  define htofl(x) ((EMFulong)htonl( \
100 		(((EMFulong)(x) & (EMFulong)0x000000ffUL) << 24) | \
101 		(((EMFulong)(x) & (EMFulong)0x0000ff00UL) <<  8) | \
102 		(((EMFulong)(x) & (EMFulong)0x00ff0000UL) >>  8) | \
103 		(((EMFulong)(x) & (EMFulong)0xff000000UL) >> 24) ))
104 
105 #  define ftohs(x) ((EMFushort)( \
106 		(((EMFushort)ntohs(x) & (EMFushort)0x00ffU) << 8) | \
107 		(((EMFushort)ntohs(x) & (EMFushort)0xff00U) >> 8) ))
108 #  define ftohl(x) ((EMFulong)( \
109 		(((EMFulong)ntohl(x) & (EMFulong)0x000000ffUL) << 24) | \
110 		(((EMFulong)ntohl(x) & (EMFulong)0x0000ff00UL) <<  8) | \
111 		(((EMFulong)ntohl(x) & (EMFulong)0x00ff0000UL) >>  8) | \
112 		(((EMFulong)ntohl(x) & (EMFulong)0xff000000UL) >> 24) ))
113 
114 # endif
115 #endif
116 
117 /* for efficiency (evaluate src only once) */
118 #define HTOFS(dst, src) \
119 	do { EMFushort htofstmp = (src); dst = htofs(htofstmp); } while (0)
120 #define HTOFL(dst, src) \
121 	do { EMFulong htofltmp = (src); dst = htofl(htofltmp); } while (0)
122 
123 
124 #define LATEX_FONT_BASE	2	/* Index of first LaTeX-like text font */
125 #define NUM_LATEX_FONTS	5	/* Number of LaTeX like text fonts */
126 #define PS_FONT_BASE	7	/* Index of first PostScript text font */
127 #define NUM_PS_FONTS	35	/* Number of PostScript fonts */
128 
129 #define PIXEL_01MM	(2.11666666667)	/* Converts from pixels to 0.01 mm */
130 #define PIXEL_01MM_BITPATTERN	(0x40077777)	/* as bit pattern */
131 
132 #define RAD_01DEG (572.95780)		/* Converts from radians to 0.1 deg */
133 
134 #define OUT_DEFAULT_PRECIS	0
135 #define OUT_STRING_PRECIS	1
136 #define OUT_CHARACTER_PRECIS	2
137 #define OUT_STROKE_PRECIS	3
138 #define OUT_TT_PRECIS		4
139 #define OUT_DEVICE_PRECIS	5
140 #define OUT_RASTER_PRECIS	6
141 #define OUT_TT_ONLY_PRECIS	7
142 #define OUT_OUTLINE_PRECIS	8
143 
144 #define CLIP_DEFAULT_PRECIS	0
145 #define CLIP_CHARACTER_PRECIS	1
146 #define CLIP_STROKE_PRECIS	2
147 #define CLIP_MASK		0xf
148 #define CLIP_LH_ANGLES		(1<<4)
149 #define CLIP_TT_ALWAYS		(2<<4)
150 #define CLIP_EMBEDDED		(8<<4)
151 
152 #define DEFAULT_QUALITY		0
153 #define DRAFT_QUALITY		1
154 #define PROOF_QUALITY		2
155 
156 #define DEFAULT_PITCH		0
157 #define FIXED_PITCH		1
158 #define VARIABLE_PITCH		2
159 
160 #define ANSI_CHARSET		0
161 #define DEFAULT_CHARSET		1
162 #define SYMBOL_CHARSET		2
163 #define SHIFTJIS_CHARSET	128
164 #define HANGUL_CHARSET		129
165 #define GB2312_CHARSET		134
166 #define CHINESEBIG5_CHARSET	136
167 #define OEM_CHARSET		255
168 
169 /* Font Families */
170 #define FF_DONTCARE	(0<<4)	/* Don't care or don't know. */
171 #define FF_ROMAN	(1<<4)	/* Variable stroke width, serifed. */
172 				/* Times Roman, Century Schoolbook, etc. */
173 #define FF_SWISS	(2<<4)	/* Variable stroke width, sans-serifed. */
174 				/* Helvetica, Swiss, etc. */
175 #define FF_MODERN	(3<<4)	/* Constant stroke width, serifed or */
176 				/* sans-serifed. Pica, Elite, Courier, etc. */
177 #define FF_SCRIPT	(4<<4)	/* Cursive, etc. */
178 #define FF_DECORATIVE	(5<<4)	/* Old English, etc. */
179 
180 /* Font Weights */
181 #define FW_DONTCARE		0
182 #define FW_THIN			100
183 #define FW_EXTRALIGHT		200
184 #define FW_LIGHT		300
185 #define FW_NORMAL		400
186 #define FW_MEDIUM		500
187 #define FW_SEMIBOLD		600
188 #define FW_BOLD			700
189 #define FW_EXTRABOLD		800
190 #define FW_HEAVY		900
191 
192 #define FW_ULTRALIGHT		FW_EXTRALIGHT
193 #define FW_REGULAR		FW_NORMAL
194 #define FW_DEMIBOLD		FW_SEMIBOLD
195 #define FW_ULTRABOLD		FW_EXTRABOLD
196 #define FW_BLACK		FW_HEAVY
197 
198 #define PANOSE_COUNT		       10
199 #define PAN_FAMILYTYPE_INDEX		0
200 #define PAN_SERIFSTYLE_INDEX		1
201 #define PAN_WEIGHT_INDEX		2
202 #define PAN_PROPORTION_INDEX		3
203 #define PAN_CONTRAST_INDEX		4
204 #define PAN_STROKEVARIATION_INDEX	5
205 #define PAN_ARMSTYLE_INDEX		6
206 #define PAN_LETTERFORM_INDEX		7
207 #define PAN_MIDLINE_INDEX		8
208 #define PAN_XHEIGHT_INDEX		9
209 
210 #define PAN_CULTURE_LATIN		0
211 
212 /*~~~~~|><|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
213 
214 /* Binary raster ops */
215 #define R2_BLACK	1	/*  0	    */
216 #define R2_NOTMERGEPEN	2	/* DPon     */
217 #define R2_MASKNOTPEN	3	/* DPna     */
218 #define R2_NOTCOPYPEN	4	/* PN	    */
219 #define R2_MASKPENNOT	5	/* PDna     */
220 #define R2_NOT		6	/* Dn	    */
221 #define R2_XORPEN	7	/* DPx	    */
222 #define R2_NOTMASKPEN	8	/* DPan     */
223 #define R2_MASKPEN	9	/* DPa	    */
224 #define R2_NOTXORPEN	10	/* DPxn     */
225 #define R2_NOP		11	/* D	    */
226 #define R2_MERGENOTPEN	12	/* DPno     */
227 #define R2_COPYPEN	13	/* P	    */
228 #define R2_MERGEPENNOT	14	/* PDno     */
229 #define R2_MERGEPEN	15	/* DPo	    */
230 #define R2_WHITE	16	/*  1	    */
231 #define R2_LAST		16
232 
233 
234 /* palette entry flags */
235 
236 #define RGB(r,g,b)		( (EMFulong)( (uchar)(r) | \
237 				  (((uchar)(g))<<8) | \
238 				  (((uchar)(b))<<16) ) )
239 #define PALETTERGB(r,g,b)	(0x02000000 | RGB(r,g,b))
240 #define PALETTEINDEX(i)		((EMFulong)(0x01000000 | (EMFushort)(i)))
241 
242 #define PC_RESERVED	0x01	/* Palette index used for animation */
243 #define PC_EXPLICIT	0x02	/* Palette index is explicit to device */
244 #define PC_NOCOLLAPSE	0x04	/* Do not match color to system palette */
245 
246 #define GetRValue(rgb)	((uchar)(rgb))
247 #define GetGValue(rgb)	((uchar)((rgb) >> 8))
248 #define GetBValue(rgb)	((uchar)((rgb) >> 16))
249 
250 /* Background Modes */
251 #define TRANSPARENT	1
252 #define OPAQUE		2
253 #define BKMODE_LAST	2
254 
255 /* Graphics Modes */
256 
257 #define GM_COMPATIBLE	1
258 #define GM_ADVANCED	2
259 #define GM_LAST		2
260 
261 /* PolyDraw and GetPath point types */
262 #define PT_CLOSEFIGURE		0x01
263 #define PT_LINETO		0x02
264 #define PT_BEZIERTO		0x04
265 #define PT_MOVETO		0x06
266 
267 /* Mapping Modes */
268 #define MM_TEXT			1
269 #define MM_LOMETRIC		2
270 #define MM_HIMETRIC		3
271 #define MM_LOENGLISH		4
272 #define MM_HIENGLISH		5
273 #define MM_TWIPS		6
274 #define MM_ISOTROPIC		7
275 #define MM_ANISOTROPIC		8
276 
277 /* Min and Max Mapping Mode values */
278 #define MM_MIN			MM_TEXT
279 #define MM_MAX			MM_ANISOTROPIC
280 #define MM_MAX_FIXEDSCALE	MM_TWIPS
281 
282 /* Coordinate Modes */
283 #define ABSOLUTE		1
284 #define RELATIVE		2
285 
286 /* Stock Logical Objects */
287 #define WHITE_BRUSH		0
288 #define LTGRAY_BRUSH		1
289 #define GRAY_BRUSH		2
290 #define DKGRAY_BRUSH		3
291 #define BLACK_BRUSH		4
292 #define NULL_BRUSH		5
293 #define HOLLOW_BRUSH		NULL_BRUSH
294 #define WHITE_PEN		6
295 #define BLACK_PEN		7
296 #define NULL_PEN		8
297 #define OEM_FIXED_FONT		10
298 #define ANSI_FIXED_FONT		11
299 #define ANSI_VAR_FONT		12
300 #define SYSTEM_FONT		13
301 #define DEVICE_DEFAULT_FONT	14
302 #define DEFAULT_PALETTE		15
303 #define SYSTEM_FIXED_FONT	16
304 #define DEFAULT_GUI_FONT	17
305 
306 #define STOCK_LAST		19
307 
308 #define CLR_INVALID	0xFFFFFFFF
309 
310 /* Brush Styles */
311 #define BS_SOLID		0
312 #define BS_NULL			1
313 #define BS_HOLLOW		BS_NULL
314 #define BS_HATCHED		2
315 #define BS_PATTERN		3
316 #define BS_INDEXED		4
317 #define BS_DIBPATTERN		5
318 #define BS_DIBPATTERNPT		6
319 #define BS_PATTERN8X8		7
320 #define BS_DIBPATTERN8X8	8
321 
322 /* Hatch Styles */
323 #define HS_HORIZONTAL		0	/* ----- */
324 #define HS_VERTICAL		1	/* ||||| */
325 #define HS_FDIAGONAL		2	/* \\\\\ */
326 #define HS_BDIAGONAL		3	/* ///// */
327 #define HS_CROSS		4	/* +++++ */
328 #define HS_DIAGCROSS		5	/* xxxxx */
329 
330 /* Pen Styles */
331 #define PS_SOLID		0
332 #define PS_DASH			1	/* -------  */
333 #define PS_DOT			2	/* .......  */
334 #define PS_DASHDOT		3	/* _._._._  */
335 #define PS_DASHDOTDOT		4	/* _.._.._  */
336 #define PS_NULL			5
337 #define PS_INSIDEFRAME		6
338 #define PS_USERSTYLE		7
339 #define PS_ALTERNATE		8
340 #define PS_STYLE_MASK		0x0000000F
341 
342 #define PS_ENDCAP_ROUND		0x00000000
343 #define PS_ENDCAP_SQUARE	0x00000100
344 #define PS_ENDCAP_FLAT		0x00000200
345 #define PS_ENDCAP_MASK		0x00000F00
346 
347 #define PS_JOIN_ROUND		0x00000000
348 #define PS_JOIN_BEVEL		0x00001000
349 #define PS_JOIN_MITER		0x00002000
350 #define PS_JOIN_MASK		0x0000F000
351 
352 #define PS_COSMETIC		0x00000000
353 #define PS_GEOMETRIC		0x00010000
354 #define PS_TYPE_MASK		0x000F0000
355 
356 #define AD_COUNTERCLOCKWISE	1
357 #define AD_CLOCKWISE		2
358 
359 /*~~~~~|><|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
360 
361 typedef struct tagSIZEL {
362     EMFlong	cx;
363     EMFlong	cy;
364 } SIZEL;
365 
366 typedef struct tagPOINTS {
367     EMFshort	x;
368     EMFshort	y;
369 } POINTS;
370 
371 typedef struct tagPOINTL {
372     EMFlong	x;
373     EMFlong	y;
374 } POINTL;
375 
376 typedef struct tagRECTL {
377     EMFlong	left;
378     EMFlong	top;
379     EMFlong	right;
380     EMFlong	bottom;
381 } RECTL;
382 
383 typedef struct tagXFORM {
384     EMFfloat	eM11;
385     EMFfloat	eM12;
386     EMFfloat	eM21;
387     EMFfloat	eM22;
388     EMFfloat	eDx;
389     EMFfloat	eDy;
390 } XFORM;
391 
392 /*~~~~~|><|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
393 
394 /* Enhanced Metafile structures */
395 typedef struct tagENHMETARECORD {
396     EMFulong	iType;		/* Record type EMR_XXX */
397     EMFulong	nSize;		/* Record size in bytes */
398     EMFulong	dParm[1];	/* Parameters */
399 } ENHMETARECORD;
400 
401 typedef struct tagENHMETAHEADER {
402     EMFulong	iType;		/* Record type EMR_HEADER */
403     EMFulong	nSize;		/* Record size in bytes.  This may be greater */
404 				/*  than the sizeof(ENHMETAHEADER). */
405     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
406     RECTL	rclFrame;	/* Inclusive-inclusive Picture Frame of */
407 				/*  metafile in .01 mm units */
408     EMFulong	dSignature;	/* Signature.  Must be ENHMETA_SIGNATURE. */
409     EMFulong	nVersion;	/* Version number */
410     EMFulong	nBytes;		/* Size of the metafile in bytes */
411     EMFulong	nRecords;	/* Number of records in the metafile */
412     EMFushort	nHandles;	/* Number of handles in the handle table */
413 				/* Handle index zero is reserved. */
414     EMFushort	sReserved;	/* Reserved.  Must be zero. */
415     EMFulong	nDescription;	/* Number of chars in the unicode */
416 				/*  description string */
417 			/* This is 0 if there is no description string */
418     EMFulong	offDescription;	/* Offset to the metafile description record. */
419 			/* This is 0 if there is no description string */
420     EMFulong	nPalEntries;	/* Number of entries in the metafile palette. */
421     SIZEL	szlDevice;	/* Size of the reference device in pels */
422     SIZEL	szlMillimeters;	/* Size of the reference device in millimeters */
423 } ENHMETAHEADER;
424 
425 /*~~~~~|><|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
426 /*
427  * The next structures the logical color space. Unlike pens and brushes,
428  * but like palettes, there is only one way to create a LogColorSpace.
429  * A pointer to it must be passed, its elements can't be pushed as
430  * arguments.
431  */
432 #define MAX_PATH	260
433 
434 typedef EMFlong LCSCSTYPE;
435 typedef EMFlong LCSGAMUTMATCH;
436 typedef EMFlong FXPT2DOT30;
437 
438 typedef struct tagCIEXYZ {
439     FXPT2DOT30	ciexyzX;
440     FXPT2DOT30	ciexyzY;
441     FXPT2DOT30	ciexyzZ;
442 } CIEXYZ;
443 
444 typedef struct tagCIEXYZTRIPLE {
445     CIEXYZ	ciexyzRed;
446     CIEXYZ	ciexyzGreen;
447     CIEXYZ	ciexyzBlue;
448 } CIEXYZTRIPLE;
449 
450 typedef struct tagLOGCOLORSPACEA {
451     EMFulong	lcsSignature;
452     EMFulong	lcsVersion;
453     EMFulong	lcsSize;
454     LCSCSTYPE	lcsCSType;
455     LCSGAMUTMATCH lcsIntent;
456     CIEXYZTRIPLE lcsEndpoints;
457     EMFulong	lcsGammaRed;
458     EMFulong	lcsGammaGreen;
459     EMFulong	lcsGammaBlue;
460     char	lcsFilename[MAX_PATH];
461 } LOGCOLORSPACEA, *LPLOGCOLORSPACEA;
462 
463 typedef struct tagLOGCOLORSPACEW {
464     EMFulong	lcsSignature;
465     EMFulong	lcsVersion;
466     EMFulong	lcsSize;
467     LCSCSTYPE	lcsCSType;
468     LCSGAMUTMATCH lcsIntent;
469     CIEXYZTRIPLE lcsEndpoints;
470     EMFulong	lcsGammaRed;
471     EMFulong	lcsGammaGreen;
472     EMFulong	lcsGammaBlue;
473     TCHAR	lcsFilename[MAX_PATH];
474 } LOGCOLORSPACEW;
475 
476 /* Logical Font */
477 #define LF_FACESIZE		32
478 #define LF_FULLFACESIZE		64
479 #define ELF_VENDOR_SIZE		4
480 
481 typedef struct tagLOGFONTW
482 {
483     EMFlong	lfHeight;
484     EMFlong	lfWidth;
485     EMFlong	lfEscapement;
486     EMFlong	lfOrientation;
487     EMFlong	lfWeight;
488     uchar	lfItalic;
489     uchar	lfUnderline;
490     uchar	lfStrikeOut;
491     uchar	lfCharSet;
492     uchar	lfOutPrecision;
493     uchar	lfClipPrecision;
494     uchar	lfQuality;
495     uchar	lfPitchAndFamily;
496     TCHAR	lfFaceName[LF_FACESIZE];
497 } LOGFONTW;
498 
499 typedef struct tagPANOSE
500 {
501     uchar	bFamilyType;
502     uchar	bSerifStyle;
503     uchar	bWeight;
504     uchar	bProportion;
505     uchar	bContrast;
506     uchar	bStrokeVariation;
507     uchar	bArmStyle;
508     uchar	bLetterform;
509     uchar	bMidline;
510     uchar	bXHeight;
511     uchar	pad[2];		/* Padding to ensure data alignment */
512 } PANOSE;
513 
514 typedef struct tagEXTLOGFONTW {
515     LOGFONTW	elfLogFont;
516     TCHAR	elfFullName[LF_FULLFACESIZE];
517     TCHAR	elfStyle[LF_FACESIZE];
518     EMFulong	elfVersion;	/* 0 for the first release */
519     EMFulong	elfStyleSize;
520     EMFulong	elfMatch;
521     EMFulong	elfReserved;
522     uchar	elfVendorId[ELF_VENDOR_SIZE];
523     EMFulong	elfCulture;	/* 0 for Latin		   */
524     PANOSE	elfPanose;
525 } EXTLOGFONTW;
526 
527 typedef struct tagEXTLOGPEN {
528     EMFulong	elpPenStyle;
529     EMFulong	elpWidth;
530     EMFulong	elpBrushStyle;
531     EMFulong	elpColor;
532     EMFlong	elpHatch;
533     EMFulong	elpNumEntries;
534 /*  EMFulong	elpStyleEntry[1]; */
535 } EXTLOGPEN;
536 
537 /* Logical Brush (or Pattern) */
538 typedef struct tagLOGBRUSH
539 {
540     EMFulong	lbStyle;
541     EMFulong	lbColor;
542     EMFlong	lbHatch;
543 } LOGBRUSH;
544 
545 typedef struct tagPALETTEENTRY {
546     uchar	peRed;
547     uchar	peGreen;
548     uchar	peBlue;
549     uchar	peFlags;
550 } PALETTEENTRY;
551 
552 /* Logical Palette */
553 typedef struct tagLOGPALETTE {
554     EMFushort		palVersion;
555     EMFushort		palNumEntries;
556     PALETTEENTRY	palPalEntry[1];
557 } LOGPALETTE;
558 
559 /* Logical Pen */
560 typedef struct tagLOGPEN
561 {
562   EMFulong	lopnStyle;
563   POINTL	lopnWidth;
564   EMFulong	lopnColor;
565 } LOGPEN;
566 
567 /* DIB color information */
568 #define BI_RGB		0	/* uncompressed */
569 #define BI_RLE8		1	/* 8 bpp run-length encoding */
570 #define BI_RLE4		2	/* 4 bpp run-length encoding */
571 #define BI_BITFIELDS	3	/* uncompressed, color mask */
572 
573 typedef struct tagBITMAPINFOHEADER {
574     EMFulong	biSize;
575     EMFlong	biWidth;
576     EMFlong	biHeight;
577     EMFushort	biPlanes;
578     EMFushort	biBitCount;
579     EMFulong	biCompression;
580     EMFulong	biSizeImage;
581     EMFlong	biXPelsPerMeter;
582     EMFlong	biYPelsPerMeter;
583     EMFulong	biClrUsed;
584     EMFulong	biClrImportant;
585 } BITMAPINFOHEADER;
586 
587 typedef struct tagRGBQUAD {
588     uchar	rgbBlue;
589     uchar	rgbGreen;
590     uchar	rgbRed;
591     uchar	rgbReserved;
592 } RGBQUAD;
593 
594 typedef struct tagBITMAPINFO {
595     BITMAPINFOHEADER	bmiHeader;
596 /*  RGBQUAD		bmiColors[1];*/
597 } BITMAPINFO;
598 
599 /*~~~~~|><|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
600 /*
601  * Enhanced metafile constants.
602  */
603 #define ENHMETA_SIGNATURE	0x464D4520
604 #define ENHMETA_VERSION		0x10000
605 /*
606  * Stock object flag used in the object handle index in the enhanced
607  * metafile records.
608  * E.g. The object handle index (ENHMETA_STOCK_OBJECT | BLACK_BRUSH)
609  * represents the stock object BLACK_BRUSH.
610  */
611 #define ENHMETA_STOCK_OBJECT	0x80000000
612 /*
613  * Enhanced metafile record types.
614  */
615 #define EMR_ABORTPATH			68
616 #define EMR_ANGLEARC			41
617 #define EMR_ARC				45
618 #define EMR_ARCTO			55
619 #define EMR_BEGINPATH			59
620 #define EMR_BITBLT			76
621 #define EMR_CHORD			46
622 #define EMR_CLOSEFIGURE			61
623 #define EMR_CREATEBRUSHINDIRECT		39
624 #define EMR_CREATECOLORSPACE		99
625 #define EMR_CREATEDIBPATTERNBRUSHPT	94
626 #define EMR_CREATEMONOBRUSH		93
627 #define EMR_CREATEPALETTE		49
628 #define EMR_CREATEPEN			38
629 #define EMR_DELETECOLORSPACE	       101
630 #define EMR_DELETEOBJECT		40
631 #define EMR_ELLIPSE			42
632 #define EMR_ENDPATH			60
633 #define EMR_EOF				14
634 #define EMR_EXCLUDECLIPRECT		29
635 #define EMR_EXTCREATEFONTINDIRECTW	82
636 #define EMR_EXTCREATEPEN		95
637 #define EMR_EXTFLOODFILL		53
638 #define EMR_EXTSELECTCLIPRGN		75
639 #define EMR_EXTTEXTOUTA			83
640 #define EMR_EXTTEXTOUTW			84
641 #define EMR_FILLPATH			62
642 #define EMR_FILLRGN			71
643 #define EMR_FLATTENPATH			65
644 #define EMR_FRAMERGN			72
645 #define EMR_GDICOMMENT			70
646 #define EMR_HEADER			 1
647 #define EMR_INTERSECTCLIPRECT		30
648 #define EMR_INVERTRGN			73
649 #define EMR_LINETO			54
650 #define EMR_MASKBLT			78
651 #define EMR_MODIFYWORLDTRANSFORM	36
652 #define EMR_MOVETOEX			27
653 #define EMR_OFFSETCLIPRGN		26
654 #define EMR_PAINTRGN			74
655 #define EMR_PIE				47
656 #define EMR_PLGBLT			79
657 #define EMR_POLYBEZIER			 2
658 #define EMR_POLYBEZIER16		85
659 #define EMR_POLYBEZIERTO		 5
660 #define EMR_POLYBEZIERTO16		88
661 #define EMR_POLYDRAW			56
662 #define EMR_POLYDRAW16			92
663 #define EMR_POLYGON			 3
664 #define EMR_POLYGON16			86
665 #define EMR_POLYLINE			 4
666 #define EMR_POLYLINE16			87
667 #define EMR_POLYLINETO			 6
668 #define EMR_POLYLINETO16		89
669 #define EMR_POLYPOLYGON			 8
670 #define EMR_POLYPOLYGON16		91
671 #define EMR_POLYPOLYLINE		 7
672 #define EMR_POLYPOLYLINE16		90
673 #define EMR_POLYTEXTOUTA		96
674 #define EMR_POLYTEXTOUTW		97
675 #define EMR_REALIZEPALETTE		52
676 #define EMR_RECTANGLE			43
677 #define EMR_RESIZEPALETTE		51
678 #define EMR_RESTOREDC			34
679 #define EMR_ROUNDRECT			44
680 #define EMR_SAVEDC			33
681 #define EMR_SCALEVIEWPORTEXTEX		31
682 #define EMR_SCALEWINDOWEXTEX		32
683 #define EMR_SELECTCLIPPATH		67
684 #define EMR_SELECTOBJECT		37
685 #define EMR_SELECTPALETTE		48
686 #define EMR_SETARCDIRECTION		57
687 #define EMR_SETBKCOLOR			25
688 #define EMR_SETBKMODE			18
689 #define EMR_SETBRUSHORGEX		13
690 #define EMR_SETCOLORADJUSTMENT		23
691 #define EMR_SETCOLORSPACE	       100
692 #define EMR_SETDIBITSTODEVICE		80
693 #define EMR_SETICMMODE			98
694 #define EMR_SETMAPMODE			17
695 #define EMR_SETMAPPERFLAGS		16
696 #define EMR_SETMETARGN			28
697 #define EMR_SETMITERLIMIT		58
698 #define EMR_SETPALETTEENTRIES		50
699 #define EMR_SETPIXELV			15
700 #define EMR_SETPOLYFILLMODE		19
701 #define EMR_SETROP2			20
702 #define EMR_SETSTRETCHBLTMODE		21
703 #define EMR_SETTEXTALIGN		22
704 #define EMR_SETTEXTCOLOR		24
705 #define EMR_SETVIEWPORTEXTEX		11
706 #define EMR_SETVIEWPORTORGEX		12
707 #define EMR_SETWINDOWEXTEX		 9
708 #define EMR_SETWINDOWORGEX		10
709 #define EMR_SETWORLDTRANSFORM		35
710 #define EMR_STRETCHBLT			77
711 #define EMR_STRETCHDIBITS		81
712 #define EMR_STROKEANDFILLPATH		63
713 #define EMR_STROKEPATH			64
714 #define EMR_WIDENPATH			66
715 
716 #define EMR_MIN				 1
717 #define EMR_MAX			       101
718 
719 
720 /* Text Alignment Options */
721 #define TA_NOUPDATECP		0
722 #define TA_UPDATECP		1
723 
724 #define TA_LEFT			0
725 #define TA_RIGHT		2
726 #define TA_CENTER		6
727 
728 #define TA_TOP			0
729 #define TA_BOTTOM		8
730 #define TA_BASELINE		24
731 #define TA_RTLREADING		256
732 #define TA_MASK		(TA_BASELINE+TA_CENTER+TA_UPDATECP+TA_RTLREADING)
733 
734 #define VTA_BASELINE	TA_BASELINE
735 #define VTA_LEFT	TA_BOTTOM
736 #define VTA_RIGHT	TA_TOP
737 #define VTA_CENTER	TA_CENTER
738 #define VTA_BOTTOM	TA_RIGHT
739 #define VTA_TOP		TA_LEFT
740 
741 #define ETO_OPAQUE		0x0002
742 #define ETO_CLIPPED		0x0004
743 #define ETO_GLYPH_INDEX		0x0010
744 #define ETO_RTLREADING		0x0080
745 
746 #define ASPECT_FILTERING	0x0001
747 
748 /* DIB color id */
749 #define DIB_RGB_COLORS	0
750 #define DIB_PAL_COLORS	1
751 
752 /* raster operation codes (most common ones) */
753 #define SRCCOPY		0x00CC0020	/* Destination = Source */
754 #define SRCPAINT	0x00EE0086	/* Destination |= Source */
755 #define SRCAND		0x008800C6	/* Destination &= Source */
756 #define SRCINVERT	0x00660046	/* Destination ^= Source */
757 
758 /* Base record type for the enhanced metafile. */
759 
760 typedef struct tagEMR
761 {
762     EMFulong	iType;		/* Enhanced metafile record type */
763     EMFulong	nSize;		/* Length of the record in bytes */
764 				/* This must be a multiple of 4 */
765 } EMR;
766 
767 /* Base text record type for the enhanced metafile. */
768 
769 typedef struct tagEMRTEXT
770 {
771     POINTL	ptlReference;
772     EMFulong	nChars;
773     EMFulong	offString;	/* Offset to the string */
774     EMFulong	fOptions;	/* Options like ETO_OPAQUE and ETO_CLIPPED */
775     RECTL	rcl;
776     EMFulong	offDx;		/* Offset to the inter-character spacing array*/
777 				/* This is always given */
778 } EMRTEXT;
779 
780 /* Record structures for the enhanced metafile. */
781 
782 typedef struct tagABORTPATH
783 {
784     EMR		emr;
785 } EMRABORTPATH, EMRBEGINPATH, EMRENDPATH, EMRCLOSEFIGURE, EMRFLATTENPATH,
786   EMRWIDENPATH, EMRSETMETARGN, EMRSAVEDC, EMRREALIZEPALETTE;
787 
788 typedef struct tagEMRSELECTCLIPPATH
789 {
790     EMR		emr;
791     EMFulong	iMode;
792 } EMRSELECTCLIPPATH, EMRSETBKMODE, EMRSETMAPMODE, EMRSETPOLYFILLMODE,
793   EMRSETROP2, EMRSETSTRETCHBLTMODE, EMRSETICMMODE, EMRSETTEXTALIGN;
794 
795 typedef struct tagEMRSETMITERLIMIT
796 {
797     EMR		emr;
798     EMFfloat	eMiterLimit;
799 } EMRSETMITERLIMIT;
800 
801 typedef struct tagEMRRESTOREDC
802 {
803     EMR		emr;
804     EMFlong	iRelative;	/* Specifies a relative instance */
805 } EMRRESTOREDC;
806 
807 typedef struct tagEMRSETARCDIRECTION
808 {
809     EMR		emr;
810     EMFulong	iArcDirection;	/* Specifies the arc direction in the */
811 				/* advanced graphics mode. */
812 } EMRSETARCDIRECTION;
813 
814 typedef struct tagEMRSETMAPPERFLAGS
815 {
816     EMR		emr;
817     EMFulong	dwFlags;
818 } EMRSETMAPPERFLAGS;
819 
820 typedef struct tagEMRSETTEXTCOLOR
821 {
822     EMR		emr;
823     EMFulong	crColor;
824 } EMRSETBKCOLOR, EMRSETTEXTCOLOR;
825 
826 typedef struct tagEMRSELECTOBJECT
827 {
828     EMR		emr;
829     EMFulong	ihObject;	/* Object handle index */
830 } EMRSELECTOBJECT, EMRDELETEOBJECT;
831 
832 typedef struct tagEMRSELECTCOLORSPACE
833 {
834     EMR		emr;
835     EMFulong	ihCS;		/* ColorSpace handle index */
836 } EMRSELECTCOLORSPACE, EMRDELETECOLORSPACE;
837 
838 typedef struct tagEMRSELECTPALETTE
839 {
840     EMR		emr;
841     EMFulong	ihPal;		/* Palette handle index, background mode only */
842 } EMRSELECTPALETTE;
843 
844 typedef struct tagEMRRESIZEPALETTE
845 {
846     EMR		emr;
847     EMFulong	ihPal;		/* Palette handle index */
848     EMFulong	cEntries;
849 } EMRRESIZEPALETTE;
850 
851 typedef struct tagEMRSETPALETTEENTRIES
852 {
853     EMR		emr;
854     EMFulong	ihPal;		/* Palette handle index */
855     EMFulong	iStart;
856     EMFulong	cEntries;
857     PALETTEENTRY aPalEntries[1];/* The peFlags fields do not contain any flags */
858 } EMRSETPALETTEENTRIES;
859 
860 typedef struct tagEMRSETCOLORADJUSTMENT
861 {
862     EMR			emr;
863 /*  COLORADJUSTMENT	ColorAdjustment; */
864 } EMRSETCOLORADJUSTMENT;
865 
866 
867 typedef struct tagEMRGDICOMMENT
868 {
869     EMR		emr;
870     EMFulong	cbData;		/* Size of data in bytes */
871 } EMRGDICOMMENT;
872 
873 typedef struct tagEMREOF
874 {
875     EMR		emr;
876     EMFulong	nPalEntries;	/* Number of palette entries */
877     EMFulong	offPalEntries;	/* Offset to the palette entries */
878     EMFulong	nSizeLast;	/* Same as nSize and must be the last ulong */
879 				/* of the record.  The palette entries, */
880 				/* if exist, precede this field. */
881 } EMREOF;
882 
883 typedef struct tagEMRLINETO
884 {
885     EMR		emr;
886     POINTL	ptl;
887 } EMRLINETO, EMRMOVETOEX;
888 
889 typedef struct tagEMROFFSETCLIPRGN
890 {
891     EMR		emr;
892     POINTL	ptlOffset;
893 } EMROFFSETCLIPRGN;
894 
895 typedef struct tagEMRFILLPATH
896 {
897     EMR		emr;
898     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
899 } EMRFILLPATH, EMRSTROKEANDFILLPATH, EMRSTROKEPATH;
900 
901 typedef struct tagEMREXCLUDECLIPRECT
902 {
903     EMR		emr;
904     RECTL	rclClip;
905 } EMREXCLUDECLIPRECT, EMRINTERSECTCLIPRECT;
906 
907 typedef struct tagEMRSETVIEWPORTORGEX
908 {
909     EMR		emr;
910     POINTL	ptlOrigin;
911 } EMRSETVIEWPORTORGEX, EMRSETWINDOWORGEX, EMRSETBRUSHORGEX;
912 
913 typedef struct tagEMRSETVIEWPORTEXTEX
914 {
915     EMR		emr;
916     SIZEL	szlExtent;
917 } EMRSETVIEWPORTEXTEX, EMRSETWINDOWEXTEX;
918 
919 typedef struct tagEMRSCALEVIEWPORTEXTEX
920 {
921     EMR		emr;
922     EMFlong	xNum;
923     EMFlong	xDenom;
924     EMFlong	yNum;
925     EMFlong	yDenom;
926 } EMRSCALEVIEWPORTEXTEX, EMRSCALEWINDOWEXTEX;
927 
928 typedef struct tagEMRSETWORLDTRANSFORM
929 {
930     EMR		emr;
931     XFORM	xform;
932 } EMRSETWORLDTRANSFORM;
933 
934 typedef struct tagEMRMODIFYWORLDTRANSFORM
935 {
936     EMR		emr;
937     XFORM	xform;
938     EMFulong	iMode;
939 } EMRMODIFYWORLDTRANSFORM;
940 
941 typedef struct tagEMRSETPIXELV
942 {
943     EMR		emr;
944     POINTL	ptlPixel;
945     EMFulong	crColor;
946 } EMRSETPIXELV;
947 
948 typedef struct tagEMREXTFLOODFILL
949 {
950     EMR		emr;
951     POINTL	ptlStart;
952     EMFulong	crColor;
953     EMFulong	iMode;
954 } EMREXTFLOODFILL;
955 
956 typedef struct tagEMRELLIPSE
957 {
958     EMR		emr;
959     RECTL	rclBox;		/* Inclusive-inclusive bounding rectangle */
960 } EMRELLIPSE, EMRRECTANGLE;
961 
962 typedef struct tagEMRROUNDRECT
963 {
964     EMR		emr;
965     RECTL	rclBox;		/* Inclusive-inclusive bounding rectangle */
966     SIZEL	szlCorner;
967 } EMRROUNDRECT;
968 
969 typedef struct tagEMRARC
970 {
971     EMR		emr;
972     RECTL	rclBox;		/* Inclusive-inclusive bounding rectangle */
973     POINTL	ptlStart;
974     POINTL	ptlEnd;
975 } EMRARC, EMRARCTO, EMRCHORD, EMRPIE;
976 
977 typedef struct tagEMRANGLEARC
978 {
979     EMR		emr;
980     POINTL	ptlCenter;
981     EMFulong	nRadius;
982     EMFfloat	eStartAngle;
983     EMFfloat	eSweepAngle;
984 } EMRANGLEARC;
985 
986 typedef struct tagEMRPOLYLINE
987 {
988     EMR		emr;
989     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
990     EMFulong	cptl;		/* Number of points in the array */
991 /*  POINTL	aptl[cptl];	(* Array of 32-bit points */
992 } EMRPOLYLINE, EMRPOLYBEZIER, EMRPOLYGON, EMRPOLYBEZIERTO, EMRPOLYLINETO;
993 
994 typedef struct tagEMRPOLYLINE16
995 {
996     EMR		emr;
997     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
998     EMFulong	cpts;		/* Number of points in the array */
999 /*  POINTS	apts[cpts];	(* Array of 16-bit points */
1000 } EMRPOLYLINE16, EMRPOLYBEZIER16, EMRPOLYGON16, EMRPOLYBEZIERTO16,
1001   EMRPOLYLINETO16;
1002 
1003 typedef struct tagEMRPOLYDRAW
1004 {
1005     EMR		emr;
1006     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1007     EMFulong	cptl;		/* Number of points */
1008     POINTL	aptl[1];	/* Array of points */
1009     uchar	abTypes[1];	/* Array of point types */
1010 } EMRPOLYDRAW;
1011 
1012 typedef struct tagEMRPOLYDRAW16
1013 {
1014     EMR		emr;
1015     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1016     EMFulong	cpts;		/* Number of points */
1017     POINTS	apts[1];	/* Array of points */
1018     uchar	abTypes[1];	/* Array of point types */
1019 } EMRPOLYDRAW16;
1020 
1021 typedef struct tagEMRPOLYPOLYLINE
1022 {
1023     EMR		emr;
1024     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1025     EMFulong	nPolys;		/* Number of polys */
1026     EMFulong	cptl;		/* Total number of points in all polys */
1027     EMFulong	aPolyCounts[1];	/* Array of point counts for each poly */
1028     POINTL	aptl[1];	/* Array of points */
1029 } EMRPOLYPOLYLINE, EMRPOLYPOLYGON;
1030 
1031 typedef struct tagEMRPOLYPOLYLINE16
1032 {
1033     EMR		emr;
1034     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1035     EMFulong	nPolys;		/* Number of polys */
1036     EMFulong	cpts;		/* Total number of points in all polys */
1037     EMFulong	aPolyCounts[1];	/* Array of point counts for each poly */
1038     POINTS	apts[1];	/* Array of points */
1039 } EMRPOLYPOLYLINE16, EMRPOLYPOLYGON16;
1040 
1041 typedef struct tagEMRINVERTRGN
1042 {
1043     EMR		emr;
1044     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1045     EMFulong	cbRgnData;	/* Size of region data in bytes */
1046     uchar	RgnData[1];
1047 } EMRINVERTRGN, EMRPAINTRGN;
1048 
1049 typedef struct tagEMRFILLRGN
1050 {
1051     EMR		emr;
1052     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1053     EMFulong	cbRgnData;	/* Size of region data in bytes */
1054     EMFulong	ihBrush;	/* Brush handle index */
1055     uchar	RgnData[1];
1056 } EMRFILLRGN;
1057 
1058 typedef struct tagEMRFRAMERGN
1059 {
1060     EMR		emr;
1061     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1062     EMFulong	cbRgnData;	/* Size of region data in bytes */
1063     EMFulong	ihBrush;	/* Brush handle index */
1064     SIZEL	szlStroke;
1065     uchar	RgnData[1];
1066 } EMRFRAMERGN;
1067 
1068 typedef struct tagEMREXTSELECTCLIPRGN
1069 {
1070     EMR		emr;
1071     EMFulong	cbRgnData;	/* Size of region data in bytes */
1072     EMFulong	iMode;
1073     uchar	RgnData[1];
1074 } EMREXTSELECTCLIPRGN;
1075 
1076 typedef struct tagEMREXTTEXTOUTA
1077 {
1078     EMR		emr;
1079     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1080     EMFulong	iGraphicsMode;	/* Current graphics mode */
1081     EMFfloat	exScale;	/* X and Y scales from Page units to .01mm */
1082     EMFfloat	eyScale;	/*  units if graphics mode is GM_COMPATIBLE. */
1083     EMRTEXT	emrtext;	/* This is followed by the string and */
1084 				/* spacing array */
1085 } EMREXTTEXTOUTA, EMREXTTEXTOUTW;
1086 
1087 typedef struct tagEMRPOLYTEXTOUTA
1088 {
1089     EMR		emr;
1090     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1091     EMFulong	iGraphicsMode;	/* Current graphics mode */
1092     EMFfloat	exScale;	/* X and Y scales from Page units to .01mm */
1093     EMFfloat	eyScale;	/*  units if graphics mode is GM_COMPATIBLE. */
1094     EMFlong	cStrings;
1095     EMRTEXT	aemrtext[1];	/* Array of EMRTEXT structures.  This is */
1096 				/* followed by the strings and spacing arrays.*/
1097 } EMRPOLYTEXTOUTA, EMRPOLYTEXTOUTW;
1098 
1099 typedef struct tagEMRBITBLT
1100 {
1101     EMR		emr;
1102     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1103     EMFlong	xDest;
1104     EMFlong	yDest;
1105     EMFlong	cxDest;
1106     EMFlong	cyDest;
1107     EMFulong	dwRop;
1108     EMFlong	 xSrc;
1109     EMFlong	 ySrc;
1110     XFORM	xformSrc;	/* Source DC transform */
1111     EMFulong	crBkColorSrc;	/* Source DC BkColor in RGB */
1112     EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
1113 				/* (DIB_RGB_COLORS) */
1114     EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
1115     EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
1116     EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
1117     EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
1118 } EMRBITBLT;
1119 
1120 typedef struct tagEMRSTRETCHBLT
1121 {
1122     EMR		emr;
1123     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1124     EMFlong	xDest;
1125     EMFlong	yDest;
1126     EMFlong	cxDest;
1127     EMFlong	cyDest;
1128     EMFulong	dwRop;
1129     EMFlong	xSrc;
1130     EMFlong	ySrc;
1131     XFORM	xformSrc;	/* Source DC transform */
1132     EMFulong	crBkColorSrc;	/* Source DC BkColor in RGB */
1133     EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
1134 				/* (DIB_RGB_COLORS) */
1135     EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
1136     EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
1137     EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
1138     EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
1139     EMFlong	cxSrc;
1140     EMFlong	cySrc;
1141 } EMRSTRETCHBLT;
1142 
1143 typedef struct tagEMRMASKBLT
1144 {
1145     EMR		emr;
1146     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1147     EMFlong	xDest;
1148     EMFlong	yDest;
1149     EMFlong	cxDest;
1150     EMFlong	cyDest;
1151     EMFulong	dwRop;
1152     EMFlong	xSrc;
1153     EMFlong	ySrc;
1154     XFORM	xformSrc;	/* Source DC transform */
1155     EMFulong	crBkColorSrc;	/* Source DC BkColor in RGB */
1156     EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
1157 				/* (DIB_RGB_COLORS) */
1158     EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
1159     EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
1160     EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
1161     EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
1162     EMFlong	xMask;
1163     EMFlong	yMask;
1164     EMFulong	iUsageMask;	/* Mask bitmap info color table usage */
1165     EMFulong	offBmiMask;	/* Offset to the mask BITMAPINFO structure if any */
1166     EMFulong	cbBmiMask;	/* Size of the mask BITMAPINFO structure if any */
1167     EMFulong	offBitsMask;	/* Offset to the mask bitmap bits if any */
1168     EMFulong	cbBitsMask;	/* Size of the mask bitmap bits if any */
1169 } EMRMASKBLT;
1170 
1171 typedef struct tagEMRPLGBLT
1172 {
1173     EMR		emr;
1174     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1175     POINTL	aptlDest[3];
1176     EMFlong	xSrc;
1177     EMFlong	ySrc;
1178     EMFlong	cxSrc;
1179     EMFlong	cySrc;
1180     XFORM	xformSrc;	/* Source DC transform */
1181     EMFulong	crBkColorSrc;	/* Source DC BkColor in RGB */
1182     EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
1183 				/* (DIB_RGB_COLORS) */
1184     EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
1185     EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
1186     EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
1187     EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
1188     EMFlong	xMask;
1189     EMFlong	yMask;
1190     EMFulong	iUsageMask;	/* Mask bitmap info color table usage */
1191     EMFulong	offBmiMask;	/* Offset to the mask BITMAPINFO structure if any */
1192     EMFulong	cbBmiMask;	/* Size of the mask BITMAPINFO structure if any */
1193     EMFulong	offBitsMask;	/* Offset to the mask bitmap bits if any */
1194     EMFulong	cbBitsMask;	/* Size of the mask bitmap bits if any */
1195 } EMRPLGBLT;
1196 
1197 typedef struct tagEMRSETDIBITSTODEVICE
1198 {
1199     EMR		emr;
1200     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1201     EMFlong	xDest;
1202     EMFlong	yDest;
1203     EMFlong	xSrc;
1204     EMFlong	ySrc;
1205     EMFlong	cxSrc;
1206     EMFlong	cySrc;
1207     EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
1208     EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
1209     EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
1210     EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
1211     EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
1212     EMFulong	iStartScan;
1213     EMFulong	cScans;
1214 } EMRSETDIBITSTODEVICE;
1215 
1216 typedef struct tagEMRSTRETCHDIBITS
1217 {
1218     EMR		emr;
1219     RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
1220     EMFlong	xDest;
1221     EMFlong	yDest;
1222     EMFlong	xSrc;
1223     EMFlong	ySrc;
1224     EMFlong	cxSrc;
1225     EMFlong	cySrc;
1226     EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
1227     EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
1228     EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
1229     EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
1230     EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
1231     EMFulong	dwRop;
1232     EMFlong	cxDest;
1233     EMFlong	cyDest;
1234 } EMRSTRETCHDIBITS;
1235 
1236 typedef struct tagEMREXTCREATEFONTINDIRECTW
1237 {
1238     EMR		emr;
1239     EMFulong	ihFont;		/* Font handle index */
1240     EXTLOGFONTW	elfw;
1241 } EMREXTCREATEFONTINDIRECTW;
1242 
1243 typedef struct tagEMRCREATEPALETTE
1244 {
1245     EMR		emr;
1246     EMFulong	ihPal;		/* Palette handle index */
1247     LOGPALETTE	lgpl;		/* The peFlags fields in the palette entries */
1248 				/* do not contain any flags */
1249 } EMRCREATEPALETTE;
1250 
1251 typedef struct tagEMRCREATECOLORSPACE
1252 {
1253     EMR			emr;
1254     EMFulong		ihCS;	/* ColorSpace handle index */
1255     LOGCOLORSPACEW	lcs;
1256 } EMRCREATECOLORSPACE;
1257 
1258 typedef struct tagEMRCREATEPEN
1259 {
1260     EMR		emr;
1261     EMFulong	ihPen;		/* Pen handle index */
1262     LOGPEN	lopn;
1263 } EMRCREATEPEN;
1264 
1265 typedef struct tagEMREXTCREATEPEN
1266 {
1267     EMR		emr;
1268     EMFulong	ihPen;		/* Pen handle index */
1269     EMFulong	offBmi;		/* Offset to the BITMAPINFO structure if any */
1270     EMFulong	cbBmi;		/* Size of the BITMAPINFO structure if any */
1271 				/* The bitmap info is followed by the bitmap */
1272 				/* bits to form a packed DIB. */
1273     EMFulong	offBits;	/* Offset to the brush bitmap bits if any */
1274     EMFulong	cbBits;		/* Size of the brush bitmap bits if any */
1275     EXTLOGPEN	elp;		/* The extended pen with the style array. */
1276 } EMREXTCREATEPEN;
1277 
1278 typedef struct tagEMRCREATEBRUSHINDIRECT
1279 {
1280     EMR		emr;
1281     EMFulong	ihBrush;	/* Brush handle index */
1282     LOGBRUSH	lb;		/* The style must be BS_SOLID, BS_HOLLOW, */
1283 				/* BS_NULL or BS_HATCHED. */
1284 } EMRCREATEBRUSHINDIRECT;
1285 
1286 typedef struct tagEMRCREATEMONOBRUSH
1287 {
1288     EMR		emr;
1289     EMFulong	ihBrush;	/* Brush handle index */
1290     EMFulong	iUsage;		/* Bitmap info color table usage */
1291     EMFulong	offBmi;		/* Offset to the BITMAPINFO structure */
1292     EMFulong	cbBmi;		/* Size of the BITMAPINFO structure */
1293     EMFulong	offBits;	/* Offset to the bitmap bits */
1294     EMFulong	cbBits;		/* Size of the bitmap bits */
1295 } EMRCREATEMONOBRUSH;
1296 
1297 typedef struct tagEMRCREATEDIBPATTERNBRUSHPT
1298 {
1299     EMR		emr;
1300     EMFulong	ihBrush;	/* Brush handle index */
1301     EMFulong	iUsage;		/* Bitmap info color table usage */
1302     EMFulong	offBmi;		/* Offset to the BITMAPINFO structure */
1303     EMFulong	cbBmi;		/* Size of the BITMAPINFO structure */
1304 				/* The bitmap info is followed by the bitmap */
1305 				/* bits to form a packed DIB. */
1306     EMFulong	offBits;	/* Offset to the bitmap bits */
1307     EMFulong	cbBits;		/* Size of the bitmap bits */
1308 } EMRCREATEDIBPATTERNBRUSHPT;
1309 
1310 typedef struct tagEMRFORMAT
1311 {
1312     EMFulong	dSignature;	/* Format signature, e.g. ENHMETA_SIGNATURE. */
1313     EMFulong	nVersion;	/* Format version number. */
1314     EMFulong	cbData;		/* Size of data in bytes. */
1315     EMFulong	offData;	/* Offset to data from GDICOMMENT_IDENTIFIER. */
1316 				/* It must begin at a ulong offset. */
1317 } EMRFORMAT;
1318 
1319 #endif /* GENEMF_H */
1320