466 gchar buf[2][G_ASCII_DTOSTR_BUF_SIZE];
468 if (!TIFFGetField(tif, TIFFTAG_XPOSITION, &ox))
470 if (!TIFFGetField(tif, TIFFTAG_YPOSITION, &oy))
475 TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP,
479 PSHead(ctx, tif, w, h, prw, prh, ox, oy);
480 TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE,
482 TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL,
484 TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG,
486 TIFFGetField(tif, TIFFTAG_COMPRESSION, &ctx->
compression);
487 TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
490 sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
491 if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &ctx->
photometric)) {
510 fprintf(ctx->
fd,
"%%%%Page: %d %d\n", ctx->
npages,
513 double psw = 0.0, psh = 0.0;
516 if (ctx->
res_unit == RESUNIT_CENTIMETER)
519 psw=ctx->
rotate ? prh:prw;
522 if (ctx->
res_unit == RESUNIT_CENTIMETER)
525 psh=ctx->
rotate ? prw:prh;
527 "1 dict begin /PageSize [ %s %s ] def currentdict end setpagedevice\n",
528 g_ascii_dtostr(buf[0],
sizeof(buf[0]), psw),
529 g_ascii_dtostr(buf[1],
sizeof(buf[1]), psh));
531 "<<\n /Policies <<\n /PageSize 3\n >>\n>> setpagedevice\n",
534 fprintf(ctx->
fd,
"gsave\n");
535 fprintf(ctx->
fd,
"100 dict begin\n");
536 if (pw != 0 || ph != 0) {
546 fprintf(ctx->
fd,
"end\n");
547 fprintf(ctx->
fd,
"grestore\n");
548 fprintf(ctx->
fd,
"showpage\n");
550 fprintf(ctx->
fd,
"%%%%Page: %d %d\n",
552 fprintf(ctx->
fd,
"gsave\n");
553 fprintf(ctx->
fd,
"100 dict begin\n");
562 scale = pw/prw < ph/prh ?
568 (ph - prh * scale) / 2;
570 (pw - prw * scale) / 2;
572 fprintf(ctx->
fd,
"%s %s translate\n",
573 g_ascii_dtostr(buf[0],
sizeof(buf[0]), left_offset),
574 g_ascii_dtostr(buf[1],
sizeof(buf[1]), bottom_offset));
575 fprintf(ctx->
fd,
"%s %s scale\n",
576 g_ascii_dtostr(buf[0],
sizeof(buf[0]), prw * scale),
577 g_ascii_dtostr(buf[1],
sizeof(buf[1]), prh * scale));
579 fputs (
"1 1 translate 180 ctx->rotate\n", ctx->
fd);
582 fprintf(ctx->
fd,
"%s %s scale\n",
583 g_ascii_dtostr(buf[0],
sizeof(buf[0]), prw),
584 g_ascii_dtostr(buf[1],
sizeof(buf[1]), prh));
586 fputs (
"1 1 translate 180 ctx->rotate\n", ctx->
fd);
589 fprintf(ctx->
fd,
"end\n");
590 fprintf(ctx->
fd,
"grestore\n");
591 fprintf(ctx->
fd,
"showpage\n");