/usr/share/doc/libwmf0.2-7/tutipa.html is in libwmf-doc 0.2.8.4-10ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <html>
<head>
<title>libwmf-0.2.0 Tutorial 2: The IPA</title>
</head>
<body link="#CC0000" alink="#FF3300" vlink="#330099" text="#000000" bgcolor="#ffffff"
background="caolan/pics/weave.jpg">
<h1>libwmf-0.2.0 Tutorial 2: The IPA</h1>
<h2>Contents</h2>
<ul>
<li><a href="#intro">Introduction</a>
<li><a href="#types">Types</a>
<li><a href="#ipafnref"><b>IPA</b> Function Reference</a>
<li><a href="#ipafns">IPA Functions</a>
<li><a href="#bitmap">Bitmap Functions</a>
<li><a href="#fns">Other Functions</a>
<li><a href="#guide">Guidelines</a>
<li><a href="#compile">Compiling - The Distribution</a>
</ul>
<a name="intro"><h2>Introduction</h2></a>
<p>
This is a combination of tutorial and reference guide for writing new device
layers for <tt>libwmf</tt>.
</p>
<p>
Since no two graphics interfaces are identical, the task of the <b>IPA</b>
(the interface between the interpreter and the device layer) is to simplify the
task of translating the metafile drawing commands. (It cannot be denied that
there is still considerable room for improvement.)
</p>
<p>
When writing a new device layer you will need to include the following headers:
</p>
<font color=blue>
<pre>
#include <libwmf/ipa.h>
#include <libwmf/defs.h>
</pre>
</font>
<p>
The former includes the <b>API</b> declarations as well as the <b>IPA</b>
declarations, while the latter defines metafile constants.
</p>
<a name="types"><h2>Types</h2></a>
<a href="#RGB">wmfRGB</a>
| <a href="#BMP">wmfBMP</a>
| <a href="#Brush">wmfBrush</a>
| <a href="#Pen">wmfPen</a>
| <a href="#Font">wmfFont</a>
| <a href="#DC">wmfDC</a>
| <a href="#Flood">wmfFlood_t</a>
| <a href="#DrawPixel">wmfDrawPixel_t</a>
| <a href="#DrawArc">wmfDrawArc_t</a>
| <a href="#DrawLine">wmfDrawLine_t</a>
| <a href="#PolyLine">wmfPolyLine_t</a>
| <a href="#DrawRect">wmfDrawRectangle_t</a>
| <a href="#PolyRect">wmfPolyRectangle_t</a>
| <a href="#BMPRead">wmfBMP_Read_t</a>
| <a href="#BMPDraw">wmfBMP_Draw_t</a>
| <a href="#ROPDraw">wmfROP_Draw_t</a>
| <a href="#DrawText">wmfDrawText_t</a>
| <a href="#UserData">wmfUserData_t</a>
| <a href="#CharDrawer">wmfCharDrawer</a>
<ul>
<li><a name="RGB"><b>wmfRGB</b></a>
<font color=blue>
<pre>
typedef struct _wmfRGB wmfRGB;
struct _wmfRGB
{ unsigned char r;
unsigned char g;
unsigned char b;
};
</pre>
</font>
<p>
<tt>wmfRGB</tt> describes a color, with <tt>r = g = b = 255</tt> corresponding
to <i>white</i> and <tt>r = g = b = 0</tt> corresponding to <i>black</i>.
</p>
<li><a name="BMP"><b>wmfBMP</b></a>
<font color=blue>
<pre>
typedef struct _wmfBMP wmfBMP;
struct _wmfBMP
{ U16 width;
U16 height;
void* data;
};
</pre>
</font>
<p>
Container for a bitmap, of dimensions <tt>width</tt> and <tt>height</tt>.
If non-zero, <tt>data</tt> is a pointer to an internal representation of the
bitmap. The interpreter does not reference <tt>data</tt> and will not attempt
to draw a bitmap if <tt>data</tt> is zero; however, a bitmap brush pattern
may be set even though <tt>data</tt> is zero. (<tt>data=0</tt> indicates
either that the device layer has no support for bitmaps or that the bitmap
is corrupt or unreadable.)
</p>
<li><a name="Brush"><b>wmfBrush</b></a>
<font color=blue>
<pre>
typedef struct _wmfBrush wmfBrush;
struct _wmfBrush
{ U16 lbStyle;
U16 lbHatch;
wmfRGB lbColor;
wmfBMP bmp;
};
</pre>
</font>
<p>
<tt>wmfBrush</tt> is one element of the current drawing context.
<tt>lbStyle</tt> is one of the following:
</p>
<font color=blue>
<pre>
/* 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
</pre>
</font>
<p>
where <tt>BS_NULL</tt> indicates that no brush is set. If
<tt>lbStyle=BS_HATCHED</tt> then the brush has the pattern, specified by
<tt>lbHatch</tt> which is one of:
</p>
<font color=blue>
<pre>
/* 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 */
</pre>
</font>
<p>
If <tt>lbStyle=BS_HATCHED</tt> or <tt>lbStyle=BS_SOLID</tt> then the foreground
color of the brush is <tt>lbColor</tt>. Otherwise, if the brush is a bitmap,
ensure that <tt>bmp.data</tt> is non-zero.
</p>
<p>
The following macros should be used to retrieve the above info.:
</p>
<font color=blue>
<pre>
#include <libwmf/macro.h>
/* WMF_BRUSH_STYLE(wmfBrush* B) -> (U16) brush style
* WMF_BRUSH_HATCH(wmfBrush* B) -> (U16) brush hatch style
*
* WMF_BRUSH_COLOR(wmfBrush* B) -> (wmfRGB*) brush color
*
* WMF_BRUSH_BITMAP(wmfBrush* B) -> (wmfBMP*) brush bitmap
*/
#define WMF_BRUSH_STYLE(B) ((B)->lbStyle)
#define WMF_BRUSH_HATCH(B) ((B)->lbHatch)
#define WMF_BRUSH_COLOR(B) (&((B)->lbColor))
#define WMF_BRUSH_BITMAP(B) (&((B)->bmp))
</pre>
</font>
<li><a name="Pen"><b>wmfPen</b></a>
<font color=blue>
<pre>
typedef struct _wmfPen wmfPen;
struct _wmfPen
{ U16 lopnStyle;
double width;
double height;
wmfRGB lopnColor;
};
</pre>
</font>
<p>
<tt>wmfPen</tt> is one element of the current drawing context. The nib has
dimensions <tt>width</tt> and <tt>height</tt> and color <tt>lopnColor</tt>.
<tt>lopnStyle</tt> contains style information on the line itself, on the ends,
on the joins, and on the type:
</p>
<font color=blue>
<pre>
#define PS_STYLE_MASK 0x0000000F
#define PS_ENDCAP_MASK 0x00000F00
#define PS_JOIN_MASK 0x0000F000
#define PS_TYPE_MASK 0x000F0000
</pre>
</font>
<p>
<tt>lopnStyle & PS_STYLE_MASK</tt> is one of:
</p>
<font color=blue>
<pre>
#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
</pre>
</font>
<p>
where PS_NULL indicates that no pen has been set.
<tt>lopnStyle & PS_ENDCAP_MASK</tt> is one of:
</p>
<font color=blue>
<pre>
#define PS_ENDCAP_ROUND 0x00000000
#define PS_ENDCAP_SQUARE 0x00000100
#define PS_ENDCAP_FLAT 0x00000200
</pre>
</font>
<p>
and <tt>lopnStyle & PS_JOIN_MASK</tt> is one of:
</p>
<font color=blue>
<pre>
#define PS_JOIN_ROUND 0x00000000
#define PS_JOIN_BEVEL 0x00001000
#define PS_JOIN_MITER 0x00002000
</pre>
</font>
<p>
Finally, <tt>lopnStyle & PS_TYPE_MASK</tt> is one of:
</p>
<font color=blue>
<pre>
#define PS_COSMETIC 0x00000000
#define PS_GEOMETRIC 0x00010000
</pre>
</font>
<p>
The following macros should be used to retrieve the above info.:
</p>
<font color=blue>
<pre>
#include <libwmf/macro.h>
/* WMF_PEN_STYLE(wmfPen* P) -> (U16) pen style
* WMF_PEN_ENDCAP(wmfPen* P) -> (U16) endcap style
* WMF_PEN_JOIN(wmfPen* P) -> (U16) join style
* WMF_PEN_TYPE(wmfPen* P) -> (U16) `type' of pen (??)
*
* WMF_PEN_WIDTH(wmfPen* P) -> (double) pen `width' (thickness w.r.t. x-axis)
* WMF_PEN_HEIGHT(wmfPen* P) -> (double) pen `height' (thickness w.r.t. y-axis)
*
* WMF_PEN_COLOR(wmfPen* P) -> (wmfRGB*) pen color
*/
#define WMF_PEN_STYLE(P) ((P)->lopnStyle & PS_STYLE_MASK)
#define WMF_PEN_ENDCAP(P) ((P)->lopnStyle & PS_ENDCAP_MASK)
#define WMF_PEN_JOIN(P) ((P)->lopnStyle & PS_JOIN_MASK)
#define WMF_PEN_TYPE(P) ((P)->lopnStyle & PS_TYPE_MASK)
#define WMF_PEN_WIDTH(P) ((P)->width)
#define WMF_PEN_HEIGHT(P) ((P)->height)
#define WMF_PEN_COLOR(P) (&((P)->lopnColor))
</pre>
</font>
<li><a name="Font"><b>wmfFont</b></a>
<font color=blue>
<pre>
typedef struct _wmfFont wmfFont;
struct _wmfFont
{ U16 lfHeight;
U16 lfWidth;
S16 lfEscapement;
S16 lfOrientation;
U16 lfWeight;
U8 lfItalic;
U8 lfUnderline;
U8 lfStrikeOut;
U8 lfCharSet;
U8 lfOutPrecision;
U8 lfClipPrecision;
U8 lfQuality;
U8 lfPitchAndFamily;
char* lfFaceName;
char* ps_name;
FT_Face ft_face;
};
</pre>
</font>
<p>
<tt>wmfFont</tt> is one element of the current drawing context. Of all of this,
the most important elements are <tt>ps_name</tt> (the postscript font name) and
<tt>ft_face</tt>, the freetype (2) font face for which <b>bold</b> and
<i>italics</i> have already been determined.
</p>
<p>
The following macros should be used to retrieve the above info.:
</p>
<font color=blue>
<pre>
#include <libwmf/macro.h>
/* WMF_TEXT_ANGLE(wmfFont* F) -> (double) text angle in radians
*
* WMF_TEXT_UNDERLINE(wmfFont* F) -> (U8) ?? whether to underline (?? how thick)
* WMF_TEXT_STRIKEOUT(wmfFont* F) -> (U8) ?? whether to strikeout (?? how thick)
*
* WMF_FONT_NAME(wmfFont* F) -> (char*) font name supplied by metafile
* WMF_FONT_PSNAME(wmfFont* F) -> (char*) font name to use in postscript output
* WMF_FONT_FTFACE(wmfFont* F) -> (FT_Face) freetype(2) font face
*/
#define WMF_TEXT_ANGLE(F) ((((double) (F)->lfEscapement) / 10) * M_PI / 180)
#define WMF_TEXT_UNDERLINE(F) ((F)->lfUnderline)
#define WMF_TEXT_STRIKEOUT(F) ((F)->lfStrikeOut)
#define WMF_FONT_NAME(F) ((F)->lfFaceName)
#define WMF_FONT_PSNAME(F) ((F)->ps_name)
#define WMF_FONT_FTFACE(F) ((F)->ft_face)
</pre>
</font>
<li><a name="DC"><b>wmfDC</b></a>
<font color=blue>
<pre>
typedef struct _wmfDC wmfDC;
struct _wmfDC
{ void* userdata;
wmfBrush* brush;
wmfPen* pen;
wmfFont* font;
int key; /* Is this used ?? */
wmfDC* next; /* Is this used ?? */
wmfRGB textcolor;
wmfRGB bgcolor;
U16 textalign;
U16 bgmode;
U16 polyfillmode;
U16 charextra;
U16 breakextra;
U16 ROPmode;
struct
{ S32 Ox;
S32 Oy;
S32 width;
S32 height;
} Window;
double pixel_width; /* Display pixel dimensions (inches) */
double pixel_height;
U16 map_mode;
void* clip;
};
</pre>
</font>
<p>
<i>Still very much a work in progress, especially with regard to the drawing
context <tt>wmfDC</tt>; there is much in this structure that is (or should
be) irrelevant to the <b>IPA</b>.</i>
</p>
<p>
See <b>wmfBrush</b>, <b>wmfPen</b> and <b>wmfFont</b>. <tt>textcolor</tt> is
the color to draw text, <tt>bgcolor</tt> is the background color (generally, as
well as with text) unless <tt>bgmode=TRANSPARENT</tt>, in which case there is
no background. <tt>bgmode</tt> is one of:
</p>
<font color=blue>
<pre>
#define TRANSPARENT 1
#define OPAQUE 2
#define BKMODE_LAST 2
</pre>
</font>
<p>
The following macros should be used to retrieve the above info.:
</p>
<font color=blue>
<pre>
#include <libwmf/macro.h>
/* WMF_DC_BRUSH(wmfDC* C) -> (wmfBrush*) current brush
* WMF_DC_PEN(wmfDC* C) -> (wmfPen*) current pen
* WMF_DC_FONT(wmfDC* C) -> (wmfFont*) current font
*
* WMF_DC_TEXTCOLOR(wmfDC* C) -> (wmfRGB*) text color
* WMF_DC_BACKGROUND(wmfDC* C) -> (wmfRGB*) background color
*
* WMF_DC_OPAQUE(wmfDC* C) -> (U16) whether to fill opaque (non-zero if true)
*
* WMF_DC_POLYFILL(wmfDC* C) -> (U16) how to fill polygons
*
* WMF_DC_ROP(wmfDC* C) -> (U16) ROP mode
*/
#define WMF_DC_BRUSH(C) ((C)->brush)
#define WMF_DC_PEN(C) ((C)->pen)
#define WMF_DC_FONT(C) ((C)->font)
#define WMF_DC_TEXTCOLOR(C) (&((C)->textcolor))
#define WMF_DC_BACKGROUND(C) (&((C)->bgcolor))
#define WMF_DC_OPAQUE(C) ((C)->bgmode - 1)
#define WMF_DC_POLYFILL(C) ((C)->polyfillmode)
#define WMF_DC_ROP(C) ((C)->ROPmode)
</pre>
</font>
<li><a name="Flood"><b>wmfFlood_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfFlood_t wmfFlood_t;
struct _wmfFlood_t
{ wmfDC* dc;
wmfD_Coord pt;
wmfRGB color;
U16 type;
double pixel_width;
double pixel_height;
};
</pre>
</font>
<p>
Flood-fill region with color <tt>color</tt>, starting at point <tt>pt</tt>.
Since this is almost certainly not a vector operation, the pixel width and
height are given (and are probably best ignored...). <tt>type</tt> is one
of:
</p>
<font color=blue>
<pre>
#define FLOODFILLBORDER 0
#define FLOODFILLSURFACE 1
</pre>
</font>
<li><a name="DrawPixel"><b>wmfDrawPixel_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfDrawPixel_t wmfDrawPixel_t;
struct _wmfDrawPixel_t
{ wmfDC* dc;
wmfD_Coord pt;
wmfRGB color;
double pixel_width;
double pixel_height;
};
</pre>
</font>
<p>
Set pixel at point <tt>pt</tt> to color <tt>color</tt>. The pixel width and
height are given.
</p>
<li><a name="DrawArc"><b>wmfDrawArc_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfDrawArc_t wmfDrawArc_t;
struct _wmfDrawArc_t
{ wmfDC* dc;
wmfD_Coord TL;
wmfD_Coord BR;
wmfD_Coord start; /* draw_ellipse: (ignored) */
wmfD_Coord end;
};
</pre>
</font>
<p>
Draw a complete or partial ellipse. <tt>TL</tt> and <tt>BR</tt> are the
coordinates of the top left and bottom right of the ellipse's bounding box
respectively. If incomplete, then <tt>start</tt> and <tt>end</tt> give the
start and end coordinates of the arc.
</p>
<li><a name="DrawLine"><b>wmfDrawLine_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfDrawLine_t wmfDrawLine_t;
struct _wmfDrawLine_t
{ wmfDC* dc;
wmfD_Coord from;
wmfD_Coord to;
};
</pre>
</font>
<p>
Draw line from point <tt>from</tt> to point <tt>to</tt>.
</p>
<li><a name="PolyLine"><b>wmfPolyLine_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfPolyLine_t wmfPolyLine_t;
struct _wmfPolyLine_t
{ wmfDC* dc;
wmfD_Coord* pt;
U16 count;
};
</pre>
</font>
<p>
An array (of length <tt>count</tt>) of points <tt>pt[]</tt>. This may be used
to describe polygons as well as line sequences.
</p>
<li><a name="DrawRect"><b>wmfDrawRectangle_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfDrawRectangle_t wmfDrawRectangle_t;
struct _wmfDrawRectangle_t
{ wmfDC* dc;
wmfD_Coord TL;
wmfD_Coord BR;
float width; /* draw_rectangle: axes of corner ellipses; zero if un-rounded */
float height;
};
</pre>
</font>
<p>
A rectangle, possibly with rounded corners - in which case <tt>width</tt> and
<tt>height</tt> give the elliptic axes of the rectangle's corners.
</p>
<li><a name="PolyRect"><b>wmfPolyRectangle_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfPolyRectangle_t wmfPolyRectangle_t;
struct _wmfPolyRectangle_t
{ wmfDC* dc;
wmfD_Coord* TL; /* region_frame & region_paint: TL[count],BR[count] give the */
wmfD_Coord* BR; /* final `extents'... */
unsigned int count;
float width; /* region_frame: border thickness; zero otherwise */
float height;
};
</pre>
</font>
<p>
Used by region and clip calls, <tt>wmfPolyRectangle_t</tt> is used to describe
multiple rectangles, whose top left and bottom right corners are given by the
<tt>TL</tt> and <tt>BR</tt> arrays respectively. These arrays are of length
<tt>count</tt> in the case of clip calls, and of length <tt>count</tt> + 1 in
the case of the region calls, the extra element containing the overall bounding
box (the region extents). In the case of <tt>region_frame</tt>, <tt>width</tt>
and <tt>height</tt> give the thickness of the frame.
</p>
<li><a name="BMPRead"><b>wmfBMP_Read_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfBMP_Read_t wmfBMP_Read_t;
struct _wmfBMP_Read_t /* Two means available for accessing BMP image: */
{ long offset; /* (1) position in source file of start of BMP; *
* use API->bbuf.seek to set pos(ition), etc. */
long length; /* (2) buffer of length length containing image of BMP */
unsigned char* buffer;
U16 width; /* WMF player may preset these values; zero otherwise. */
U16 height; /* Use caution - may be buggy... ?? [TODO] */
wmfBMP bmp;
};
</pre>
</font>
<p>
There are two ways to read a bitmap presented by <tt>libwmf</tt>: the first is
to read it directly from the input stream using the internal stream functions:
<font color=blue>
<pre>
/* Macro-wrappers for stream functions:
* (int) WMF_READ ((wmfAPI*) API) - returns unsigned char cast to int, or EOF
* (int) WMF_SEEK ((wmfAPI*) API,(long) position) - returns (-1) on error, else 0
* (long) WMF_TELL ((wmfAPI*) API) - returns (-1) on error, else current position
*/
</pre>
</font>
where the bitmap starts at offset <tt>offset</tt>; the second (which is
preferred) is to use the buffer <tt>buffer</tt> of length <tt>length</tt>.
</p>
<p>
To complicate matters, the bitmap's data may be truncated so that the bitmap's
header is incorrect - <tt>width</tt> and <tt>height</tt> give the <i>real</i>
dimensions of the bitmap.
</p>
<p>
The bitmap's width and height should be entered into <tt>bmp</tt> (see
<a href="#BMP">wmfBMP</a> above) as well as a pointer to the bitmap data (which
can be in any format you choose; the library does not need to know).
</p>
<li><a name="BMPDraw"><b>wmfBMP_Draw_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfBMP_Draw_t wmfBMP_Draw_t;
struct _wmfBMP_Draw_t
{ wmfDC* dc;
wmfD_Coord pt;
wmfBMP bmp;
U32 type;
struct
{ U16 x;
U16 y;
U16 w;
U16 h;
} crop;
double pixel_width;
double pixel_height;
};
</pre>
</font>
<p>
In contrast to earlier versions, <tt>libwmf</tt> no longer makes any attempt to
crop or scale the bitmap. Instead the crop data are presented to the device
layer to use as it sees fit, and the pixel width and height as well. The bitmap
referenced by <tt>bmp</tt> (see <a href="#BMP">wmfBMP</a> above) is to be drawn
at point <tt>pt</tt>.
</p>
<p>
<i><b>TODO:</b> info on <tt>type</tt></i>
</p>
<li><a name="ROPDraw"><b>wmfROP_Draw_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfROP_Draw_t wmfROP_Draw_t;
struct _wmfROP_Draw_t
{ wmfDC* dc;
wmfD_Coord TL;
wmfD_Coord BR;
U32 ROP;
double pixel_width;
double pixel_height;
};
</pre>
</font>
<p>
<i><b>TODO:</b></i>
</p>
<li><a name="DrawText"><b>wmfDrawText_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfDrawText_t wmfDrawText_t;
struct _wmfDrawText_t
{ wmfDC* dc;
wmfD_Coord pt;
wmfD_Coord TL; /* Clip zone */
wmfD_Coord BR;
struct /* An estimated surround zone */
{ wmfD_Coord TL;
wmfD_Coord TR;
wmfD_Coord BL;
wmfD_Coord BR;
} bbox;
char* str;
U16 flags;
double font_height;
double font_ratio; /* width to height ratio */
};
</pre>
</font>
<p>
Fonts and text are <i>triiicky</i>! Fortunately <tt>libwmf</tt> tries to do
most of the work. As such text justification is taken care of by the
interpreter, and fonts (<b>bold</b>, <i>italic</i>, etc.) are selected
elsewhere. The emphasis with <tt>wmfDrawText_t</tt> is therefore the rendering
of text.
</p>
<p>
The text can be assumed to be left-justified, starting at point <tt>pt</tt>.
<tt>TL</tt> and <tt>BR</tt> are the corners of a clip rectangle. <tt>bbox</tt>
gives four corners of rectangle - an <i>estimate</i> of the background zone.
<tt>str</tt> is the text to draw; <tt>font_height</tt> is the height of the
font and <tt>font_ratio</tt> is how much to stretch the font width-wise. The
values for <tt>flags</tt> are:
</p>
<font color=blue>
<pre>
#define ETO_OPAQUE 0x0002
#define ETO_CLIPPED 0x0004
#define ETO_GLYPH_INDEX 0x0010
#define ETO_RTLREADING 0x0080
</pre>
</font>
<li><a name="UserData"><b>wmfUserData_t</b></a>
<font color=blue>
<pre>
typedef struct _wmfUserData_t wmfUserData_t;
struct _wmfUserData_t /* TODO: Need to be careful with usage here; not all these are set by the player! */
{ wmfDC* dc; /* dc is guaranteed */
void* data; /* data also, except for init */
};
</pre>
</font>
<p>
Redundant; may be removed at some point...
</p>
<li><a name="CharDrawer"><b>wmfCharDrawer</b></a>
<font color=blue>
<pre>
typedef void (*wmfCharDrawer) (wmfAPI*,wmfDrawText_t*);
</pre>
</font>
</ul>
<a name="ipafnref"><h2>IPA Function Reference</h2></a>
<p>
Let us assume that you are writing a device layer called <i>mydev</i>, then the
first requirement is an initialization function:
</p>
<font color=blue>
<pre>
#include <libwmf/ipa.h>
#include <libwmf/defs.h>
#include <libwmf/<i>mydev</i>.h>
void wmf_<i>mydev</i>_function (wmfAPI* API)
{ wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference;
/* */
</pre>
</font>
The function reference has the following definition:
<font color=blue>
<pre>
typedef struct _wmfFunctionReference wmfFunctionReference;
struct _wmfFunctionReference
{ void (*device_open) (wmfAPI*);
void (*device_close) (wmfAPI*);
void (*device_begin) (wmfAPI*);
void (*device_end) (wmfAPI*);
void (*flood_interior) (wmfAPI*,wmfFlood_t*);
void (*flood_exterior) (wmfAPI*,wmfFlood_t*);
void (*draw_pixel) (wmfAPI*,wmfDrawPixel_t*);
void (*draw_pie) (wmfAPI*,wmfDrawArc_t*);
void (*draw_chord) (wmfAPI*,wmfDrawArc_t*);
void (*draw_arc) (wmfAPI*,wmfDrawArc_t*);
void (*draw_ellipse) (wmfAPI*,wmfDrawArc_t*);
void (*draw_line) (wmfAPI*,wmfDrawLine_t*);
void (*poly_line) (wmfAPI*,wmfPolyLine_t*);
void (*draw_polygon) (wmfAPI*,wmfPolyLine_t*);
void (*draw_rectangle) (wmfAPI*,wmfDrawRectangle_t*);
void (*rop_draw) (wmfAPI*,wmfROP_Draw_t*);
void (*bmp_draw) (wmfAPI*,wmfBMP_Draw_t*);
void (*bmp_read) (wmfAPI*,wmfBMP_Read_t*);
void (*bmp_free) (wmfAPI*,wmfBMP*);
void (*draw_text) (wmfAPI*,wmfDrawText_t*);
void (*udata_init) (wmfAPI*,wmfUserData_t*);
void (*udata_copy) (wmfAPI*,wmfUserData_t*);
void (*udata_set) (wmfAPI*,wmfUserData_t*);
void (*udata_free) (wmfAPI*,wmfUserData_t*);
void (*region_frame) (wmfAPI*,wmfPolyRectangle_t*);
void (*region_paint) (wmfAPI*,wmfPolyRectangle_t*);
void (*region_clip) (wmfAPI*,wmfPolyRectangle_t*);
};
</pre>
</font>
<p>
The initialization function has two purposes, the first being to establish the
links that create the <b>IPA</b> by pointing the function reference variables
to your own drawing functions:
</p>
<font color=blue>
<pre>
#include <libwmf/ipa.h>
#include <libwmf/defs.h>
#include <libwmf/<i>mydev</i>.h>
void wmf_<i>mydev</i>_function (wmfAPI* API)
{ wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference;
FR->device_open = wmf_<i>mydev</i>_device_open;
FR->device_close = wmf_<i>mydev</i>_device_close;
FR->device_begin = wmf_<i>mydev</i>_device_begin;
FR->device_end = wmf_<i>mydev</i>_device_end;
/* etc. */
/* */
}
void wmf_<i>mydev</i>_device_open (wmfAPI* API)
{ /* */
}
/* etc. */
</pre>
</font>
<p>
The second purpose of the initialization function is to allocate the device's
data structure, set the device parameters to default values if necessary, and
then to attach the data to the <tt>API->device_data</tt> hook.
</p>
<font color=blue>
<pre>
/* */
typedef struct _wmf_<i>mydev</i>_t wmf_<i>mydev</i>_t;
struct _wmf_<i>mydev</i>_t
{ /* */
unsigned long flags;
}
void wmf_<i>mydev</i>_function (wmfAPI* API)
{ wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference;
wmf_<i>mydev</i>_t* ddata = 0;
FR->device_open = wmf_<i>mydev</i>_device_open;
/* etc. */
API->device_data = wmf_malloc (API,sizeof (wmf_<i>mydev</i>_t));
if (API->err != wmf_E_None) return; /* insufficient memory? */
ddata = (wmf_<i>mydev</i>_t*) API->device_data;
/* */
ddata->flags = 0;
}
/* */
</pre>
</font>
<a name="ipafns"><h2>IPA Functions</h2></a>
<p>
The <b>IPA</b> functions are called by <tt>wmf_play ()</tt>, the only exception
being <tt>device_close</tt> which is called by <tt>wmf_api_destroy ()</tt> -
and then only if <tt>device_open</tt> has been called by <tt>wmf_play ()</tt>.
</p>
<p>
<tt>device_open</tt> is called the first time (and <i>only</i> the first time)
<tt>wmf_play ()</tt> is called, and is the very first <b>IPA</b> function to be
called, just as <tt>device_close</tt> will be the very last.
</p>
<p>
At the beginning of each <i>play</i> cycle (i.e., each call to
<tt>wmf_play ()</tt>) <tt>device_begin</tt> is called (after
<tt>device_open</tt> if it is the first cycle), and at the end of each cycle
<tt>device_end</tt> is called. The metafile graphics use other <b>IPA</b>
functions.
</p>
<p>
<tt>device_open</tt>, <tt>device_begin</tt>, <tt>device_end</tt> and
<tt>device_close</tt> <i>should</i> be written so that <tt>wmf_play ()</tt> can
be called repeatedly.
</p>
<p>
The names of the functions are not important. The generic names are used below:
</p>
<a href="#devopen">device_open</a>
| <a href="#devclose">device_close</a>
| <a href="#devbegin">device_begin</a>
| <a href="#devend">device_end</a>
| <a href="#floodint">flood_interior</a>
| <a href="#floodext">flood_exterior</a>
| <a href="#dpixel">draw_pixel</a>
| <a href="#dpie">draw_pie</a>
| <a href="#dchord">draw_chord</a>
| <a href="#darc">draw_arc</a>
| <a href="#dellipse">draw_ellipse</a>
| <a href="#dline">draw_line</a>
| <a href="#pline">poly_line</a>
| <a href="#dpoly">draw_polygon</a>
| <a href="#drect">draw_rectangle</a>
| <a href="#ropdraw">rop_draw</a>
| <a href="#bmpdraw">bmp_draw</a>
| <a href="#bmpread">bmp_read</a>
| <a href="#bmpfree">bmp_free</a>
| <a href="#dtext">draw_text</a>
| <a href="#uinit">udata_init</a>
| <a href="#ucopy">udata_copy</a>
| <a href="#uset">udata_set</a>
| <a href="#ufree">udata_free</a>
| <a href="#rframe">region_frame</a>
| <a href="#rpaint">region_paint</a>
| <a href="#rclip">region_clip</a>
<ul>
<li><a name="devopen"><b>device_open</b></a>
<font color=blue>
<pre>
void device_open (wmfAPI*);
</pre>
</font>
<p>
<tt>device_open</tt> is the very first <b>IPA</b> function to be called. It is
called only once, the first time <tt>wmf_play ()</tt> is called.
</p>
<li><a name="devclose"><b>device_close</b></a>
<font color=blue>
<pre>
void device_close (wmfAPI*);
</pre>
</font>
<p>
<tt>device_close</tt> is the very last <b>IPA</b> function to be called. It is
called by <tt>wmf_api_destroy ()</tt>, and only if <tt>device_open</tt> has
been called earlier.
</p>
<li><a name="devbegin"><b>device_begin</b></a>
<font color=blue>
<pre>
void device_begin (wmfAPI*);
</pre>
</font>
<p>
<tt>device_begin</tt> is the first <b>IPA</b> function called from
<tt>wmf_play ()</tt> (with the exception of <tt>device_open</tt> the first time
<tt>wmf_play ()</tt> is called).
</p>
<li><a name="devend"><b>device_end</b></a>
<font color=blue>
<pre>
void device_end (wmfAPI*);
</pre>
</font>
<p>
<tt>device_end</tt> is the last <b>IPA</b> function called from
<tt>wmf_play ()</tt>.
</p>
<li><a name="floodint"><b>flood_interior</b></a>
<font color=blue>
<pre>
void flood_interior (wmfAPI*,<a href="#Flood">wmfFlood_t</a>*);
</pre>
</font>
<li><a name="floodext"><b>flood_exterior</b></a>
<font color=blue>
<pre>
void flood_exterior (wmfAPI*,<a href="#Flood">wmfFlood_t</a>*);
</pre>
</font>
<li><a name="dpixel"><b>draw_pixel</b></a>
<font color=blue>
<pre>
void draw_pixel (wmfAPI*,<a href="#DrawPixel">wmfDrawPixel_t</a>*);
</pre>
</font>
<li><a name="dpie"><b>draw_pie</b></a>
<font color=blue>
<pre>
void draw_pie (wmfAPI*,<a href="#DrawArc">wmfDrawArc_t</a>*);
</pre>
</font>
<li><a name="dchord"><b>draw_chord</b></a>
<font color=blue>
<pre>
void draw_chord (wmfAPI*,<a href="#DrawArc">wmfDrawArc_t</a>*);
</pre>
</font>
<li><a name="darc"><b>draw_arc</b></a>
<font color=blue>
<pre>
void draw_arc (wmfAPI*,<a href="#DrawArc">wmfDrawArc_t</a>*);
</pre>
</font>
<li><a name="dellipse"><b>draw_ellipse</b></a>
<font color=blue>
<pre>
void draw_ellipse (wmfAPI*,<a href="#DrawArc">wmfDrawArc_t</a>*);
</pre>
</font>
<li><a name="dline"><b>draw_line</b></a>
<font color=blue>
<pre>
void draw_line (wmfAPI*,<a href="#DrawLine">wmfDrawLine_t</a>*);
</pre>
</font>
<li><a name="pline"><b>poly_line</b></a>
<font color=blue>
<pre>
void poly_line (wmfAPI*,<a href="#PolyLine">wmfPolyLine_t</a>*);
</pre>
</font>
<li><a name="dpoly"><b>draw_polygon</b></a>
<font color=blue>
<pre>
void draw_polygon (wmfAPI*,<a href="#PolyLine">wmfPolyLine_t</a>*);
</pre>
</font>
<li><a name="drect"><b>draw_rectangle</b></a>
<font color=blue>
<pre>
void draw_rectangle (wmfAPI*,<a href="#DrawRect">wmfDrawRectangle_t</a>*);
</pre>
</font>
<li><a name="ropdraw"><b>rop_draw</b></a>
<font color=blue>
<pre>
void rop_draw (wmfAPI*,<a href="#ROPDraw">wmfROP_Draw_t</a>*);
</pre>
</font>
<p>
<i><b>TODO:</b></i>
</p>
<li><a name="bmpdraw"><b>bmp_draw</b></a>
<font color=blue>
<pre>
void bmp_draw (wmfAPI*,<a href="#BMPDraw">wmfBMP_Draw_t</a>*);
</pre>
</font>
<p>
<b>Note:</b> Unless you're feeling masochistic and want to write, or re-write,
your own suite of functions for the reading, writing and general manipulation
of bitmaps, you should defer this to <tt>libwmf</tt>'s built-in support which
is adapted from <tt>ImageMagick</tt>'s excellent BMP coder.
</p>
<p>
See section on bitmaps below.
</p>
<li><a name="bmpread"><b>bmp_read</b></a>
<font color=blue>
<pre>
void bmp_read (wmfAPI*,<a href="#BMPRead">wmfBMP_Read_t</a>*);
</pre>
</font>
<p>
<b>Note:</b> Unless you're feeling masochistic and want to write, or re-write,
your own suite of functions for the reading, writing and general manipulation
of bitmaps, you should defer this to <tt>libwmf</tt>'s built-in support which
is adapted from <tt>ImageMagick</tt>'s excellent BMP coder.
</p>
<font color=blue>
<pre>
void bmp_read (wmfAPI* API,<a href="#BMPRead">wmfBMP_Read_t</a>* bmp_read)
{ wmf_ipa_bmp_read (API,bmp_read);
}
</pre>
</font>
<li><a name="bmpfree"><b>bmp_free</b></a>
<font color=blue>
<pre>
void bmp_free (wmfAPI*,<a href="#BMP">wmfBMP</a>*);
</pre>
</font>
<p>
<b>Note:</b> Unless you're feeling masochistic and want to write, or re-write,
your own suite of functions for the reading, writing and general manipulation
of bitmaps, you should defer this to <tt>libwmf</tt>'s built-in support which
is adapted from <tt>ImageMagick</tt>'s excellent BMP coder.
</p>
<font color=blue>
<pre>
void bmp_free (wmfAPI* API,<a href="#BMP">wmfBMP</a>* bmp)
{ wmf_ipa_bmp_free (API,bmp);
}
</pre>
</font>
<li><a name="dtext"><b>draw_text</b></a>
<font color=blue>
<pre>
void draw_text (wmfAPI*,<a href="#DrawText">wmfDrawText_t</a>*);
</pre>
</font>
<p>
If desired, strings can be decomposed into individual chars using
<tt>wmf_ipa_draw_text ()</tt>. Best to see source for the various device layers
in <tt>libwmf</tt>.
</p>
<li><a name="uinit"><b>udata_init</b></a>
<font color=blue>
<pre>
void udata_init (wmfAPI*,<a href="#UserData">wmfUserData_t</a>*);
</pre>
</font>
<p>
Redundant; may be removed at some point...
</p>
<li><a name="ucopy"><b>udata_copy</b></a>
<font color=blue>
<pre>
void udata_copy (wmfAPI*,<a href="#UserData">wmfUserData_t</a>*);
</pre>
</font>
<p>
Redundant; may be removed at some point...
</p>
<li><a name="uset"><b>udata_set</b></a>
<font color=blue>
<pre>
void udata_set (wmfAPI*,<a href="#UserData">wmfUserData_t</a>*);
</pre>
</font>
<p>
Redundant; may be removed at some point...
</p>
<li><a name="ufree"><b>udata_free</b></a>
<font color=blue>
<pre>
void udata_free (wmfAPI*,<a href="#UserData">wmfUserData_t</a>*);
</pre>
</font>
<p>
Redundant; may be removed at some point...
</p>
<li><a name="rframe"><b>region_frame</b></a>
<font color=blue>
<pre>
void region_frame (wmfAPI*,<a href="#PolyRect">wmfPolyRectangle_t</a>*);
</pre>
</font>
<li><a name="rpaint"><b>region_paint</b></a>
<font color=blue>
<pre>
void region_paint (wmfAPI*,<a href="#PolyRect">wmfPolyRectangle_t</a>*);
</pre>
</font>
<li><a name="rclip"><b>region_clip</b></a>
<font color=blue>
<pre>
void region_clip (wmfAPI*,<a href="#PolyRect">wmfPolyRectangle_t</a>*);
</pre>
</font>
<p>
If the number of clip rectangles is zero, the current clip region should be
unset.
</p>
</ul>
<a name="bitmap"><h2>Bitmap Functions</h2></a>
<a name="fns"><h2>Other Functions</h2></a>
<a name="guide"><h2>Guidelines</h2></a>
<a name="compile"><h2>Compiling - The Distribution</h2></a>
<p>
The section applies only if you are working on the <tt>libwmf</tt> sources.
</p>
<p>
The build system uses <b>automake</b> and <b>autoconf</b>. If any changes are
made to any of the various <tt>Makefile.am</tt> files, or to
<tt>configure.in</tt> or <tt>libwmf.m4</tt>, then the build system will need to
be updated. Change to the top source directory (containing
<tt>configure.in</tt> and <tt>libwmf.m4</tt>) and:
</p>
<font color=blue>
<pre>
# aclocal
# automake
# autoheader
# autoconf
# date > stamp-h.in
</pre>
</font>
<p>
When adding a new device layer, <tt>include/libwmf/Makefile.am</tt> and
<tt>src/ipa/Makefile.am</tt> will need to be modifiled. Source files
(<tt>src/ipa/new.c</tt>) and installing header files
(<tt>include/libwmf/new.h</tt>) do not need to be added to the distribution,
but other headers (<tt>src/ipa/new.h</tt> & <tt>src/ipa/new/*.h</tt>) will.
</p>
<hr>
<address>
Copyright 2001 wvWare/libwmf <a href="http://www.wvware.com/">http://www.wvware.com/</a>
</address>
</body>
</html>
|