File: genemf.h

package info (click to toggle)
transfig 1%3A3.2.5.e-4%2Bdeb8u1
  • links: PTS
  • area: main
  • in suites: jessie
  • size: 9,300 kB
  • sloc: ansic: 32,666; makefile: 3,255; sh: 549; csh: 25; perl: 13
file content (1316 lines) | stat: -rwxr-xr-x 37,243 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
/*
 * TransFig: Facility for Translating Fig code
 * Copyright (c) 1999 by Philippe Bekaert
 * Parts Copyright (c) 1989-2002 by Brian V. Smith
 *
 * Any party obtaining a copy of these files is granted, free of charge, a
 * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
 * nonexclusive right and license to deal in this software and
 * documentation files (the "Software"), including without limitation the
 * rights to use, copy, modify, merge, publish and/or distribute copies of
 * the Software, and to permit persons who receive copies from any such 
 * party to do so, with the only requirement being that this copyright 
 * notice remain intact.
 *
 */

/*
 * genemf.h -- convert fig to Enhanced MetaFile header file
 *
 * Written by Michael Schrick (2001-03-04)
 *
 */

#ifndef GENEMF_H
#define GENEMF_H

typedef unsigned char  uchar;
typedef unsigned short TCHAR;

/* 16bit value */
typedef short		EMFshort;
typedef unsigned short	EMFushort;

/* 32bit value (use int, not long, for LP64 platforms) */
typedef int		EMFlong;
typedef unsigned int	EMFulong;

/* 32bit floating value */
typedef union {
	EMFulong	bit_uint;	/* bit pattern */
	/* float	val_float; */	/* floating value (not portable) */
} EMFfloat;


/*
 * Macros for conversion between host and file byte order.
 */

#ifndef BYTE_ORDER
# define BIG_ENDIAN	4321
# define LITTLE_ENDIAN	1234

# if defined(__BIG_ENDIAN__) || defined(m68k) || defined(__m68k__) || defined(sparc) || defined(__sparc) || defined(__sparc__) || defined(hppa) || defined(__hppa) || defined(MIPSEB) || defined(__ARMEB__)
#  define BYTE_ORDER	BIG_ENDIAN

# else

#  if defined(__LITTLE_ENDIAN__) || defined(vax) || defined(__vax__) || defined(__alpha) || defined(__alpha__) || defined(MIPSEL) || defined(ns32k) || defined(__ARMEL__) || defined(i386) || defined(__i386__)
#   define BYTE_ORDER	LITTLE_ENDIAN
#  endif

# endif
#endif

#if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)

# define htofs(x) (x)
# define htofl(x) (x)

# define ftohs(x) (x)
# define ftohl(x) (x)

#else
# if defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN)

#  define htofs(x) ((EMFushort)( \
		(((EMFushort)(x) & (EMFushort)0x00ffU) << 8) | \
		(((EMFushort)(x) & (EMFushort)0xff00U) >> 8) ))
#  define htofl(x) ((EMFulong)( \
		(((EMFulong)(x) & (EMFulong)0x000000ffUL) << 24) | \
		(((EMFulong)(x) & (EMFulong)0x0000ff00UL) <<  8) | \
		(((EMFulong)(x) & (EMFulong)0x00ff0000UL) >>  8) | \
		(((EMFulong)(x) & (EMFulong)0xff000000UL) >> 24) ))

#  define ftohs(x) (htofs(x))
#  define ftohl(x) (htofl(x))

# else

/* Unknwon endian.  This is not efficient but should work. */
#  include <netinet/in.h>

#  define htofs(x) ((EMFushort)htons( \
		(((EMFushort)(x) & (EMFushort)0x00ffU) << 8) | \
		(((EMFushort)(x) & (EMFushort)0xff00U) >> 8) ))
#  define htofl(x) ((EMFulong)htonl( \
		(((EMFulong)(x) & (EMFulong)0x000000ffUL) << 24) | \
		(((EMFulong)(x) & (EMFulong)0x0000ff00UL) <<  8) | \
		(((EMFulong)(x) & (EMFulong)0x00ff0000UL) >>  8) | \
		(((EMFulong)(x) & (EMFulong)0xff000000UL) >> 24) ))

#  define ftohs(x) ((EMFushort)( \
		(((EMFushort)ntohs(x) & (EMFushort)0x00ffU) << 8) | \
		(((EMFushort)ntohs(x) & (EMFushort)0xff00U) >> 8) ))
#  define ftohl(x) ((EMFulong)( \
		(((EMFulong)ntohl(x) & (EMFulong)0x000000ffUL) << 24) | \
		(((EMFulong)ntohl(x) & (EMFulong)0x0000ff00UL) <<  8) | \
		(((EMFulong)ntohl(x) & (EMFulong)0x00ff0000UL) >>  8) | \
		(((EMFulong)ntohl(x) & (EMFulong)0xff000000UL) >> 24) ))

# endif
#endif

/* for efficiency (evaluate src only once) */
#define HTOFS(dst, src) \
	do { EMFushort htofstmp = (src); dst = htofs(htofstmp); } while (0)
#define HTOFL(dst, src) \
	do { EMFulong htofltmp = (src); dst = htofl(htofltmp); } while (0)


#define LATEX_FONT_BASE	2	/* Index of first LaTeX-like text font */
#define NUM_LATEX_FONTS	5	/* Number of LaTeX like text fonts */
#define PS_FONT_BASE	7	/* Index of first PostScript text font */
#define NUM_PS_FONTS	35	/* Number of PostScript fonts */

#define PIXEL_01MM	(2.11666666667)	/* Converts from pixels to 0.01 mm */
#define PIXEL_01MM_BITPATTERN	(0x40077777)	/* as bit pattern */

#define RAD_01DEG (572.95780)		/* Converts from radians to 0.1 deg */

#define OUT_DEFAULT_PRECIS	0
#define OUT_STRING_PRECIS	1
#define OUT_CHARACTER_PRECIS	2
#define OUT_STROKE_PRECIS	3
#define OUT_TT_PRECIS		4
#define OUT_DEVICE_PRECIS	5
#define OUT_RASTER_PRECIS	6
#define OUT_TT_ONLY_PRECIS	7
#define OUT_OUTLINE_PRECIS	8

#define CLIP_DEFAULT_PRECIS	0
#define CLIP_CHARACTER_PRECIS	1
#define CLIP_STROKE_PRECIS	2
#define CLIP_MASK		0xf
#define CLIP_LH_ANGLES		(1<<4)
#define CLIP_TT_ALWAYS		(2<<4)
#define CLIP_EMBEDDED		(8<<4)

#define DEFAULT_QUALITY		0
#define DRAFT_QUALITY		1
#define PROOF_QUALITY		2

#define DEFAULT_PITCH		0
#define FIXED_PITCH		1
#define VARIABLE_PITCH		2

#define ANSI_CHARSET		0
#define DEFAULT_CHARSET		1
#define SYMBOL_CHARSET		2
#define SHIFTJIS_CHARSET	128
#define HANGUL_CHARSET		129
#define GB2312_CHARSET		134
#define CHINESEBIG5_CHARSET	136
#define OEM_CHARSET		255

/* Font Families */
#define FF_DONTCARE	(0<<4)	/* Don't care or don't know. */
#define FF_ROMAN	(1<<4)	/* Variable stroke width, serifed. */
				/* Times Roman, Century Schoolbook, etc. */
#define FF_SWISS	(2<<4)	/* Variable stroke width, sans-serifed. */
				/* Helvetica, Swiss, etc. */
#define FF_MODERN	(3<<4)	/* Constant stroke width, serifed or */
				/* sans-serifed. Pica, Elite, Courier, etc. */
#define FF_SCRIPT	(4<<4)	/* Cursive, etc. */
#define FF_DECORATIVE	(5<<4)	/* Old English, etc. */

/* Font Weights */
#define FW_DONTCARE		0
#define FW_THIN			100
#define FW_EXTRALIGHT		200
#define FW_LIGHT		300
#define FW_NORMAL		400
#define FW_MEDIUM		500
#define FW_SEMIBOLD		600
#define FW_BOLD			700
#define FW_EXTRABOLD		800
#define FW_HEAVY		900

#define FW_ULTRALIGHT		FW_EXTRALIGHT
#define FW_REGULAR		FW_NORMAL
#define FW_DEMIBOLD		FW_SEMIBOLD
#define FW_ULTRABOLD		FW_EXTRABOLD
#define FW_BLACK		FW_HEAVY

#define PANOSE_COUNT		       10
#define PAN_FAMILYTYPE_INDEX		0
#define PAN_SERIFSTYLE_INDEX		1
#define PAN_WEIGHT_INDEX		2
#define PAN_PROPORTION_INDEX		3
#define PAN_CONTRAST_INDEX		4
#define PAN_STROKEVARIATION_INDEX	5
#define PAN_ARMSTYLE_INDEX		6
#define PAN_LETTERFORM_INDEX		7
#define PAN_MIDLINE_INDEX		8
#define PAN_XHEIGHT_INDEX		9

#define PAN_CULTURE_LATIN		0

/*~~~~~|><|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/* Binary raster ops */
#define R2_BLACK	1	/*  0       */
#define R2_NOTMERGEPEN	2	/* DPon     */
#define R2_MASKNOTPEN	3	/* DPna     */
#define R2_NOTCOPYPEN	4	/* PN       */
#define R2_MASKPENNOT	5	/* PDna     */
#define R2_NOT		6	/* Dn       */
#define R2_XORPEN	7	/* DPx      */
#define R2_NOTMASKPEN	8	/* DPan     */
#define R2_MASKPEN	9	/* DPa      */
#define R2_NOTXORPEN	10	/* DPxn     */
#define R2_NOP		11	/* D        */
#define R2_MERGENOTPEN	12	/* DPno     */
#define R2_COPYPEN	13	/* P        */
#define R2_MERGEPENNOT	14	/* PDno     */
#define R2_MERGEPEN	15	/* DPo      */
#define R2_WHITE	16	/*  1       */
#define R2_LAST		16


/* palette entry flags */

#define RGB(r,g,b)		( (EMFulong)( (uchar)(r) | \
				  (((uchar)(g))<<8) | \
				  (((uchar)(b))<<16) ) )
#define PALETTERGB(r,g,b)	(0x02000000 | RGB(r,g,b))
#define PALETTEINDEX(i)		((EMFulong)(0x01000000 | (EMFushort)(i)))

#define PC_RESERVED	0x01	/* Palette index used for animation */
#define PC_EXPLICIT	0x02	/* Palette index is explicit to device */
#define PC_NOCOLLAPSE	0x04	/* Do not match color to system palette */

#define GetRValue(rgb)	((uchar)(rgb))
#define GetGValue(rgb)	((uchar)((rgb) >> 8))
#define GetBValue(rgb)	((uchar)((rgb) >> 16))

/* Background Modes */
#define TRANSPARENT	1
#define OPAQUE		2
#define BKMODE_LAST	2

/* Graphics Modes */

#define GM_COMPATIBLE	1
#define GM_ADVANCED	2
#define GM_LAST		2

/* PolyDraw and GetPath point types */
#define PT_CLOSEFIGURE		0x01
#define PT_LINETO		0x02
#define PT_BEZIERTO		0x04
#define PT_MOVETO		0x06

/* Mapping Modes */
#define MM_TEXT			1
#define MM_LOMETRIC		2
#define MM_HIMETRIC		3
#define MM_LOENGLISH		4
#define MM_HIENGLISH		5
#define MM_TWIPS		6
#define MM_ISOTROPIC		7
#define MM_ANISOTROPIC		8

/* Min and Max Mapping Mode values */
#define MM_MIN			MM_TEXT
#define MM_MAX			MM_ANISOTROPIC
#define MM_MAX_FIXEDSCALE	MM_TWIPS

/* Coordinate Modes */
#define ABSOLUTE		1
#define RELATIVE		2

/* Stock Logical Objects */
#define WHITE_BRUSH		0
#define LTGRAY_BRUSH		1
#define GRAY_BRUSH		2
#define DKGRAY_BRUSH		3
#define BLACK_BRUSH		4
#define NULL_BRUSH		5
#define HOLLOW_BRUSH		NULL_BRUSH
#define WHITE_PEN		6
#define BLACK_PEN		7
#define NULL_PEN		8
#define OEM_FIXED_FONT		10
#define ANSI_FIXED_FONT		11
#define ANSI_VAR_FONT		12
#define SYSTEM_FONT		13
#define DEVICE_DEFAULT_FONT	14
#define DEFAULT_PALETTE		15
#define SYSTEM_FIXED_FONT	16
#define DEFAULT_GUI_FONT	17

#define STOCK_LAST		19

#define CLR_INVALID	0xFFFFFFFF

/* Brush Styles */
#define BS_SOLID		0
#define BS_NULL			1
#define BS_HOLLOW		BS_NULL
#define BS_HATCHED		2
#define BS_PATTERN		3
#define BS_INDEXED		4
#define BS_DIBPATTERN		5
#define BS_DIBPATTERNPT		6
#define BS_PATTERN8X8		7
#define BS_DIBPATTERN8X8	8

/* Hatch Styles */
#define HS_HORIZONTAL		0	/* ----- */
#define HS_VERTICAL		1	/* ||||| */
#define HS_FDIAGONAL		2	/* \\\\\ */
#define HS_BDIAGONAL		3	/* ///// */
#define HS_CROSS		4	/* +++++ */
#define HS_DIAGCROSS		5	/* xxxxx */

/* Pen Styles */
#define PS_SOLID		0
#define PS_DASH			1	/* -------  */
#define PS_DOT			2	/* .......  */
#define PS_DASHDOT		3	/* _._._._  */
#define PS_DASHDOTDOT		4	/* _.._.._  */
#define PS_NULL			5
#define PS_INSIDEFRAME		6
#define PS_USERSTYLE		7
#define PS_ALTERNATE		8
#define PS_STYLE_MASK		0x0000000F

#define PS_ENDCAP_ROUND		0x00000000
#define PS_ENDCAP_SQUARE	0x00000100
#define PS_ENDCAP_FLAT		0x00000200
#define PS_ENDCAP_MASK		0x00000F00

#define PS_JOIN_ROUND		0x00000000
#define PS_JOIN_BEVEL		0x00001000
#define PS_JOIN_MITER		0x00002000
#define PS_JOIN_MASK		0x0000F000

#define PS_COSMETIC		0x00000000
#define PS_GEOMETRIC		0x00010000
#define PS_TYPE_MASK		0x000F0000

#define AD_COUNTERCLOCKWISE	1
#define AD_CLOCKWISE		2

/*~~~~~|><|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

typedef struct tagSIZEL {
    EMFlong	cx;
    EMFlong	cy;
} SIZEL;

typedef struct tagPOINTS {
    EMFshort	x;
    EMFshort	y;
} POINTS;

typedef struct tagPOINTL {
    EMFlong	x;
    EMFlong	y;
} POINTL;

typedef struct tagRECTL {
    EMFlong	left;
    EMFlong	top;
    EMFlong	right;
    EMFlong	bottom;
} RECTL;

typedef struct tagXFORM {
    EMFfloat	eM11;
    EMFfloat	eM12;
    EMFfloat	eM21;
    EMFfloat	eM22;
    EMFfloat	eDx;
    EMFfloat	eDy;
} XFORM;

/*~~~~~|><|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/* Enhanced Metafile structures */
typedef struct tagENHMETARECORD {
    EMFulong	iType;		/* Record type EMR_XXX */
    EMFulong	nSize;		/* Record size in bytes */
    EMFulong	dParm[1];	/* Parameters */
} ENHMETARECORD;

typedef struct tagENHMETAHEADER {
    EMFulong	iType;		/* Record type EMR_HEADER */
    EMFulong	nSize;		/* Record size in bytes.  This may be greater */
				/*  than the sizeof(ENHMETAHEADER). */
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    RECTL	rclFrame;	/* Inclusive-inclusive Picture Frame of */
				/*  metafile in .01 mm units */
    EMFulong	dSignature;	/* Signature.  Must be ENHMETA_SIGNATURE. */
    EMFulong	nVersion;	/* Version number */
    EMFulong	nBytes;		/* Size of the metafile in bytes */
    EMFulong	nRecords;	/* Number of records in the metafile */
    EMFushort	nHandles;	/* Number of handles in the handle table */
				/* Handle index zero is reserved. */
    EMFushort	sReserved;	/* Reserved.  Must be zero. */
    EMFulong	nDescription;	/* Number of chars in the unicode */
				/*  description string */
			/* This is 0 if there is no description string */
    EMFulong	offDescription;	/* Offset to the metafile description record. */
			/* This is 0 if there is no description string */
    EMFulong	nPalEntries;	/* Number of entries in the metafile palette. */
    SIZEL	szlDevice;	/* Size of the reference device in pels */
    SIZEL	szlMillimeters;	/* Size of the reference device in millimeters */
} ENHMETAHEADER;

/*~~~~~|><|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
 * The next structures the logical color space. Unlike pens and brushes,
 * but like palettes, there is only one way to create a LogColorSpace.
 * A pointer to it must be passed, its elements can't be pushed as
 * arguments.
 */
#define MAX_PATH	260

typedef EMFlong LCSCSTYPE;
typedef EMFlong LCSGAMUTMATCH;
typedef EMFlong FXPT2DOT30;

typedef struct tagCIEXYZ {
    FXPT2DOT30	ciexyzX;
    FXPT2DOT30	ciexyzY;
    FXPT2DOT30	ciexyzZ;
} CIEXYZ;

typedef struct tagCIEXYZTRIPLE {
    CIEXYZ	ciexyzRed;
    CIEXYZ	ciexyzGreen;
    CIEXYZ	ciexyzBlue;
} CIEXYZTRIPLE;

typedef struct tagLOGCOLORSPACEA {
    EMFulong	lcsSignature;
    EMFulong	lcsVersion;
    EMFulong	lcsSize;
    LCSCSTYPE	lcsCSType;
    LCSGAMUTMATCH lcsIntent;
    CIEXYZTRIPLE lcsEndpoints;
    EMFulong	lcsGammaRed;
    EMFulong	lcsGammaGreen;
    EMFulong	lcsGammaBlue;
    char	lcsFilename[MAX_PATH];
} LOGCOLORSPACEA, *LPLOGCOLORSPACEA;

typedef struct tagLOGCOLORSPACEW {
    EMFulong	lcsSignature;
    EMFulong	lcsVersion;
    EMFulong	lcsSize;
    LCSCSTYPE	lcsCSType;
    LCSGAMUTMATCH lcsIntent;
    CIEXYZTRIPLE lcsEndpoints;
    EMFulong	lcsGammaRed;
    EMFulong	lcsGammaGreen;
    EMFulong	lcsGammaBlue;
    TCHAR	lcsFilename[MAX_PATH];
} LOGCOLORSPACEW;

/* Logical Font */
#define LF_FACESIZE		32
#define LF_FULLFACESIZE		64
#define ELF_VENDOR_SIZE		4

typedef struct tagLOGFONTW
{
    EMFlong	lfHeight;
    EMFlong	lfWidth;
    EMFlong	lfEscapement;
    EMFlong	lfOrientation;
    EMFlong	lfWeight;
    uchar	lfItalic;
    uchar	lfUnderline;
    uchar	lfStrikeOut;
    uchar	lfCharSet;
    uchar	lfOutPrecision;
    uchar	lfClipPrecision;
    uchar	lfQuality;
    uchar	lfPitchAndFamily;
    TCHAR	lfFaceName[LF_FACESIZE];
} LOGFONTW;

typedef struct tagPANOSE
{
    uchar	bFamilyType;
    uchar	bSerifStyle;
    uchar	bWeight;
    uchar	bProportion;
    uchar	bContrast;
    uchar	bStrokeVariation;
    uchar	bArmStyle;
    uchar	bLetterform;
    uchar	bMidline;
    uchar	bXHeight;
    uchar	pad[2];		/* Padding to ensure data alignment */
} PANOSE;

typedef struct tagEXTLOGFONTW {
    LOGFONTW	elfLogFont;
    TCHAR	elfFullName[LF_FULLFACESIZE];
    TCHAR	elfStyle[LF_FACESIZE];
    EMFulong	elfVersion;	/* 0 for the first release */
    EMFulong	elfStyleSize;
    EMFulong	elfMatch;
    EMFulong	elfReserved;
    uchar	elfVendorId[ELF_VENDOR_SIZE];
    EMFulong	elfCulture;	/* 0 for Latin             */
    PANOSE	elfPanose;
} EXTLOGFONTW;

typedef struct tagEXTLOGPEN {
    EMFulong	elpPenStyle;
    EMFulong	elpWidth;
    EMFulong	elpBrushStyle;
    EMFulong	elpColor;
    EMFlong	elpHatch;
    EMFulong	elpNumEntries;
/*  EMFulong	elpStyleEntry[1]; */
} EXTLOGPEN;

/* Logical Brush (or Pattern) */
typedef struct tagLOGBRUSH
{
    EMFulong	lbStyle;
    EMFulong	lbColor;
    EMFlong	lbHatch;
} LOGBRUSH;

typedef struct tagPALETTEENTRY {
    uchar	peRed;
    uchar	peGreen;
    uchar	peBlue;
    uchar	peFlags;
} PALETTEENTRY;

/* Logical Palette */
typedef struct tagLOGPALETTE {
    EMFushort		palVersion;
    EMFushort		palNumEntries;
    PALETTEENTRY	palPalEntry[1];
} LOGPALETTE;

/* Logical Pen */
typedef struct tagLOGPEN
{
  EMFulong	lopnStyle;
  POINTL	lopnWidth;
  EMFulong	lopnColor;
} LOGPEN;

/* DIB color information */
#define BI_RGB		0	/* uncompressed */
#define BI_RLE8		1	/* 8 bpp run-length encoding */
#define BI_RLE4		2	/* 4 bpp run-length encoding */
#define BI_BITFIELDS	3	/* uncompressed, color mask */

typedef struct tagBITMAPINFOHEADER {
    EMFulong	biSize;
    EMFlong	biWidth;
    EMFlong	biHeight;
    EMFushort	biPlanes;
    EMFushort	biBitCount;
    EMFulong	biCompression;
    EMFulong	biSizeImage;
    EMFlong	biXPelsPerMeter;
    EMFlong	biYPelsPerMeter;
    EMFulong	biClrUsed;
    EMFulong	biClrImportant;
} BITMAPINFOHEADER;

typedef struct tagRGBQUAD {
    uchar	rgbBlue;
    uchar	rgbGreen;
    uchar	rgbRed;
    uchar	rgbReserved;
} RGBQUAD;

typedef struct tagBITMAPINFO {
    BITMAPINFOHEADER	bmiHeader;
/*  RGBQUAD		bmiColors[1];*/
} BITMAPINFO;

/*~~~~~|><|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
 * Enhanced metafile constants.
 */
#define ENHMETA_SIGNATURE	0x464D4520
#define ENHMETA_VERSION		0x10000
/*
 * Stock object flag used in the object handle index in the enhanced
 * metafile records.
 * E.g. The object handle index (ENHMETA_STOCK_OBJECT | BLACK_BRUSH)
 * represents the stock object BLACK_BRUSH.
 */
#define ENHMETA_STOCK_OBJECT	0x80000000
/*
 * Enhanced metafile record types.
 */
#define EMR_ABORTPATH			68
#define EMR_ANGLEARC			41
#define EMR_ARC				45
#define EMR_ARCTO			55
#define EMR_BEGINPATH			59
#define EMR_BITBLT			76
#define EMR_CHORD			46
#define EMR_CLOSEFIGURE			61
#define EMR_CREATEBRUSHINDIRECT		39
#define EMR_CREATECOLORSPACE		99
#define EMR_CREATEDIBPATTERNBRUSHPT	94
#define EMR_CREATEMONOBRUSH		93
#define EMR_CREATEPALETTE		49
#define EMR_CREATEPEN			38
#define EMR_DELETECOLORSPACE	       101
#define EMR_DELETEOBJECT		40
#define EMR_ELLIPSE			42
#define EMR_ENDPATH			60
#define EMR_EOF				14
#define EMR_EXCLUDECLIPRECT		29
#define EMR_EXTCREATEFONTINDIRECTW	82
#define EMR_EXTCREATEPEN		95
#define EMR_EXTFLOODFILL		53
#define EMR_EXTSELECTCLIPRGN		75
#define EMR_EXTTEXTOUTA			83
#define EMR_EXTTEXTOUTW			84
#define EMR_FILLPATH			62
#define EMR_FILLRGN			71
#define EMR_FLATTENPATH			65
#define EMR_FRAMERGN			72
#define EMR_GDICOMMENT			70
#define EMR_HEADER			 1
#define EMR_INTERSECTCLIPRECT		30
#define EMR_INVERTRGN			73
#define EMR_LINETO			54
#define EMR_MASKBLT			78
#define EMR_MODIFYWORLDTRANSFORM	36
#define EMR_MOVETOEX			27
#define EMR_OFFSETCLIPRGN		26
#define EMR_PAINTRGN			74
#define EMR_PIE				47
#define EMR_PLGBLT			79
#define EMR_POLYBEZIER			 2
#define EMR_POLYBEZIER16		85
#define EMR_POLYBEZIERTO		 5
#define EMR_POLYBEZIERTO16		88
#define EMR_POLYDRAW			56
#define EMR_POLYDRAW16			92
#define EMR_POLYGON			 3
#define EMR_POLYGON16			86
#define EMR_POLYLINE			 4
#define EMR_POLYLINE16			87
#define EMR_POLYLINETO			 6
#define EMR_POLYLINETO16		89
#define EMR_POLYPOLYGON			 8
#define EMR_POLYPOLYGON16		91
#define EMR_POLYPOLYLINE		 7
#define EMR_POLYPOLYLINE16		90
#define EMR_POLYTEXTOUTA		96
#define EMR_POLYTEXTOUTW		97
#define EMR_REALIZEPALETTE		52
#define EMR_RECTANGLE			43
#define EMR_RESIZEPALETTE		51
#define EMR_RESTOREDC			34
#define EMR_ROUNDRECT			44
#define EMR_SAVEDC			33
#define EMR_SCALEVIEWPORTEXTEX		31
#define EMR_SCALEWINDOWEXTEX		32
#define EMR_SELECTCLIPPATH		67
#define EMR_SELECTOBJECT		37
#define EMR_SELECTPALETTE		48
#define EMR_SETARCDIRECTION		57
#define EMR_SETBKCOLOR			25
#define EMR_SETBKMODE			18
#define EMR_SETBRUSHORGEX		13
#define EMR_SETCOLORADJUSTMENT		23
#define EMR_SETCOLORSPACE	       100
#define EMR_SETDIBITSTODEVICE		80
#define EMR_SETICMMODE			98
#define EMR_SETMAPMODE			17
#define EMR_SETMAPPERFLAGS		16
#define EMR_SETMETARGN			28
#define EMR_SETMITERLIMIT		58
#define EMR_SETPALETTEENTRIES		50
#define EMR_SETPIXELV			15
#define EMR_SETPOLYFILLMODE		19
#define EMR_SETROP2			20
#define EMR_SETSTRETCHBLTMODE		21
#define EMR_SETTEXTALIGN		22
#define EMR_SETTEXTCOLOR		24
#define EMR_SETVIEWPORTEXTEX		11
#define EMR_SETVIEWPORTORGEX		12
#define EMR_SETWINDOWEXTEX		 9
#define EMR_SETWINDOWORGEX		10
#define EMR_SETWORLDTRANSFORM		35
#define EMR_STRETCHBLT			77
#define EMR_STRETCHDIBITS		81
#define EMR_STROKEANDFILLPATH		63
#define EMR_STROKEPATH			64
#define EMR_WIDENPATH			66

#define EMR_MIN				 1
#define EMR_MAX			       101


/* Text Alignment Options */
#define TA_NOUPDATECP		0
#define TA_UPDATECP		1

#define TA_LEFT			0
#define TA_RIGHT		2
#define TA_CENTER		6

#define TA_TOP			0
#define TA_BOTTOM		8
#define TA_BASELINE		24
#define TA_RTLREADING		256
#define TA_MASK		(TA_BASELINE+TA_CENTER+TA_UPDATECP+TA_RTLREADING)

#define VTA_BASELINE	TA_BASELINE
#define VTA_LEFT	TA_BOTTOM
#define VTA_RIGHT	TA_TOP
#define VTA_CENTER	TA_CENTER
#define VTA_BOTTOM	TA_RIGHT
#define VTA_TOP		TA_LEFT

#define ETO_OPAQUE		0x0002
#define ETO_CLIPPED		0x0004
#define ETO_GLYPH_INDEX		0x0010
#define ETO_RTLREADING		0x0080

#define ASPECT_FILTERING	0x0001

/* DIB color id */
#define DIB_RGB_COLORS	0
#define DIB_PAL_COLORS	1

/* raster operation codes (most common ones) */
#define SRCCOPY		0x00CC0020	/* Destination = Source */
#define SRCPAINT	0x00EE0086	/* Destination |= Source */
#define SRCAND		0x008800C6	/* Destination &= Source */
#define SRCINVERT	0x00660046	/* Destination ^= Source */

/* Base record type for the enhanced metafile. */

typedef struct tagEMR
{
    EMFulong	iType;		/* Enhanced metafile record type */
    EMFulong	nSize;		/* Length of the record in bytes */
				/* This must be a multiple of 4 */
} EMR;

/* Base text record type for the enhanced metafile. */

typedef struct tagEMRTEXT
{
    POINTL	ptlReference;
    EMFulong	nChars;
    EMFulong	offString;	/* Offset to the string */
    EMFulong	fOptions;	/* Options like ETO_OPAQUE and ETO_CLIPPED */
    RECTL	rcl;
    EMFulong	offDx;		/* Offset to the inter-character spacing array*/
				/* This is always given */
} EMRTEXT;

/* Record structures for the enhanced metafile. */

typedef struct tagABORTPATH
{
    EMR		emr;
} EMRABORTPATH, EMRBEGINPATH, EMRENDPATH, EMRCLOSEFIGURE, EMRFLATTENPATH,
  EMRWIDENPATH, EMRSETMETARGN, EMRSAVEDC, EMRREALIZEPALETTE;

typedef struct tagEMRSELECTCLIPPATH
{
    EMR		emr;
    EMFulong	iMode;
} EMRSELECTCLIPPATH, EMRSETBKMODE, EMRSETMAPMODE, EMRSETPOLYFILLMODE,
  EMRSETROP2, EMRSETSTRETCHBLTMODE, EMRSETICMMODE, EMRSETTEXTALIGN;

typedef struct tagEMRSETMITERLIMIT
{
    EMR		emr;
    EMFfloat	eMiterLimit;
} EMRSETMITERLIMIT;

typedef struct tagEMRRESTOREDC
{
    EMR		emr;
    EMFlong	iRelative;	/* Specifies a relative instance */
} EMRRESTOREDC;

typedef struct tagEMRSETARCDIRECTION
{
    EMR		emr;
    EMFulong	iArcDirection;	/* Specifies the arc direction in the */
				/* advanced graphics mode. */
} EMRSETARCDIRECTION;

typedef struct tagEMRSETMAPPERFLAGS
{
    EMR		emr;
    EMFulong	dwFlags;
} EMRSETMAPPERFLAGS;

typedef struct tagEMRSETTEXTCOLOR
{
    EMR		emr;
    EMFulong	crColor;
} EMRSETBKCOLOR, EMRSETTEXTCOLOR;

typedef struct tagEMRSELECTOBJECT
{
    EMR		emr;
    EMFulong	ihObject;	/* Object handle index */
} EMRSELECTOBJECT, EMRDELETEOBJECT;

typedef struct tagEMRSELECTCOLORSPACE
{
    EMR		emr;
    EMFulong	ihCS;		/* ColorSpace handle index */
} EMRSELECTCOLORSPACE, EMRDELETECOLORSPACE;

typedef struct tagEMRSELECTPALETTE
{
    EMR		emr;
    EMFulong	ihPal;		/* Palette handle index, background mode only */
} EMRSELECTPALETTE;

typedef struct tagEMRRESIZEPALETTE
{
    EMR		emr;
    EMFulong	ihPal;		/* Palette handle index */
    EMFulong	cEntries;
} EMRRESIZEPALETTE;

typedef struct tagEMRSETPALETTEENTRIES
{
    EMR		emr;
    EMFulong	ihPal;		/* Palette handle index */
    EMFulong	iStart;
    EMFulong	cEntries;
    PALETTEENTRY aPalEntries[1];/* The peFlags fields do not contain any flags */
} EMRSETPALETTEENTRIES;

typedef struct tagEMRSETCOLORADJUSTMENT
{
    EMR			emr;
/*  COLORADJUSTMENT	ColorAdjustment; */
} EMRSETCOLORADJUSTMENT;


typedef struct tagEMRGDICOMMENT
{
    EMR		emr;
    EMFulong	cbData;		/* Size of data in bytes */
} EMRGDICOMMENT;

typedef struct tagEMREOF
{
    EMR		emr;
    EMFulong	nPalEntries;	/* Number of palette entries */
    EMFulong	offPalEntries;	/* Offset to the palette entries */
    EMFulong	nSizeLast;	/* Same as nSize and must be the last ulong */
				/* of the record.  The palette entries, */
				/* if exist, precede this field. */
} EMREOF;

typedef struct tagEMRLINETO
{
    EMR		emr;
    POINTL	ptl;
} EMRLINETO, EMRMOVETOEX;

typedef struct tagEMROFFSETCLIPRGN
{
    EMR		emr;
    POINTL	ptlOffset;
} EMROFFSETCLIPRGN;

typedef struct tagEMRFILLPATH
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
} EMRFILLPATH, EMRSTROKEANDFILLPATH, EMRSTROKEPATH;

typedef struct tagEMREXCLUDECLIPRECT
{
    EMR		emr;
    RECTL	rclClip;
} EMREXCLUDECLIPRECT, EMRINTERSECTCLIPRECT;

typedef struct tagEMRSETVIEWPORTORGEX
{
    EMR		emr;
    POINTL	ptlOrigin;
} EMRSETVIEWPORTORGEX, EMRSETWINDOWORGEX, EMRSETBRUSHORGEX;

typedef struct tagEMRSETVIEWPORTEXTEX
{
    EMR		emr;
    SIZEL	szlExtent;
} EMRSETVIEWPORTEXTEX, EMRSETWINDOWEXTEX;

typedef struct tagEMRSCALEVIEWPORTEXTEX
{
    EMR		emr;
    EMFlong	xNum;
    EMFlong	xDenom;
    EMFlong	yNum;
    EMFlong	yDenom;
} EMRSCALEVIEWPORTEXTEX, EMRSCALEWINDOWEXTEX;

typedef struct tagEMRSETWORLDTRANSFORM
{
    EMR		emr;
    XFORM	xform;
} EMRSETWORLDTRANSFORM;

typedef struct tagEMRMODIFYWORLDTRANSFORM
{
    EMR		emr;
    XFORM	xform;
    EMFulong	iMode;
} EMRMODIFYWORLDTRANSFORM;

typedef struct tagEMRSETPIXELV
{
    EMR		emr;
    POINTL	ptlPixel;
    EMFulong	crColor;
} EMRSETPIXELV;

typedef struct tagEMREXTFLOODFILL
{
    EMR		emr;
    POINTL	ptlStart;
    EMFulong	crColor;
    EMFulong	iMode;
} EMREXTFLOODFILL;

typedef struct tagEMRELLIPSE
{
    EMR		emr;
    RECTL	rclBox;		/* Inclusive-inclusive bounding rectangle */
} EMRELLIPSE, EMRRECTANGLE;

typedef struct tagEMRROUNDRECT
{
    EMR		emr;
    RECTL	rclBox;		/* Inclusive-inclusive bounding rectangle */
    SIZEL	szlCorner;
} EMRROUNDRECT;

typedef struct tagEMRARC
{
    EMR		emr;
    RECTL	rclBox;		/* Inclusive-inclusive bounding rectangle */
    POINTL	ptlStart;
    POINTL	ptlEnd;
} EMRARC, EMRARCTO, EMRCHORD, EMRPIE;

typedef struct tagEMRANGLEARC
{
    EMR		emr;
    POINTL	ptlCenter;
    EMFulong	nRadius;
    EMFfloat	eStartAngle;
    EMFfloat	eSweepAngle;
} EMRANGLEARC;

typedef struct tagEMRPOLYLINE
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFulong	cptl;		/* Number of points in the array */
/*  POINTL	aptl[cptl];	(* Array of 32-bit points */
} EMRPOLYLINE, EMRPOLYBEZIER, EMRPOLYGON, EMRPOLYBEZIERTO, EMRPOLYLINETO;

typedef struct tagEMRPOLYLINE16
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFulong	cpts;		/* Number of points in the array */
/*  POINTS	apts[cpts];	(* Array of 16-bit points */
} EMRPOLYLINE16, EMRPOLYBEZIER16, EMRPOLYGON16, EMRPOLYBEZIERTO16,
  EMRPOLYLINETO16;

typedef struct tagEMRPOLYDRAW
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFulong	cptl;		/* Number of points */
    POINTL	aptl[1];	/* Array of points */
    uchar	abTypes[1];	/* Array of point types */
} EMRPOLYDRAW;

typedef struct tagEMRPOLYDRAW16
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFulong	cpts;		/* Number of points */
    POINTS	apts[1];	/* Array of points */
    uchar	abTypes[1];	/* Array of point types */
} EMRPOLYDRAW16;

typedef struct tagEMRPOLYPOLYLINE
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFulong	nPolys;		/* Number of polys */
    EMFulong	cptl;		/* Total number of points in all polys */
    EMFulong	aPolyCounts[1];	/* Array of point counts for each poly */
    POINTL	aptl[1];	/* Array of points */
} EMRPOLYPOLYLINE, EMRPOLYPOLYGON;

typedef struct tagEMRPOLYPOLYLINE16
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFulong	nPolys;		/* Number of polys */
    EMFulong	cpts;		/* Total number of points in all polys */
    EMFulong	aPolyCounts[1];	/* Array of point counts for each poly */
    POINTS	apts[1];	/* Array of points */
} EMRPOLYPOLYLINE16, EMRPOLYPOLYGON16;

typedef struct tagEMRINVERTRGN
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFulong	cbRgnData;	/* Size of region data in bytes */
    uchar	RgnData[1];
} EMRINVERTRGN, EMRPAINTRGN;

typedef struct tagEMRFILLRGN
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFulong	cbRgnData;	/* Size of region data in bytes */
    EMFulong	ihBrush;	/* Brush handle index */
    uchar	RgnData[1];
} EMRFILLRGN;

typedef struct tagEMRFRAMERGN
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFulong	cbRgnData;	/* Size of region data in bytes */
    EMFulong	ihBrush;	/* Brush handle index */
    SIZEL	szlStroke;
    uchar	RgnData[1];
} EMRFRAMERGN;

typedef struct tagEMREXTSELECTCLIPRGN
{
    EMR		emr;
    EMFulong	cbRgnData;	/* Size of region data in bytes */
    EMFulong	iMode;
    uchar	RgnData[1];
} EMREXTSELECTCLIPRGN;

typedef struct tagEMREXTTEXTOUTA
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFulong	iGraphicsMode;	/* Current graphics mode */
    EMFfloat	exScale;	/* X and Y scales from Page units to .01mm */
    EMFfloat	eyScale;	/*  units if graphics mode is GM_COMPATIBLE. */
    EMRTEXT	emrtext;	/* This is followed by the string and */
				/* spacing array */
} EMREXTTEXTOUTA, EMREXTTEXTOUTW;

typedef struct tagEMRPOLYTEXTOUTA
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFulong	iGraphicsMode;	/* Current graphics mode */
    EMFfloat	exScale;	/* X and Y scales from Page units to .01mm */
    EMFfloat	eyScale;	/*  units if graphics mode is GM_COMPATIBLE. */
    EMFlong	cStrings;
    EMRTEXT	aemrtext[1];	/* Array of EMRTEXT structures.  This is */
				/* followed by the strings and spacing arrays.*/
} EMRPOLYTEXTOUTA, EMRPOLYTEXTOUTW;

typedef struct tagEMRBITBLT
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFlong	xDest;
    EMFlong	yDest;
    EMFlong	cxDest;
    EMFlong	cyDest;
    EMFulong	dwRop;
    EMFlong	 xSrc;
    EMFlong	 ySrc;
    XFORM	xformSrc;	/* Source DC transform */
    EMFulong	crBkColorSrc;	/* Source DC BkColor in RGB */
    EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
				/* (DIB_RGB_COLORS) */
    EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
    EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
    EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
    EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
} EMRBITBLT;

typedef struct tagEMRSTRETCHBLT
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFlong	xDest;
    EMFlong	yDest;
    EMFlong	cxDest;
    EMFlong	cyDest;
    EMFulong	dwRop;
    EMFlong	xSrc;
    EMFlong	ySrc;
    XFORM	xformSrc;	/* Source DC transform */
    EMFulong	crBkColorSrc;	/* Source DC BkColor in RGB */
    EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
				/* (DIB_RGB_COLORS) */
    EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
    EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
    EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
    EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
    EMFlong	cxSrc;
    EMFlong	cySrc;
} EMRSTRETCHBLT;

typedef struct tagEMRMASKBLT
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFlong	xDest;
    EMFlong	yDest;
    EMFlong	cxDest;
    EMFlong	cyDest;
    EMFulong	dwRop;
    EMFlong	xSrc;
    EMFlong	ySrc;
    XFORM	xformSrc;	/* Source DC transform */
    EMFulong	crBkColorSrc;	/* Source DC BkColor in RGB */
    EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
				/* (DIB_RGB_COLORS) */
    EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
    EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
    EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
    EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
    EMFlong	xMask;
    EMFlong	yMask;
    EMFulong	iUsageMask;	/* Mask bitmap info color table usage */
    EMFulong	offBmiMask;	/* Offset to the mask BITMAPINFO structure if any */
    EMFulong	cbBmiMask;	/* Size of the mask BITMAPINFO structure if any */
    EMFulong	offBitsMask;	/* Offset to the mask bitmap bits if any */
    EMFulong	cbBitsMask;	/* Size of the mask bitmap bits if any */
} EMRMASKBLT;

typedef struct tagEMRPLGBLT
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    POINTL	aptlDest[3];
    EMFlong	xSrc;
    EMFlong	ySrc;
    EMFlong	cxSrc;
    EMFlong	cySrc;
    XFORM	xformSrc;	/* Source DC transform */
    EMFulong	crBkColorSrc;	/* Source DC BkColor in RGB */
    EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
				/* (DIB_RGB_COLORS) */
    EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
    EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
    EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
    EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
    EMFlong	xMask;
    EMFlong	yMask;
    EMFulong	iUsageMask;	/* Mask bitmap info color table usage */
    EMFulong	offBmiMask;	/* Offset to the mask BITMAPINFO structure if any */
    EMFulong	cbBmiMask;	/* Size of the mask BITMAPINFO structure if any */
    EMFulong	offBitsMask;	/* Offset to the mask bitmap bits if any */
    EMFulong	cbBitsMask;	/* Size of the mask bitmap bits if any */
} EMRPLGBLT;

typedef struct tagEMRSETDIBITSTODEVICE
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFlong	xDest;
    EMFlong	yDest;
    EMFlong	xSrc;
    EMFlong	ySrc;
    EMFlong	cxSrc;
    EMFlong	cySrc;
    EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
    EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
    EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
    EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
    EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
    EMFulong	iStartScan;
    EMFulong	cScans;
} EMRSETDIBITSTODEVICE;

typedef struct tagEMRSTRETCHDIBITS
{
    EMR		emr;
    RECTL	rclBounds;	/* Inclusive-inclusive bounds in device units */
    EMFlong	xDest;
    EMFlong	yDest;
    EMFlong	xSrc;
    EMFlong	ySrc;
    EMFlong	cxSrc;
    EMFlong	cySrc;
    EMFulong	offBmiSrc;	/* Offset to the source BITMAPINFO structure */
    EMFulong	cbBmiSrc;	/* Size of the source BITMAPINFO structure */
    EMFulong	offBitsSrc;	/* Offset to the source bitmap bits */
    EMFulong	cbBitsSrc;	/* Size of the source bitmap bits */
    EMFulong	iUsageSrc;	/* Source bitmap info color table usage */
    EMFulong	dwRop;
    EMFlong	cxDest;
    EMFlong	cyDest;
} EMRSTRETCHDIBITS;

typedef struct tagEMREXTCREATEFONTINDIRECTW
{
    EMR		emr;
    EMFulong	ihFont;		/* Font handle index */
    EXTLOGFONTW	elfw;
} EMREXTCREATEFONTINDIRECTW;

typedef struct tagEMRCREATEPALETTE
{
    EMR		emr;
    EMFulong	ihPal;		/* Palette handle index */
    LOGPALETTE	lgpl;		/* The peFlags fields in the palette entries */
				/* do not contain any flags */
} EMRCREATEPALETTE;

typedef struct tagEMRCREATECOLORSPACE
{
    EMR			emr;
    EMFulong		ihCS;	/* ColorSpace handle index */
    LOGCOLORSPACEW	lcs;
} EMRCREATECOLORSPACE;

typedef struct tagEMRCREATEPEN
{
    EMR		emr;
    EMFulong	ihPen;		/* Pen handle index */
    LOGPEN	lopn;
} EMRCREATEPEN;

typedef struct tagEMREXTCREATEPEN
{
    EMR		emr;
    EMFulong	ihPen;		/* Pen handle index */
    EMFulong	offBmi;		/* Offset to the BITMAPINFO structure if any */
    EMFulong	cbBmi;		/* Size of the BITMAPINFO structure if any */
				/* The bitmap info is followed by the bitmap */
				/* bits to form a packed DIB. */
    EMFulong	offBits;	/* Offset to the brush bitmap bits if any */
    EMFulong	cbBits;		/* Size of the brush bitmap bits if any */
    EXTLOGPEN	elp;		/* The extended pen with the style array. */
} EMREXTCREATEPEN;

typedef struct tagEMRCREATEBRUSHINDIRECT
{
    EMR		emr;
    EMFulong	ihBrush;	/* Brush handle index */
    LOGBRUSH	lb;		/* The style must be BS_SOLID, BS_HOLLOW, */
				/* BS_NULL or BS_HATCHED. */
} EMRCREATEBRUSHINDIRECT;

typedef struct tagEMRCREATEMONOBRUSH
{
    EMR		emr;
    EMFulong	ihBrush;	/* Brush handle index */
    EMFulong	iUsage;		/* Bitmap info color table usage */
    EMFulong	offBmi;		/* Offset to the BITMAPINFO structure */
    EMFulong	cbBmi;		/* Size of the BITMAPINFO structure */
    EMFulong	offBits;	/* Offset to the bitmap bits */
    EMFulong	cbBits;		/* Size of the bitmap bits */
} EMRCREATEMONOBRUSH;

typedef struct tagEMRCREATEDIBPATTERNBRUSHPT
{
    EMR		emr;
    EMFulong	ihBrush;	/* Brush handle index */
    EMFulong	iUsage;		/* Bitmap info color table usage */
    EMFulong	offBmi;		/* Offset to the BITMAPINFO structure */
    EMFulong	cbBmi;		/* Size of the BITMAPINFO structure */
				/* The bitmap info is followed by the bitmap */
				/* bits to form a packed DIB. */
    EMFulong	offBits;	/* Offset to the bitmap bits */
    EMFulong	cbBits;		/* Size of the bitmap bits */
} EMRCREATEDIBPATTERNBRUSHPT;

typedef struct tagEMRFORMAT
{
    EMFulong	dSignature;	/* Format signature, e.g. ENHMETA_SIGNATURE. */
    EMFulong	nVersion;	/* Format version number. */
    EMFulong	cbData;		/* Size of data in bytes. */
    EMFulong	offData;	/* Offset to data from GDICOMMENT_IDENTIFIER. */
				/* It must begin at a ulong offset. */
} EMRFORMAT;

#endif /* GENEMF_H */