This is adj_bbox.c in view mode; [Download] [Up]
#include "incl.h"
extern int Width, Height, Vspace;
extern int GemPS, DrawPerfectPS;
extern double width, height;
extern double top_space, bottom_space;
extern double llx, lly, urx, ury, mm2pt;
extern double xfac, yfac, scx, scy;
adj_bbox (ini_width)
double ini_width;
{
double ini_height, width_mm, height_mm;
/*
** Compute initial height and initial x and y factors
** based on initial width.
*/
xfac = ini_width / (urx - llx);
yfac = xfac;
ini_height = xfac * (ury - lly);
/*
** Compute initial BoundingBox and scale values.
*/
llx *= xfac;
lly *= yfac;
urx *= xfac;
ury *= yfac;
scx *= xfac;
scy *= yfac;
/*
** Compute x and y factors based on width (-w) and/or height (-h) options.
** Compute resulting BoundingBox and scale values.
*/
if (Width || Height) {
if (Width && !Height) {
xfac = width / ini_width;
yfac = xfac;
}
else if (Height && !Width) {
yfac = height / ini_height;
xfac = yfac;
}
else {
xfac = width / ini_width;
yfac = height / ini_height;
}
llx *= xfac;
lly *= yfac;
urx *= xfac;
ury *= yfac;
scx *= xfac;
scy *= yfac;
}
/*
** Add some space between character bottom and top of boundingbox.
*/
ury += TOP_SPACE;
/*
** Adjust BoundingBox values to additional space above and
** below the picture supplied by means of the -s option.
*/
if (Vspace) {
lly -= bottom_space;
ury += top_space;
}
/*
** With the -G (Gem) and -D (DrawPerfect) option the -b (boundingbox)
** option is required.
** Test on maximum Boundingbox dimensions.
*/
if (GemPS || DrawPerfectPS) {
width_mm = (urx - llx) / mm2pt;
if (width_mm > MAX_WIDTH) {
fprintf (stderr, "\n*** Boundingbox width too large.\n");
fprintf (stderr, "Width = %.2lf\n", width_mm);
fprintf (stderr, "Maximum width = %d\n", MAX_WIDTH);
fprintf (stderr, "Adjust boundingbox or use the -w# option!\n\n");
return (EXIT_FAILURE);
}
height_mm = (ury - lly) / mm2pt;
if (height_mm > MAX_HEIGHT) {
fprintf (stderr, "\n*** Boundingbox height too large.\n");
fprintf (stderr, "Height = %.2lf\n", height_mm);
fprintf (stderr, "Maximum height = %d\n", MAX_HEIGHT);
fprintf (stderr, "Adjust boundingbox or use the -h# option!\n\n");
return (EXIT_FAILURE);
}
}
return (EXIT_SUCCESS);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.