uint32
TIFFNumberOfStrips(TIFF* tif)
{
	TIFFDirectory *td = &tif->tif_dir;
	uint32 nstrips;
	nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
	     TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
	if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
		nstrips = multiply_32(tif, nstrips, (uint32)td->td_samplesperpixel,
		    "TIFFNumberOfStrips");
	return (nstrips);
}
['int\nTIFF2PS(FILE* fd, TIFF* tif,\n\tdouble pw, double ph, double lm, double bm, int cnt)\n{\n\tuint32 w = 0, h = 0;\n\tfloat  ox, oy;\n        double maxsource, maxtarget;\n        double hcenter, vcenter;\n        double prw, prh;\n\tdouble psw, psh;\n\tdouble xscale = 1.0, yscale = 1.0, scale = 1.0;\n\tdouble left_offset = lm * PS_UNIT_SIZE;\n\tdouble bottom_offset = bm * PS_UNIT_SIZE;\n\tuint32 subfiletype;\n\tuint16* sampleinfo;\n\tstatic int npages = 0;\n\tint split;\n\tif (!TIFFGetField(tif, TIFFTAG_XPOSITION, &ox))\n\t\tox = 0;\n\tif (!TIFFGetField(tif, TIFFTAG_YPOSITION, &oy))\n\t\toy = 0;\n\tdo {\n\t\ttf_numberstrips = TIFFNumberOfStrips(tif);\n\t\tTIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP,\n\t\t    &tf_rowsperstrip);\n\t\tsetupPageState(tif, &w, &h, &prw, &prh);\n                if (pw != 0) {\n                    psw = pw * PS_UNIT_SIZE;\n\t\t    if (res_unit == RESUNIT_CENTIMETER)\n\t\t\tpsw *= 2.54F;\n\t\t}\n                else\n                  psw = prw;\n                if (ph != 0) {\n                    psh = ph * PS_UNIT_SIZE;\n \t\t    if (res_unit == RESUNIT_CENTIMETER)\n\t\t\tpsh *= 2.54F;\n\t\t}\n                else\n                  psh = prh;\n                if (rotate && rotation == 0) {\n                  maxsource = (prw >= prh) ? prw : prh;\n                  maxtarget = (psw >= psh) ? psw : psh;\n                  if (((maxsource == prw) && (maxtarget != psw)) ||\n                      ((maxsource == prh) && (maxtarget != psh))) {\n\t\t    rotation = 90;\n\t\t  }\n\t\t}\n                switch (rotation) {\n                  case   0:\n                  case 180:\n                    xscale = (psw - left_offset)/prw;\n                    yscale = (psh - bottom_offset)/prh;\n\t\t    if (!npages)\n\t\t      PSHead(fd, tif, w, h, psw, psh, ox, oy);\n                    break;\n\t\t  case  90:\n                  case 270:\n                    xscale = (psw - bottom_offset) /prh;\n                    yscale = (psh - left_offset) /prw;\n\t\t    if (!npages)\n\t\t      PSHead(fd, tif, w, h, psh, psw, oy, ox);\n                    break;\n\t\t}\n\t\tTIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE,\n\t\t    &bitspersample);\n\t\tTIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL,\n\t\t    &samplesperpixel);\n\t\tTIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG,\n\t\t    &planarconfiguration);\n\t\tTIFFGetField(tif, TIFFTAG_COMPRESSION, &compression);\n\t\tTIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,\n\t\t    &extrasamples, &sampleinfo);\n\t\talpha = (extrasamples == 1 &&\n\t\t\t sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);\n\t\tif (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) {\n\t\t\tswitch (samplesperpixel - extrasamples) {\n\t\t\tcase 1:\n\t\t\t\tif (isCCITTCompression(tif))\n\t\t\t\t\tphotometric = PHOTOMETRIC_MINISWHITE;\n\t\t\t\telse\n\t\t\t\t\tphotometric = PHOTOMETRIC_MINISBLACK;\n\t\t\t\tbreak;\n\t\t\tcase 3:\n\t\t\t\tphotometric = PHOTOMETRIC_RGB;\n\t\t\t\tbreak;\n\t\t\tcase 4:\n\t\t\t\tphotometric = PHOTOMETRIC_SEPARATED;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (checkImage(tif)) {\n\t\t\ttf_bytesperrow = TIFFScanlineSize(tif);\n\t\t\tnpages++;\n\t\t\tfprintf(fd, "%%%%Page: %d %d\\n", npages, npages);\n\t\t\tif (!generateEPSF && ( level2 || level3 )) {\n\t\t\t\tfprintf(fd,\n\t"1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\\n",\n\t\t\t\t\tpsw, psh);\n\t\t\t\tfputs(\n\t"<<\\n  /Policies <<\\n    /PageSize 3\\n  >>\\n>> setpagedevice\\n",\n\t\t\t\t      fd);\n\t\t\t}\n\t\t\tfprintf(fd, "gsave\\n");\n\t\t\tfprintf(fd, "100 dict begin\\n");\n\t\t\tif (pw != 0 || ph != 0) {\n\t\t\t\tif (maxPageHeight || maxPageWidth)  {\n\t\t\t\t  split = PlaceImage(tif,fd,&npages,w,h,pw,ph,prw,prh,\n\t\t\t\t     0,lm,bm,cnt);\n\t\t\t\t\twhile( split ) {\n\t\t\t\t\t    PSpage(fd, tif, w, h);\n\t\t\t\t\t    fprintf(fd, "end\\n");\n\t\t\t\t\t    fprintf(fd, "grestore\\n");\n\t\t\t\t\t    fprintf(fd, "showpage\\n");\n\t\t\t\t\t    npages++;\n\t\t\t\t\t    fprintf(fd, "%%%%Page: %d %d\\n",\n\t\t\t\t\t\t    npages, npages);\n\t\t\t\t\t    fprintf(fd, "gsave\\n");\n\t\t\t\t\t    fprintf(fd, "100 dict begin\\n");\n\t\t\t\t\t    split = PlaceImage(tif,fd,&npages,w,h,pw,ph,prw,prh,\n\t\t\t\t\t\tsplit,lm,bm,cnt);\n\t\t\t\t\t}\n\t\t\t\t}\n                                else {\n                                    scale = (xscale < yscale) ? xscale : yscale;\n\t\t\t\t    if (scale > 1.0)\n\t\t\t\t       \tscale = 1.0;\n\t\t\t\t    if (cnt) {\n                                      switch (rotation) {\n\t\t\t\t\tcase   90:\n                                        case  270:\n\t\t\t\t\t    hcenter = (psw - prh * scale) / 2;\n\t\t\t\t\t    vcenter = (psh - prw * scale) / 2;\n                                            break;\n\t\t\t\t\tcase    0:\n                                        case  180:\n\t\t\t\t\tdefault:\n\t\t\t\t\t    hcenter = (psw - prw * scale) / 2;\n\t\t\t\t\t    vcenter = (psh - prh * scale) / 2;\n                                            break;\n\t\t\t\t      }\n\t\t\t\t    }\n\t\t\t\t  else\n                                      hcenter = 0.0, vcenter = 0.0;\n                                  if (cnt)\n  \t\t\t\t     fprintf (fd, "%f %f translate\\n", hcenter, vcenter);\n                                  switch (rotation) {\n \t\t\t\t    case 0:\n\t\t\t\t        fprintf (fd, "%f %f scale\\n", prw * scale, prh * scale);\n                                        break;\n \t\t\t       \t    case 90:\n\t\t\t\t\tfprintf (fd, "%f %f scale\\n1 0 translate 90 rotate\\n", prh * scale, prw * scale);\n                                        break;\n                                    case 180:\n\t\t\t\t\tfprintf (fd, "%f %f scale\\n1 1 translate 180 rotate\\n", prw * scale, prh * scale);\n\t\t\t\t\tbreak;\n\t\t\t\t    case 270:\n\t\t\t\t\tfprintf (fd, "%f %f scale\\n0 1 translate 270 rotate\\n", prh * scale, prw * scale);\n\t\t\t\t        break;\n\t\t\t            default:\n\t\t\t                fprintf (stderr, "Unsupported angle. No rotation\\n");\n\t\t\t\t\tfprintf (fd, "%f %f scale\\n", prw * scale, prh * scale);\n                                        break;\n\t\t\t\t  }\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t    if (rotate)\n                              {\n\t\t\t      switch (rotation) {\n\t\t\t         case   0:\n\t\t\t             fprintf (fd, "%f %f scale\\n", prw, prh);\n\t\t\t\t case  90:\n\t\t\t\t     fprintf (fd, "%f %f scale\\n1 0 translate 90 rotate\\n", prw, prh);\n                                     break;\n                                 case 180:\n\t\t\t             fprintf (fd, "%f %f scale\\n1 1 translate 180 rotate\\n", prw, prh);\n                                     break;\n\t\t\t         case 270:\n\t\t\t\t     fprintf (fd, "%f %f scale\\n0 1 translate 270 rotate\\n", prw, prh);\n                                     break;\n\t\t\t         default:\n\t\t\t             fprintf (stderr, "Unsupported angle. No rotation\\n");\n\t\t\t             fprintf( fd, "%f %f scale\\n", prw, prh);\n                                     break;\n\t\t\t         }\n\t\t\t      }\n                            else\n\t\t\t      {\n\t\t\t      fprintf (stderr, "No rotation\\n");\n\t\t\t      fprintf (fd, "%f %f scale\\n", prw, prh);\n\t\t\t      }\n\t\t\t}\n\t\t\tPSpage(fd, tif, w, h);\n\t\t\tfprintf(fd, "end\\n");\n\t\t\tfprintf(fd, "grestore\\n");\n\t\t\tfprintf(fd, "showpage\\n");\n\t\t}\n\t\tif (generateEPSF)\n\t\t\tbreak;\n\t\tTIFFGetFieldDefaulted(tif, TIFFTAG_SUBFILETYPE, &subfiletype);\n\t} while (((subfiletype & FILETYPE_PAGE) || printAll) &&\n\t    TIFFReadDirectory(tif));\n\treturn(npages);\n}', 'uint32\nTIFFNumberOfStrips(TIFF* tif)\n{\n\tTIFFDirectory *td = &tif->tif_dir;\n\tuint32 nstrips;\n\tnstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :\n\t     TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));\n\tif (td->td_planarconfig == PLANARCONFIG_SEPARATE)\n\t\tnstrips = multiply_32(tif, nstrips, (uint32)td->td_samplesperpixel,\n\t\t    "TIFFNumberOfStrips");\n\treturn (nstrips);\n}']