printouts scaled as large as possible w/o distortion

This commit is contained in:
Albert Cahalan 2005-01-14 02:00:11 +00:00
parent a63e3ab4ac
commit 7b8dc6e528

View file

@ -12385,25 +12385,48 @@ static int do_ps_save(FILE * fi, const char *restrict const fname, SDL_Surface
char buf[256];
Uint32 (*getpixel)(SDL_Surface *, int, int) = getpixels[surf->format->BytesPerPixel];
fprintf(fi, "%%!PS-Adobe-3.0 EPSF-3.0\n");
fprintf(fi, "%%!PS-Adobe-3.0 EPSF-3.0\n"); // probably broken, but close enough maybe
fprintf(fi, "%%%%Title: (TuxPaint)\n");
time_t t = time(NULL);
strftime(buf, sizeof buf - 1, "%a %b %e %H:%M:%S %Y", localtime(&t));
fprintf(fi, "%%%%CreationDate: (%s)\n", buf);
fprintf(fi, "%%%%Creator: (Tux Paint " VER_VERSION "--" VER_DATE ")\n");
fprintf(fi, "%%%%Creator: (Tux Paint " VER_VERSION ", " VER_DATE ")\n");
fprintf(fi, "%%%%LanguageLevel: 2\n");
fprintf(fi, "%%%%BoundingBox: 72 214 540 578\n");
// fprintf(fi, "%%%%BoundingBox: 72 214 540 578\n");
fprintf(fi, "%%%%DocumentData: Binary\n");
fprintf(fi, "%%%%EndComments\n");
fprintf(fi, "\n");
fprintf(fi, "gsave\n");
fprintf(fi, "\n");
fprintf(fi, "%% First, grab the page size.\n");
fprintf(fi, "gsave\n");
fprintf(fi, " clippath\n");
fprintf(fi, " pathbbox\n");
fprintf(fi, "grestore\n");
fprintf(fi, "/ury exch def\n");
fprintf(fi, "/urx exch def\n");
fprintf(fi, "/lly exch def\n");
fprintf(fi, "/llx exch def\n");
fprintf(fi, "\n");
fprintf(fi, "llx lly translate\n");
fprintf(fi, "\n");
fprintf(fi, "/width %u def\n", surf->w);
fprintf(fi, "/height %u def\n", surf->h);
fprintf(fi, "width height scale\n");
fprintf(fi, "\n");
fprintf(fi, "urx llx sub width div\n");
fprintf(fi, "ury lly sub height div\n");
fprintf(fi, "%% now do a 'min' operation\n");
fprintf(fi, "2 copy gt { exch } if pop\n");
fprintf(fi, "\n");
// fprintf(fi, "90 rotate 0 %f translate\n", ???); // landscape mode
fprintf(fi, "72.000000 214.560000 translate 468.000000 362.880000 scale\n");
fprintf(fi, "dup scale\n");
fprintf(fi, "/DeviceRGB setcolorspace\n");
fprintf(fi, "<<\n");
fprintf(fi, " /ImageType 1\n");
fprintf(fi, " /Width %u /Height %u\n", surf->w, surf->h);
fprintf(fi, " /Width width /Height height\n");
fprintf(fi, " /BitsPerComponent 8\n");
fprintf(fi, " /ImageMatrix [650 0 0 -504 0 504]\n");
fprintf(fi, " /ImageMatrix [width 0 0 height neg 0 height]\n");
fprintf(fi, " /Decode [0 1 0 1 0 1]\n");
fprintf(fi, " /DataSource currentfile\n");
fprintf(fi, ">>\n");