- if (checkImage(tif)) {
- tf_bytesperrow = TIFFScanlineSize(tif);
- *npages = *npages + 1;
- fprintf(fd, "%%%%Page: %d %d\n", *npages, *npages);
- if (!generateEPSF && ( level2 || level3 )) {
- double psw = 0.0, psh = 0.0;
- if (psw != 0.0) {
- psw = pw * PS_UNIT_SIZE;
- if (res_unit == RESUNIT_CENTIMETER)
- psw *= 2.54F;
- } else
- psw=rotate ? prh:prw;
- if (psh != 0.0) {
- psh = ph * PS_UNIT_SIZE;
- if (res_unit == RESUNIT_CENTIMETER)
- psh *= 2.54F;
- } else
- psh=rotate ? prw:prh;
- fprintf(fd,
- "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n",
- psw, psh);
- fputs(
- "<<\n /Policies <<\n /PageSize 3\n >>\n>> setpagedevice\n",
- fd);
- }
- fprintf(fd, "gsave\n");
- fprintf(fd, "100 dict begin\n");
- if (pw != 0 || ph != 0) {
- if (!pw)
- pw = prw;
- if (!ph)
- ph = prh;
- if (maxPageHeight) { /* used -H option */
- split = PlaceImage(fd,pw,ph,prw,prh,
- 0,lm,bm,cnt);
- while( split ) {
- PSpage(fd, tif, w, h);
- fprintf(fd, "end\n");
- fprintf(fd, "grestore\n");
- fprintf(fd, "showpage\n");
- *npages = *npages + 1;
- fprintf(fd, "%%%%Page: %d %d\n",
- *npages, *npages);
- fprintf(fd, "gsave\n");
- fprintf(fd, "100 dict begin\n");
- split = PlaceImage(fd,pw,ph,prw,prh,
- split,lm,bm,cnt);
- }
- } else {
- pw *= PS_UNIT_SIZE;
- ph *= PS_UNIT_SIZE;
-
- /* NB: maintain image aspect ratio */
- scale = pw/prw < ph/prh ?
- pw/prw : ph/prh;
- if (scale > 1.0)
- scale = 1.0;
- if (cnt) {
- bottom_offset +=
- (ph - prh * scale) / 2;
- left_offset +=
- (pw - prw * scale) / 2;
- }
- fprintf(fd, "%f %f translate\n",
- left_offset, bottom_offset);
- fprintf(fd, "%f %f scale\n",
- prw * scale, prh * scale);
- if (rotate)
- fputs ("1 1 translate 180 rotate\n", fd);
+ }
+ if (checkImage(ctx, tif)) {
+ ctx->tf_bytesperrow = TIFFScanlineSize(tif);
+ ctx->npages++;
+ fprintf(ctx->fd, "%%%%Page: %d %d\n", ctx->npages,
+ ctx->npages);
+ if (!ctx->generateEPSF && ( ctx->level2 || ctx->level3 )) {
+ double psw = 0.0, psh = 0.0;
+ if (psw != 0.0) {
+ psw = pw * PS_UNIT_SIZE;
+ if (ctx->res_unit == RESUNIT_CENTIMETER)
+ psw *= 2.54F;
+ } else
+ psw=ctx->rotate ? prh:prw;
+ if (psh != 0.0) {
+ psh = ph * PS_UNIT_SIZE;
+ if (ctx->res_unit == RESUNIT_CENTIMETER)
+ psh *= 2.54F;
+ } else
+ psh=ctx->rotate ? prw:prh;
+ fprintf(ctx->fd,
+ "1 dict begin /PageSize [ %s %s ] def currentdict end setpagedevice\n",
+ g_ascii_dtostr(buf[0], sizeof(buf[0]), psw),
+ g_ascii_dtostr(buf[1], sizeof(buf[1]), psh));
+ fputs(
+ "<<\n /Policies <<\n /PageSize 3\n >>\n>> setpagedevice\n",
+ ctx->fd);
+ }
+ fprintf(ctx->fd, "gsave\n");
+ fprintf(ctx->fd, "100 dict begin\n");
+ if (pw != 0 || ph != 0) {
+ if (!pw)
+ pw = prw;
+ if (!ph)
+ ph = prh;
+ if (ctx->maxPageHeight) { /* used -H option */
+ split = PlaceImage(ctx,pw,ph,prw,prh,
+ 0,lm,bm,cnt);
+ while( split ) {
+ PSpage(ctx, tif, w, h);
+ fprintf(ctx->fd, "end\n");
+ fprintf(ctx->fd, "grestore\n");
+ fprintf(ctx->fd, "showpage\n");
+ ctx->npages++;
+ fprintf(ctx->fd, "%%%%Page: %d %d\n",
+ ctx->npages, ctx->npages);
+ fprintf(ctx->fd, "gsave\n");
+ fprintf(ctx->fd, "100 dict begin\n");
+ split = PlaceImage(ctx,pw,ph,prw,prh,
+ split,lm,bm,cnt);