📄 meta.h
字号:
/* libwmf ("player/meta.h"): library for wmf conversion Copyright (C) 2000 - various; see CREDITS, ChangeLog, and sources The libwmf Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The libwmf Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the libwmf Library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#ifndef WMFPLAYER_META_H#define WMFPLAYER_META_Hstatic int meta_mapmode (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; U16 par_U16; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 0",Record->size); } par_U16 = ParU16 (API,Record,0); WmfSetMapMode (API,par_U16); return (changed);}static int meta_orgext (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data; S32 par_S32_x; S32 par_S32_y; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 1",Record->size); } par_S32_x = ParS32 (API,Record,1); par_S32_y = ParS32 (API,Record,0); switch (Record->function) { case META_SETWINDOWORG: P->dc->Window.Ox = par_S32_x; P->dc->Window.Oy = par_S32_y; break; case META_SETVIEWPORTORG: P->Viewport_Origin.x = (float) ((double) par_S32_x * P->dc->pixel_width ); P->Viewport_Origin.y = (float) ((double) par_S32_y * P->dc->pixel_height); break; case META_SETVIEWPORTEXT: P->Viewport_Width = par_S32_x; P->Viewport_Height = par_S32_y; PixelWidth (API); PixelHeight (API); /* Recalculate pixel size */ break; case META_SETWINDOWEXT: P->dc->Window.width = par_S32_x; P->dc->Window.height = par_S32_y; PixelWidth (API); PixelHeight (API); /* Recalculate pixel size */ break; case META_OFFSETWINDOWORG: P->dc->Window.Ox += par_S32_x; P->dc->Window.Oy += par_S32_y; break; case META_OFFSETVIEWPORTORG: P->Viewport_Origin.x += (float) ((double) par_S32_x * P->dc->pixel_width ); P->Viewport_Origin.y += (float) ((double) par_S32_y * P->dc->pixel_height); break; default: WMF_ERROR (API,"libwmf: erk! programmer's error..."); WMF_ERROR (API," please contact us at http://www.wvware.com/"); API->err = wmf_E_Glitch; break; } return (changed);}static int meta_scale (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data; S32 par_S32_x1; S32 par_S32_x2; S32 par_S32_y1; S32 par_S32_y2; double x1; double x2; double y1; double y2; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 3",Record->size); } par_S32_x2 = ParS32 (API,Record,3); par_S32_x1 = ParS32 (API,Record,2); par_S32_y2 = ParS32 (API,Record,1); par_S32_y1 = ParS32 (API,Record,0); if ((par_S32_x1 == 0) || (par_S32_y1 == 0)) { WMF_ERROR (API,"meta file attempts division by zero!"); API->err = wmf_E_BadFormat; return (changed); } x2 = (double) par_S32_x2; x1 = (double) par_S32_x1; y2 = (double) par_S32_y2; y1 = (double) par_S32_y1; switch (Record->function) { case META_SCALEWINDOWEXT: P->dc->Window.width = (S32) (((double) P->dc->Window.width * x2) / x1); P->dc->Window.height = (S32) (((double) P->dc->Window.height * y2) / y1); break; case META_SCALEVIEWPORTEXT: P->Viewport_Width = (S32) (((double) P->Viewport_Width * x2) / x1); P->Viewport_Height = (S32) (((double) P->Viewport_Height * y2) / y1); break; default: WMF_ERROR (API,"libwmf: erk! programmer's error..."); WMF_ERROR (API," please contact us at http://www.wvware.com/"); API->err = wmf_E_Glitch; break; } PixelWidth (API); PixelHeight (API); /* Recalculate pixel size */ return (changed);}static int meta_moveto (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data; U16 par_U16_x; U16 par_U16_y; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 1",Record->size); } par_U16_x = ParU16 (API,Record,1); par_U16_y = ParU16 (API,Record,0); P->current = L_Coord (API,par_U16_x,par_U16_y); return (changed);}static int meta_flood (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data; wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference; wmfL_Coord l_pt; wmfFlood_t flood; U16 par_U16_x; U16 par_U16_y; U16 par_U16_rg; U16 par_U16_b; U16 par_U16_t; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 4",Record->size); } par_U16_x = ParU16 (API,Record,4); par_U16_y = ParU16 (API,Record,3); par_U16_b = ParU16 (API,Record,2); par_U16_rg = ParU16 (API,Record,1); par_U16_t = ParU16 (API,Record,0); l_pt = L_Coord (API,par_U16_x,par_U16_y); flood.pt = wmf_D_Coord_translate (API,l_pt); flood.color = rgb (API,par_U16_rg,par_U16_b); if (SCAN (API)) { wmf_ipa_color_add (API,&(flood.color)); D_Coord_Register (API,flood.pt,0); return (changed); } flood.dc = P->dc; flood.type = par_U16_t; flood.pixel_width = ABS (P->dc->pixel_width ); flood.pixel_height = ABS (P->dc->pixel_height); switch (Record->function) { case META_FLOODFILL: if (FR->flood_interior) FR->flood_interior (API,&flood); break; case META_EXTFLOODFILL: if (FR->flood_exterior) FR->flood_exterior (API,&flood); break; default: WMF_ERROR (API,"libwmf: erk! programmer's error..."); WMF_ERROR (API," please contact us at http://www.wvware.com/"); API->err = wmf_E_Glitch; break; } return (changed);}static int meta_pixel (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data; wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference; wmfL_Coord l_pt; wmfDrawPixel_t drawpixel; U16 par_U16_x; U16 par_U16_y; U16 par_U16_rg; U16 par_U16_b; float scope; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 3",Record->size); } par_U16_x = ParU16 (API,Record,3); par_U16_y = ParU16 (API,Record,2); par_U16_b = ParU16 (API,Record,1); par_U16_rg = ParU16 (API,Record,0); l_pt = L_Coord (API,par_U16_x,par_U16_y); drawpixel.pt = wmf_D_Coord_translate (API,l_pt); drawpixel.color = rgb (API,par_U16_rg,par_U16_b); drawpixel.pixel_width = ABS (P->dc->pixel_width ); drawpixel.pixel_height = ABS (P->dc->pixel_height); if (SCAN (API)) { wmf_ipa_color_add (API,&(drawpixel.color)); scope = (float) MAX (drawpixel.pixel_width,drawpixel.pixel_height); D_Coord_Register (API,drawpixel.pt,scope); return (changed); } drawpixel.dc = P->dc; if (FR->draw_pixel) FR->draw_pixel (API,&drawpixel); return (changed);}static int meta_arc (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data; wmfFunctionReference* FR = (wmfFunctionReference*) API->function_reference; wmfL_Coord l_pt; wmfD_Coord d_pt; wmfD_Coord c_pt; wmfDrawArc_t drawarc; wmfPen* pen = 0; U16 par_U16_x; U16 par_U16_y; U16 end_x; U16 end_y; char Qs; char Qe; float scope = 0; if (SCAN (API) && DIAG (API)) { fprintf (stderr,"\t[0x%04x]",Record->function); fprintf (stderr,"\t#par=%lu; max. index = 7",Record->size); } par_U16_x = ParU16 (API,Record,7); par_U16_y = ParU16 (API,Record,6); l_pt = L_Coord (API,par_U16_x,par_U16_y); drawarc.TL = wmf_D_Coord_translate (API,l_pt); par_U16_x = ParU16 (API,Record,5); par_U16_y = ParU16 (API,Record,4); l_pt = L_Coord (API,par_U16_x,par_U16_y); drawarc.BR = wmf_D_Coord_translate (API,l_pt); par_U16_x = ParU16 (API,Record,3); par_U16_y = ParU16 (API,Record,2); l_pt = L_Coord (API,par_U16_x,par_U16_y); drawarc.end = wmf_D_Coord_translate (API,l_pt); end_x = par_U16_x; end_y = par_U16_y; par_U16_x = ParU16 (API,Record,1); par_U16_y = ParU16 (API,Record,0); if ((end_x == par_U16_x) && (end_y == par_U16_y)) { /* start == end: This is probably an ellipse... TODO */ } l_pt = L_Coord (API,par_U16_x,par_U16_y); drawarc.start = wmf_D_Coord_translate (API,l_pt); if (SCAN (API)) { pen = WMF_DC_PEN (P->dc); scope = (float) (MAX (WMF_PEN_WIDTH (pen),WMF_PEN_HEIGHT (pen))) / 2; D_Coord_Register (API,drawarc.end,scope); D_Coord_Register (API,drawarc.start,scope); } c_pt.x = (drawarc.TL.x + drawarc.BR.x) / 2; /* ellipse origin */ c_pt.y = (drawarc.TL.y + drawarc.BR.y) / 2; drawarc.start.x -= c_pt.x; drawarc.start.y -= c_pt.y; drawarc.end.x -= c_pt.x; drawarc.end.y -= c_pt.y; if (SCAN (API)) { if ((drawarc.start.x > 0) && (drawarc.start.y >= 0)) Qs = '1'; else if ((drawarc.start.x <= 0) && (drawarc.start.y > 0)) Qs = '2'; else if ((drawarc.start.x < 0) && (drawarc.start.y <= 0)) Qs = '3'; else Qs = '4'; if ((drawarc.end.x > 0) && (drawarc.end.y >= 0)) Qe = '1'; else if ((drawarc.end.x <= 0) && (drawarc.end.y > 0)) Qe = '2'; else if ((drawarc.end.x < 0) && (drawarc.end.y <= 0)) Qe = '3'; else Qe = '4'; switch (Qs) { case '1': switch (Qe) { case '1': if ( (drawarc.end.x < drawarc.start.x) || (drawarc.end.y < drawarc.start.y)) break; d_pt.x = drawarc.BR.x; d_pt.y = c_pt.y; D_Coord_Register (API,d_pt,scope); case '4': d_pt.x = c_pt.x; d_pt.y = drawarc.BR.y; D_Coord_Register (API,d_pt,scope); case '3': d_pt.x = drawarc.TL.x; d_pt.y = c_pt.y; D_Coord_Register (API,d_pt,scope); case '2': d_pt.x = c_pt.x; d_pt.y = drawarc.TL.y; D_Coord_Register (API,d_pt,scope); break; default: WMF_ERROR (API,"Glitch!"); API->err = wmf_E_Glitch; break; } break; case '2': switch (Qe) { case '2': if ( (drawarc.end.x < drawarc.start.x) || (drawarc.end.y > drawarc.start.y)) break; d_pt.x = c_pt.x; d_pt.y = drawarc.TL.y; D_Coord_Register (API,d_pt,scope); case '1': d_pt.x = drawarc.BR.x; d_pt.y = c_pt.y; D_Coord_Register (API,d_pt,scope); case '4': d_pt.x = c_pt.x; d_pt.y = drawarc.BR.y; D_Coord_Register (API,d_pt,scope); case '3': d_pt.x = drawarc.TL.x; d_pt.y = c_pt.y; D_Coord_Register (API,d_pt,scope); break; default: WMF_ERROR (API,"Glitch!"); API->err = wmf_E_Glitch; break; } break; case '3': switch (Qe) { case '3': if ( (drawarc.end.x > drawarc.start.x) || (drawarc.end.y > drawarc.start.y)) break; d_pt.x = drawarc.TL.x; d_pt.y = c_pt.y; D_Coord_Register (API,d_pt,scope); case '2': d_pt.x = c_pt.x; d_pt.y = drawarc.TL.y; D_Coord_Register (API,d_pt,scope); case '1': d_pt.x = drawarc.BR.x; d_pt.y = c_pt.y; D_Coord_Register (API,d_pt,scope); case '4': d_pt.x = c_pt.x; d_pt.y = drawarc.BR.y; D_Coord_Register (API,d_pt,scope); break; default: WMF_ERROR (API,"Glitch!"); API->err = wmf_E_Glitch; break; } break; case '4': switch (Qe) { case '4': if ( (drawarc.end.x > drawarc.start.x) || (drawarc.end.y < drawarc.start.y)) break; d_pt.x = c_pt.x; d_pt.y = drawarc.BR.y; D_Coord_Register (API,d_pt,scope); case '3': d_pt.x = drawarc.TL.x; d_pt.y = c_pt.y; D_Coord_Register (API,d_pt,scope); case '2': d_pt.x = c_pt.x; d_pt.y = drawarc.TL.y; D_Coord_Register (API,d_pt,scope); case '1': d_pt.x = drawarc.BR.x; d_pt.y = c_pt.y; D_Coord_Register (API,d_pt,scope); break; default: WMF_ERROR (API,"Glitch!"); API->err = wmf_E_Glitch; break; } break; default: WMF_ERROR (API,"Glitch!"); API->err = wmf_E_Glitch; break; } return (changed); } d_pt.x = (drawarc.BR.x - drawarc.TL.x) / 2; /* elliptic axes */ d_pt.y = (drawarc.BR.y - drawarc.TL.y) / 2; if ((drawarc.start.x == 0) && (drawarc.start.y == 0)) drawarc.start.x = d_pt.x; if (drawarc.start.x > d_pt.x ) drawarc.start.x = d_pt.x; if (drawarc.start.x < (-d_pt.x)) drawarc.start.x = - d_pt.x; if (drawarc.start.y > d_pt.y ) drawarc.start.y = d_pt.y; if (drawarc.start.y < (-d_pt.y)) drawarc.start.y = - d_pt.y; if ((drawarc.end.x == 0) && (drawarc.end.y == 0)) drawarc.end.x = d_pt.x; if (drawarc.end.x > d_pt.x ) drawarc.end.x = d_pt.x; if (drawarc.end.x < (-d_pt.x)) drawarc.end.x = - d_pt.x; if (drawarc.end.y > d_pt.y ) drawarc.end.y = d_pt.y; if (drawarc.end.y < (-d_pt.y)) drawarc.end.y = - d_pt.y; drawarc.dc = P->dc; switch (Record->function) { case META_PIE: if (FR->draw_pie) FR->draw_pie (API,&drawarc); break; case META_CHORD: if (FR->draw_chord) FR->draw_chord (API,&drawarc); break; case META_ARC: if (FR->draw_arc) FR->draw_arc (API,&drawarc); break; default: WMF_ERROR (API,"libwmf: erk! programmer's error..."); WMF_ERROR (API," please contact us at http://www.wvware.com/"); API->err = wmf_E_Glitch; break; } return (changed);}static int meta_ellipse (wmfAPI* API,wmfRecord* Record,wmfAttributes* attrlist){ int changed = 0; wmfPlayer_t* P = (wmfPlayer_t*) API->player_data;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -