1 /* libwmf (<libwmf/ipa.h>): library for wmf conversion 2 Copyright (C) 2000 - various; see CREDITS, ChangeLog, and sources 3 4 The libwmf Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public License as 6 published by the Free Software Foundation; either version 2 of the 7 License, or (at your option) any later version. 8 9 The libwmf Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public 15 License along with the libwmf Library; see the file COPYING. If not, 16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Boston, MA 02111-1307, USA. */ 18 19 20 /* Interface Programmable des Applications ?? 21 */ 22 #ifndef LIBWMF_IPA_H 23 #define LIBWMF_IPA_H 24 25 #include <libwmf/types.h> 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 /* Type declarations 32 */ 33 typedef struct _wmfRGB wmfRGB; 34 typedef struct _wmfBMP wmfBMP; 35 36 typedef struct _wmfBrush wmfBrush; 37 typedef struct _wmfPen wmfPen; 38 typedef struct _wmfFont wmfFont; 39 40 typedef struct _wmfFontData wmfFontData; 41 typedef struct _wmfColorData wmfColorData; 42 43 typedef struct _wmfDC wmfDC; 44 45 typedef struct _wmfFlood_t wmfFlood_t; 46 typedef struct _wmfDrawPixel_t wmfDrawPixel_t; 47 typedef struct _wmfDrawArc_t wmfDrawArc_t; 48 typedef struct _wmfDrawLine_t wmfDrawLine_t; 49 typedef struct _wmfPolyLine_t wmfPolyLine_t; 50 typedef struct _wmfPolyPoly_t wmfPolyPoly_t; 51 typedef struct _wmfDrawRectangle_t wmfDrawRectangle_t; 52 typedef struct _wmfPolyRectangle_t wmfPolyRectangle_t; 53 typedef struct _wmfBMP_Read_t wmfBMP_Read_t; 54 typedef struct _wmfBMP_Draw_t wmfBMP_Draw_t; 55 typedef struct _wmfROP_Draw_t wmfROP_Draw_t; 56 typedef struct _wmfDrawText_t wmfDrawText_t; 57 typedef struct _wmfUserData_t wmfUserData_t; 58 59 typedef struct _wmfFunctionReference wmfFunctionReference; 60 61 typedef float (*wmfStringWidth) (wmfAPI*,wmfFont*,char*); 62 typedef void (*wmfMap) (wmfAPI*,wmfFont*); 63 64 /* Device-layer device-independent default functions 65 */ 66 extern void wmf_ipa_bmp_b64 (wmfAPI*,wmfBMP_Draw_t*,wmfStream*); 67 extern void wmf_ipa_bmp_png (wmfAPI*,wmfBMP_Draw_t*,char*); 68 extern void wmf_ipa_bmp_jpg (wmfAPI*,wmfBMP_Draw_t*,char*); 69 extern void wmf_ipa_bmp_eps (wmfAPI*,wmfBMP_Draw_t*,char*); 70 extern void wmf_ipa_bmp_read (wmfAPI*,wmfBMP_Read_t*); 71 extern void wmf_ipa_bmp_free (wmfAPI*,wmfBMP*); 72 extern wmfBMP wmf_ipa_bmp_copy (wmfAPI*,wmfBMP*,unsigned int,unsigned int); 73 extern int wmf_ipa_bmp_color (wmfAPI*,wmfBMP*,wmfRGB*,unsigned int,unsigned int); 74 extern void wmf_ipa_bmp_setcolor (wmfAPI*,wmfBMP*,wmfRGB*,unsigned char,unsigned int,unsigned int); 75 extern int wmf_ipa_bmp_interpolate (wmfAPI*,wmfBMP*,wmfRGB*,float,float); 76 77 extern void wmf_ipa_color_init (wmfAPI*); 78 extern void wmf_ipa_color_add (wmfAPI*,wmfRGB*); 79 extern unsigned long wmf_ipa_color_index (wmfAPI*,wmfRGB*); 80 extern unsigned long wmf_ipa_color_count (wmfAPI*); 81 extern wmfRGB* wmf_ipa_color (wmfAPI*,unsigned long); 82 83 extern char* wmf_ipa_page_format (wmfAPI*,wmf_page_t); 84 extern unsigned int wmf_ipa_page_width (wmfAPI*,wmf_page_t); 85 extern unsigned int wmf_ipa_page_height (wmfAPI*,wmf_page_t); 86 87 /* Other useful functions 88 */ 89 extern wmfRGB wmf_rgb_white (void); 90 extern wmfRGB wmf_rgb_black (void); 91 extern wmfRGB wmf_rgb_color (wmfAPI*,float,float,float); 92 93 /* Structure definitions 94 */ 95 struct _wmfRGB 96 { unsigned char r; 97 unsigned char g; 98 unsigned char b; 99 }; 100 101 struct _wmfBMP 102 { U16 width; 103 U16 height; 104 105 void* data; 106 }; 107 108 struct _wmfPen 109 { U16 lopnStyle; 110 111 double width; 112 double height; 113 114 wmfRGB lopnColor; 115 }; 116 117 struct _wmfBrush 118 { U16 lbStyle; 119 U16 lbHatch; 120 121 wmfRGB lbColor; 122 wmfBMP bmp; 123 }; 124 125 struct _wmfFont 126 { U16 lfHeight; 127 U16 lfWidth; 128 129 S16 lfEscapement; 130 S16 lfOrientation; 131 132 U16 lfWeight; 133 134 U8 lfItalic; 135 U8 lfUnderline; 136 U8 lfStrikeOut; 137 U8 lfCharSet; 138 U8 lfOutPrecision; 139 U8 lfClipPrecision; 140 U8 lfQuality; 141 U8 lfPitchAndFamily; 142 143 char* lfFaceName; 144 145 void* user_data; 146 }; 147 148 /** 149 * API->font_data is a pointer to a wmfFontData. wmf_api_create () sets this up automatically, but 150 * wmf_lite_create () does not. If you use wmf_lite_create () then you \b must create your own 151 * wmfFontData. \b libwmflite requires you to define \p map and \p stringwidth functions but the 152 * rest of these fields are ignored (they are only used by \b libwmf). 153 */ 154 struct _wmfFontData 155 { /** 156 * Necessary field: exactly what the function does is irrelevant. 157 */ 158 wmfMap map; 159 160 /** 161 * Necessary field: returns width of specified string in points, assuming (unstretched) 162 * font size of 1pt. 163 */ 164 wmfStringWidth stringwidth; 165 166 /** 167 * A handle for data, unused by libwmflite 168 */ 169 void* user_data; 170 }; 171 172 struct _wmfColorData 173 { unsigned long max; 174 unsigned long count; 175 176 wmfRGB* rgb; 177 }; 178 179 struct _wmfDC 180 { void* userdata; 181 182 wmfBrush* brush; 183 wmfPen* pen; 184 wmfFont* font; 185 186 wmfRGB textcolor; 187 wmfRGB bgcolor; 188 189 U16 textalign; 190 U16 bgmode; 191 U16 polyfillmode; 192 U16 charextra; 193 U16 breakextra; 194 195 U16 ROPmode; 196 197 struct 198 { S32 Ox; 199 S32 Oy; 200 S32 width; 201 S32 height; 202 } Window; 203 204 double pixel_width; /* Display pixel dimensions (inches) */ 205 double pixel_height; 206 207 U16 map_mode; 208 209 void* clip; 210 }; 211 212 /* IPA info structures 213 */ 214 struct _wmfFlood_t 215 { wmfDC* dc; 216 217 wmfD_Coord pt; 218 wmfRGB color; 219 220 U16 type; 221 222 double pixel_width; 223 double pixel_height; 224 }; 225 226 struct _wmfDrawPixel_t 227 { wmfDC* dc; 228 229 wmfD_Coord pt; 230 wmfRGB color; 231 232 double pixel_width; 233 double pixel_height; 234 }; 235 236 struct _wmfDrawArc_t 237 { wmfDC* dc; 238 239 wmfD_Coord TL; 240 wmfD_Coord BR; 241 242 wmfD_Coord start; /* draw_ellipse: (ignored) */ 243 wmfD_Coord end; 244 }; 245 246 struct _wmfDrawLine_t 247 { wmfDC* dc; 248 249 wmfD_Coord from; 250 wmfD_Coord to; 251 }; 252 253 struct _wmfPolyLine_t 254 { wmfDC* dc; 255 256 wmfD_Coord* pt; 257 258 U16 count; 259 }; 260 261 struct _wmfPolyPoly_t 262 { wmfDC* dc; 263 264 wmfD_Coord** pt; /* pt[i][*] = points of ith polygon */ 265 266 U16* count; /* points in ith polygon */ 267 U16 npoly; /* number of polygons */ 268 }; 269 270 struct _wmfDrawRectangle_t 271 { wmfDC* dc; 272 273 wmfD_Coord TL; 274 wmfD_Coord BR; 275 276 float width; /* draw_rectangle: axes of corner ellipses; zero if un-rounded */ 277 float height; 278 }; 279 280 struct _wmfPolyRectangle_t 281 { wmfDC* dc; 282 283 wmfD_Coord* TL; /* region_frame & region_paint: TL[count],BR[count] give the */ 284 wmfD_Coord* BR; /* final `extents'... */ 285 286 unsigned int count; 287 288 float width; /* region_frame: border thickness; zero otherwise */ 289 float height; 290 }; 291 292 struct _wmfBMP_Read_t /* Two means available for accessing BMP image: */ 293 { long offset; /* (1) position in source file of start of BMP; * 294 * use API->bbuf.seek to set pos(ition), etc. */ 295 long length; /* (2) buffer of length length containing image of BMP */ 296 unsigned char* buffer; 297 298 U16 width; /* WMF player may preset these values; zero otherwise. */ 299 U16 height; /* Use caution - may be buggy... ?? [TODO] */ 300 301 wmfBMP bmp; 302 }; 303 304 struct _wmfBMP_Draw_t 305 { wmfDC* dc; 306 307 wmfD_Coord pt; 308 wmfBMP bmp; 309 310 U32 type; 311 312 struct 313 { U16 x; 314 U16 y; 315 U16 w; 316 U16 h; 317 } crop; 318 319 double pixel_width; 320 double pixel_height; 321 }; 322 323 struct _wmfROP_Draw_t 324 { wmfDC* dc; 325 326 wmfD_Coord TL; 327 wmfD_Coord BR; 328 329 U32 ROP; 330 331 double pixel_width; 332 double pixel_height; 333 }; 334 335 struct _wmfDrawText_t 336 { wmfDC* dc; 337 338 wmfD_Coord pt; 339 340 wmfD_Coord TL; /* Clip zone */ 341 wmfD_Coord BR; 342 343 struct /* An estimated surround zone */ 344 { wmfD_Coord TL; 345 wmfD_Coord TR; 346 wmfD_Coord BL; 347 wmfD_Coord BR; 348 } bbox; 349 350 char* str; 351 352 U16 flags; 353 354 double font_height; 355 double font_ratio; /* width to height ratio */ 356 }; 357 358 struct _wmfUserData_t /* TODO: Need to be careful with usage here; not all these are set by the player! */ 359 { wmfDC* dc; /* dc is guaranteed */ 360 361 void* data; /* data also, except for init */ 362 }; 363 364 struct _wmfFunctionReference 365 { void (*device_open) (wmfAPI*); 366 void (*device_close) (wmfAPI*); 367 void (*device_begin) (wmfAPI*); 368 void (*device_end) (wmfAPI*); 369 370 void (*flood_interior) (wmfAPI*,wmfFlood_t*); 371 void (*flood_exterior) (wmfAPI*,wmfFlood_t*); 372 373 void (*draw_pixel) (wmfAPI*,wmfDrawPixel_t*); 374 void (*draw_pie) (wmfAPI*,wmfDrawArc_t*); 375 void (*draw_chord) (wmfAPI*,wmfDrawArc_t*); 376 void (*draw_arc) (wmfAPI*,wmfDrawArc_t*); 377 void (*draw_ellipse) (wmfAPI*,wmfDrawArc_t*); 378 void (*draw_line) (wmfAPI*,wmfDrawLine_t*); 379 void (*poly_line) (wmfAPI*,wmfPolyLine_t*); 380 void (*draw_polygon) (wmfAPI*,wmfPolyLine_t*); 381 void (*draw_polypolygon) (wmfAPI*,wmfPolyPoly_t*); 382 void (*draw_rectangle) (wmfAPI*,wmfDrawRectangle_t*); 383 384 void (*rop_draw) (wmfAPI*,wmfROP_Draw_t*); 385 void (*bmp_draw) (wmfAPI*,wmfBMP_Draw_t*); 386 void (*bmp_read) (wmfAPI*,wmfBMP_Read_t*); 387 void (*bmp_free) (wmfAPI*,wmfBMP*); 388 389 void (*draw_text) (wmfAPI*,wmfDrawText_t*); 390 391 void (*udata_init) (wmfAPI*,wmfUserData_t*); 392 void (*udata_copy) (wmfAPI*,wmfUserData_t*); 393 void (*udata_set) (wmfAPI*,wmfUserData_t*); 394 void (*udata_free) (wmfAPI*,wmfUserData_t*); 395 396 void (*region_frame) (wmfAPI*,wmfPolyRectangle_t*); 397 void (*region_paint) (wmfAPI*,wmfPolyRectangle_t*); 398 void (*region_clip) (wmfAPI*,wmfPolyRectangle_t*); 399 }; 400 401 #ifdef __cplusplus 402 } 403 #endif 404 405 #endif /* ! LIBWMF_IPA_H */ 406