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