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
|
/* $Id: plmeta.c,v 1.5 2007/05/17 11:18:41 ajb Exp $
Copyright 1991, 1992, 1993, 1994, 1995
Geoffrey Furnish furnish@dino.ph.utexas.edu
Maurice LeBrun mjl@dino.ph.utexas.edu
Institute for Fusion Studies University of Texas at Austin
This 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.
This 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 this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
This is a metafile writer for PLplot.
*/
#include "plDevs.h"
/*#define DEBUG*/
#ifdef PLD_plmeta
#define NEED_PLDEBUG
#include "plplotP.h"
#include "drivers.h"
#include "metadefs.h"
#include <string.h>
/* Device info */
const char* plD_DEVICE_INFO_plmeta = "plmeta:PLplot Native Meta-File:0:plmeta:26:plm";
/* pmr: in drivers.h */
/* void plD_dispatch_init_plm ( PLDispatchTable *pdt ); */
void plD_init_plm (PLStream *);
void plD_line_plm (PLStream *, short, short, short, short);
void plD_polyline_plm (PLStream *, short *, short *, PLINT);
void plD_eop_plm (PLStream *);
void plD_bop_plm (PLStream *);
void plD_tidy_plm (PLStream *);
void plD_state_plm (PLStream *, PLINT);
void plD_esc_plm (PLStream *, PLINT, void *);
/* Struct to hold device-specific info. */
typedef struct {
PLFLT pxlx, pxly;
PLINT xold, yold;
PLINT xmin, xmax, xlen;
PLINT ymin, ymax, ylen;
FPOS_T lp_offset, index_offset;
int notfirst;
char Padding[4];
} PLmDev;
/* Used for constructing error messages */
static char buffer[256];
/* Function prototypes */
static void WriteFileHeader (PLStream *pls);
static void UpdatePrevPagehdr (PLStream *pls);
static void WritePageInfo (PLStream *pls, FPOS_T pp_offset);
static void UpdateIndex (PLStream *pls, FPOS_T cp_offset);
static void plm_fill (PLStream *pls);
static void plm_swin (PLStream *pls);
/* A little function to help with debugging */
#ifdef DEBUG
#define DEBUG_PRINT_LOCATION(a) PrintLocation(pls, a)
static void PrintLocation(PLStream *pls, char *tag)
{
int isfile = (pls->output_type == 0);
if (isfile) {
FILE *file = pls->OutFile;
FPOS_T current_offset;
if (pl_fgetpos(file, ¤t_offset))
plexit("PrintLocation (plmeta.c): fgetpos call failed");
pldebug(tag, "at offset %d in file %s\n",
(int) current_offset, pls->FileName);
}
}
#else
#define DEBUG_PRINT_LOCATION(a)
#endif
void plD_dispatch_init_plm( PLDispatchTable *pdt )
{
#ifndef ENABLE_DYNDRIVERS
pdt->pl_MenuStr = "PLplot Native Meta-File";
pdt->pl_DevName = "plmeta";
#endif
pdt->pl_type = plDevType_FileOriented;
pdt->pl_seq = 26;
pdt->pl_init = (plD_init_fp) plD_init_plm;
pdt->pl_line = (plD_line_fp) plD_line_plm;
pdt->pl_polyline = (plD_polyline_fp) plD_polyline_plm;
pdt->pl_eop = (plD_eop_fp) plD_eop_plm;
pdt->pl_bop = (plD_bop_fp) plD_bop_plm;
pdt->pl_tidy = (plD_tidy_fp) plD_tidy_plm;
pdt->pl_state = (plD_state_fp) plD_state_plm;
pdt->pl_esc = (plD_esc_fp) plD_esc_plm;
}
/*--------------------------------------------------------------------------*\
* plD_init_plm()
*
* Initialize device.
\*--------------------------------------------------------------------------*/
void
plD_init_plm(PLStream *pls)
{
PLmDev *dev;
U_CHAR c = (U_CHAR) INITIALIZE;
dbug_enter("plD_init_plm");
pls->color = 1; /* Is a color device */
pls->dev_fill0 = 1; /* Handle solid fills */
pls->dev_fill1 = 1; /* Handle pattern fills */
/* Initialize family file info */
plFamInit(pls);
/* Prompt for a file name if not already set */
plOpenFile(pls);
pls->pdfs = pdf_finit(pls->OutFile);
/* Allocate and initialize device-specific data */
pls->dev = calloc(1, (size_t) sizeof(PLmDev));
if (pls->dev == NULL)
plexit("plD_init_plm: Out of memory.");
dev = (PLmDev *) pls->dev;
dev->xold = PL_UNDEFINED;
dev->yold = PL_UNDEFINED;
dev->xmin = 0;
dev->xmax = PIXELS_X - 1;
dev->ymin = 0;
dev->ymax = PIXELS_Y - 1;
dev->pxlx = (double) PIXELS_X / (double) LPAGE_X;
dev->pxly = (double) PIXELS_Y / (double) LPAGE_Y;
plP_setpxl(dev->pxlx, dev->pxly);
plP_setphy(dev->xmin, dev->xmax, dev->ymin, dev->ymax);
/* Write Metafile header. */
WriteFileHeader(pls);
/* Write color map state info */
plD_state_plm(pls, PLSTATE_CMAP0);
plD_state_plm(pls, PLSTATE_CMAP1);
/* Write initialization command. */
DEBUG_PRINT_LOCATION("before init");
plm_wr( pdf_wr_1byte(pls->pdfs, c) );
}
/*--------------------------------------------------------------------------*\
* plD_line_plm()
*
* Draw a line in the current color from (x1,y1) to (x2,y2).
\*--------------------------------------------------------------------------*/
void
plD_line_plm(PLStream *pls, short xx1, short yy1, short xx2, short yy2)
{
PLmDev *dev = (PLmDev *) pls->dev;
U_CHAR c;
U_SHORT xy[4];
/* dbug_enter("plD_line_plm"); */
/* Failsafe check */
#ifdef DEBUG
if (xx1 < dev->xmin || xx1 > dev->xmax ||
xx2 < dev->xmin || xx2 > dev->xmax ||
yy1 < dev->ymin || yy1 > dev->ymax ||
yy2 < dev->ymin || yy2 > dev->ymax) {
pldebug("plD_line_plm",
"coordinates out of bounds -- \nActual: (%i,%i), (%i,%i) Bounds: (%i,%i,%i,%i)\n",
xx1, yy1, xx2, yy2,
dev->xmin, dev->xmax, dev->ymin, dev->ymax);
}
#endif
/* If continuation of previous line send the LINETO command, which uses
the previous (x,y) point as it's starting location. This results in a
storage reduction of not quite 50%, since the instruction length for
a LINETO is 5/9 of that for the LINE command, and given that most
graphics applications use this command heavily.
Still not quite as efficient as tektronix format since we also send the
command each time (so shortest command is 25% larger), but a lot easier
to implement than the tek method.
*/
if (xx1 == dev->xold && yy1 == dev->yold) {
c = (U_CHAR) LINETO;
plm_wr( pdf_wr_1byte(pls->pdfs, c) );
xy[0] = xx2;
xy[1] = yy2;
plm_wr( pdf_wr_2nbytes(pls->pdfs, xy, 2) );
}
else {
c = (U_CHAR) LINE;
plm_wr( pdf_wr_1byte(pls->pdfs, c) );
xy[0] = xx1;
xy[1] = yy1;
xy[2] = xx2;
xy[3] = yy2;
plm_wr( pdf_wr_2nbytes(pls->pdfs, xy, 4) );
}
dev->xold = xx2;
dev->yold = yy2;
}
/*--------------------------------------------------------------------------*\
* plD_polyline_plm()
*
* Draw a polyline in the current color.
\*--------------------------------------------------------------------------*/
void
plD_polyline_plm(PLStream *pls, short *xa, short *ya, PLINT npts)
{
PLmDev *dev = (PLmDev *) pls->dev;
U_CHAR c = (U_CHAR) POLYLINE;
dbug_enter("plD_polyline_plm");
plm_wr( pdf_wr_1byte(pls->pdfs, c) );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) npts) );
plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) xa, npts) );
plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) ya, npts) );
dev->xold = xa[npts - 1];
dev->yold = ya[npts - 1];
}
/*--------------------------------------------------------------------------*\
* plD_eop_plm()
*
* End of page.
\*--------------------------------------------------------------------------*/
void
plD_eop_plm(PLStream *pls)
{
U_CHAR c = (U_CHAR) EOP;
plm_wr( pdf_wr_1byte(pls->pdfs, c) );
}
/*--------------------------------------------------------------------------*\
* plD_bop_plm()
*
* Set up for the next page.
*
* Page header layout as follows:
*
* BOP (U_CHAR)
* page number (U_SHORT)
* prev page offset (U_LONG)
* next page offset (U_LONG)
*
* Each call after the first is responsible for updating the table of
* contents and the next page offset from the previous page.
\*--------------------------------------------------------------------------*/
void
plD_bop_plm(PLStream *pls)
{
PLmDev *dev = (PLmDev *) pls->dev;
int isfile = (pls->output_type == 0);
FPOS_T pp_offset = dev->lp_offset;;
dbug_enter("plD_bop_plm");
dev->xold = PL_UNDEFINED;
dev->yold = PL_UNDEFINED;
/* Update previous page header */
if (isfile)
UpdatePrevPagehdr(pls);
/* Start next family file if necessary. */
pls->bytecnt = pls->pdfs->bp;
plGetFam(pls);
/* Update page counter */
pls->page++;
/* Update table of contents info & write new page header. */
WritePageInfo(pls, pp_offset);
}
/*--------------------------------------------------------------------------*\
* WritePageInfo()
*
* Update table of contents info & write new page header.
\*--------------------------------------------------------------------------*/
static void
WritePageInfo(PLStream *pls, FPOS_T pp_offset)
{
PLmDev *dev = (PLmDev *) pls->dev;
FILE *file = pls->OutFile;
int isfile = (pls->output_type == 0);
U_CHAR c;
FPOS_T cp_offset=0;
/* Update table of contents. */
if (isfile) {
if (pl_fgetpos(file, &cp_offset))
plexit("WritePageInfo (plmeta.c): fgetpos call failed");
UpdateIndex(pls, cp_offset);
}
/* Write new page header */
if (dev->notfirst)
c = BOP;
else {
c = BOP0;
dev->notfirst = 1;
}
plm_wr( pdf_wr_1byte(pls->pdfs, c) );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->page) );
plm_wr( pdf_wr_4bytes(pls->pdfs, (U_LONG) pp_offset) );
plm_wr( pdf_wr_4bytes(pls->pdfs, (U_LONG) 0) );
/* Update last page offset with current page value */
dev->lp_offset = cp_offset;
/* Write some page state information just to make things nice later on */
/* Eventually there will be more */
plD_state_plm(pls, PLSTATE_COLOR0);
}
/*--------------------------------------------------------------------------*\
* UpdatePrevPagehdr()
*
* Update previous page header.
\*--------------------------------------------------------------------------*/
static void
UpdatePrevPagehdr(PLStream *pls)
{
PLmDev *dev = (PLmDev *) pls->dev;
FILE *file = pls->OutFile;
FPOS_T cp_offset=0;
fflush(file);
/* Determine where we are */
if (pl_fgetpos(file, &cp_offset))
plexit("plD_bop_plm: fgetpos call failed");
/* Seek back to previous page header. */
if (dev->lp_offset > 0) {
FPOS_T fwbyte_offset=0;
pldebug("UpdatePrevPagehdr 1 (plmeta.c)",
"Location: %d, seeking to: %d\n",
(int) cp_offset, (int) dev->lp_offset);
/* The forward byte offset is located exactly 7 bytes after the BOP */
fwbyte_offset = dev->lp_offset + 7;
if (pl_fsetpos(file, &fwbyte_offset)) {
sprintf(buffer, "UpdatePrevPagehdr (plmeta.c): fsetpos to fwbyte_offset (%d) failed",
(int) fwbyte_offset);
plexit(buffer);
}
/* DEBUG: verify current location */
#ifdef DEBUG
if (pl_fgetpos(file, &fwbyte_offset))
plexit("UpdatePrevPagehdr (plmeta.c): fgetpos call failed");
pldebug("UpdatePrevPagehdr 2 (plmeta.c)",
"Now at: %d, to write: %d\n",
(int) fwbyte_offset, (int) cp_offset);
#endif
/* Write forward byte offset into previous page header. */
plm_wr( pdf_wr_4bytes(pls->pdfs, (U_LONG) cp_offset) );
fflush(file);
/* DEBUG: move back to before the write & read it to verify */
#ifdef DEBUG
if (pl_fsetpos(file, &fwbyte_offset)) {
sprintf(buffer, "UpdatePrevPagehdr (plmeta.c): fsetpos to fwbyte_offset (%d) failed",
(int) fwbyte_offset);
plexit(buffer);
}
{
U_LONG read_offset;
plm_rd(pdf_rd_4bytes(pls->pdfs, &read_offset));
pldebug("UpdatePrevPagehdr 3 (plmeta.c)",
"Value read as: %d\n", read_offset);
}
#endif
/* Return to current page offset */
if (pl_fsetpos(file, &cp_offset)) {
sprintf(buffer, "UpdatePrevPagehdr (plmeta.c): fsetpos to cp_offset (%d) failed",
(int) cp_offset);
plexit(buffer);
}
}
}
/*--------------------------------------------------------------------------*\
* UpdateIndex()
*
* Update file index.
\*--------------------------------------------------------------------------*/
static void
UpdateIndex(PLStream *pls, FPOS_T cp_offset)
{
PLmDev *dev = (PLmDev *) pls->dev;
FILE *file = pls->OutFile;
/* Update file index. Right now only number of pages. */
/* The ordering here is critical */
if (dev->index_offset > 0) {
pldebug("UpdateIndex (plmeta.c)",
"Location: %d, seeking to: %d\n",
(int) cp_offset, (int) dev->lp_offset);
if (pl_fsetpos(file, &dev->index_offset)) {
sprintf(buffer, "UpdateIndex (plmeta.c): fsetpos to index_offset (%d) failed",
(int) dev->index_offset);
plexit(buffer);
}
plm_wr( pdf_wr_header(pls->pdfs, "pages") );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->page) );
pldebug("UpdateIndex (plmeta.c)",
"Location: %d, seeking to: %d\n",
(int) dev->lp_offset, (int) cp_offset);
if (pl_fsetpos(file, &cp_offset)) {
sprintf(buffer, "UpdateIndex (plmeta.c): fsetpos to cp_offset (%d) failed",
(int) cp_offset);
plexit(buffer);
}
}
}
/*--------------------------------------------------------------------------*\
* plD_tidy_plm()
*
* Close graphics file
\*--------------------------------------------------------------------------*/
void
plD_tidy_plm(PLStream *pls)
{
U_CHAR c = (U_CHAR) CLOSE;
dbug_enter("plD_tidy_plm");
plm_wr( pdf_wr_1byte(pls->pdfs, c) );
pdf_close(pls->pdfs);
free_mem(pls->dev);
}
/*--------------------------------------------------------------------------*\
* plD_state_plm()
*
* Handle change in PLStream state (color, pen width, fill attribute, etc).
\*--------------------------------------------------------------------------*/
void
plD_state_plm(PLStream *pls, PLINT op)
{
U_CHAR c = (U_CHAR) CHANGE_STATE;
int i;
dbug_enter("plD_state_plm");
plm_wr( pdf_wr_1byte(pls->pdfs, c) );
plm_wr( pdf_wr_1byte(pls->pdfs, op) );
switch (op) {
case PLSTATE_WIDTH:
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) (pls->width)) );
break;
case PLSTATE_COLOR0:
plm_wr( pdf_wr_2bytes(pls->pdfs, (short) pls->icol0) );
if (pls->icol0 == PL_RGB_COLOR) {
plm_wr( pdf_wr_1byte(pls->pdfs, pls->curcolor.r) );
plm_wr( pdf_wr_1byte(pls->pdfs, pls->curcolor.g) );
plm_wr( pdf_wr_1byte(pls->pdfs, pls->curcolor.b) );
}
break;
case PLSTATE_COLOR1:
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->icol1) );
break;
case PLSTATE_FILL:
plm_wr( pdf_wr_1byte(pls->pdfs, (U_CHAR) pls->patt) );
break;
case PLSTATE_CMAP0:
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->ncol0) );
for (i = 0; i < pls->ncol0; i++) {
plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap0[i].r) );
plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap0[i].g) );
plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap0[i].b) );
}
break;
case PLSTATE_CMAP1:
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->ncol1) );
for (i = 0; i < pls->ncol1; i++) {
plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap1[i].r) );
plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap1[i].g) );
plm_wr( pdf_wr_1byte(pls->pdfs, pls->cmap1[i].b) );
}
break;
}
}
/*--------------------------------------------------------------------------*\
* plD_esc_plm()
*
* Escape function. Note that any data written must be in device
* independent form to maintain the transportability of the metafile.
*
* Functions:
*
* PLESC_FILL Fill polygon
* PLESC_SWIN Set window parameters
*
\*--------------------------------------------------------------------------*/
void
plD_esc_plm(PLStream *pls, PLINT op, void *ptr)
{
U_CHAR c = (U_CHAR) ESCAPE;
(void) ptr; /* pmr: make it used */
dbug_enter("plD_esc_plm");
plm_wr( pdf_wr_1byte(pls->pdfs, c) );
plm_wr( pdf_wr_1byte(pls->pdfs, (U_CHAR) op) );
switch (op) {
case PLESC_FILL:
plm_fill(pls);
break;
case PLESC_SWIN:
plm_swin(pls);
break;
}
}
/*--------------------------------------------------------------------------*\
* plm_fill()
*
* Fill polygon described in points pls->dev_x[] and pls->dev_y[].
\*--------------------------------------------------------------------------*/
static void
plm_fill(PLStream *pls)
{
PLmDev *dev = (PLmDev *) pls->dev;
dbug_enter("plm_fill");
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->dev_npts) );
plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) pls->dev_x, pls->dev_npts) );
plm_wr( pdf_wr_2nbytes(pls->pdfs, (U_SHORT *) pls->dev_y, pls->dev_npts) );
dev->xold = PL_UNDEFINED;
dev->yold = PL_UNDEFINED;
}
/*--------------------------------------------------------------------------*\
* plm_swin()
*
* Set window parameters.
* Each parameter or group of parameters is tagged to make backward
* compatibility easier.
\*--------------------------------------------------------------------------*/
static void
plm_swin(PLStream *pls)
{
(void) pls; /* pmr: make it used */
dbug_enter("plm_swin");
}
/*--------------------------------------------------------------------------*\
* WriteFileHeader()
*
* Writes Metafile header.
\*--------------------------------------------------------------------------*/
static void
WriteFileHeader(PLStream *pls)
{
PLmDev *dev = (PLmDev *) pls->dev;
FILE *file = pls->OutFile;
int isfile = (pls->output_type == 0);
dbug_enter("WriteFileHeader(PLStream *pls");
plm_wr( pdf_wr_header(pls->pdfs, PLMETA_HEADER) );
plm_wr( pdf_wr_header(pls->pdfs, PLMETA_VERSION) );
/* Write file index info. Right now only number of pages. */
/* The order here is critical */
if (isfile) {
if (pl_fgetpos(file, &dev->index_offset))
plexit("WriteFileHeader: fgetpos call failed");
}
plm_wr( pdf_wr_header(pls->pdfs, "pages") );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) 0) );
/* Write initialization info. Tag via strings to make backward
compatibility with old metafiles as easy as possible. */
plm_wr( pdf_wr_header(pls->pdfs, "xmin") );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) dev->xmin) );
plm_wr( pdf_wr_header(pls->pdfs, "xmax") );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) dev->xmax) );
plm_wr( pdf_wr_header(pls->pdfs, "ymin") );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) dev->ymin) );
plm_wr( pdf_wr_header(pls->pdfs, "ymax") );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) dev->ymax) );
plm_wr( pdf_wr_header(pls->pdfs, "pxlx") );
plm_wr( pdf_wr_ieeef(pls->pdfs, (float) dev->pxlx) );
plm_wr( pdf_wr_header(pls->pdfs, "pxly") );
plm_wr( pdf_wr_ieeef(pls->pdfs, (float) dev->pxly) );
/* Geometry info, needed to properly transmit e.g. aspect ratio, via the
length params. Not sure if the others are useful, but they're included for
completeness. */
plm_wr( pdf_wr_header(pls->pdfs, "xdpi") );
plm_wr( pdf_wr_ieeef(pls->pdfs, (float) pls->xdpi) );
plm_wr( pdf_wr_header(pls->pdfs, "ydpi") );
plm_wr( pdf_wr_ieeef(pls->pdfs, (float) pls->ydpi) );
plm_wr( pdf_wr_header(pls->pdfs, "xlength") );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->xlength) );
plm_wr( pdf_wr_header(pls->pdfs, "ylength") );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->ylength) );
plm_wr( pdf_wr_header(pls->pdfs, "xoffset") );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->xoffset) );
plm_wr( pdf_wr_header(pls->pdfs, "yoffset") );
plm_wr( pdf_wr_2bytes(pls->pdfs, (U_SHORT) pls->yoffset) );
plm_wr( pdf_wr_header(pls->pdfs, "") );
}
#else
int
pldummy_plmeta(void)
{
return 0;
}
#endif /* PLD_plmeta */
|