Back to index

texmacs  1.0.7.15
Classes | Defines | Functions | Variables
pdfximage.c File Reference
#include <string.h>
#include "system.h"
#include "error.h"
#include "mem.h"
#include "dpxfile.h"
#include "pdfobj.h"
#include "pdfdoc.h"
#include "pdfdev.h"
#include "pdfdraw.h"
#include "epdf.h"
#include "pngimage.h"
#include "jpegimage.h"
#include "bmpimage.h"
#include "pdfximage.h"

Go to the source code of this file.

Classes

struct  attr_
struct  pdf_ximage_
struct  opt_
struct  ic_

Defines

#define IMAGE_TYPE_UNKNOWN   -1
#define IMAGE_TYPE_PDF   0
#define IMAGE_TYPE_JPEG   1
#define IMAGE_TYPE_PNG   2
#define IMAGE_TYPE_MPS   4
#define IMAGE_TYPE_EPS   5
#define IMAGE_TYPE_BMP   6
#define dpx_find_file(n, d, s)   (kpse_find_pict((n)))
#define dpx_fopen(n, m)   (MFOPEN((n),(m)))
#define dpx_fclose(f)   (MFCLOSE((f)))
#define CHECK_ID(c, n)
#define GET_IMAGE(c, n)   (&((c)->ximages[(n)]))
#define EBB_DPI   72

Functions

static int check_for_ps (FILE *fp)
static int ps_include_page (pdf_ximage *ximage)
void pdf_ximage_set_verbose (void)
static void pdf_init_ximage_struct (pdf_ximage *I, const char *ident, const char *filename, long page_no, pdf_obj *dict)
static void pdf_set_ximage_tempfile (pdf_ximage *I, const char *filename)
static void pdf_clean_ximage_struct (pdf_ximage *I)
void pdf_init_images (void)
void pdf_close_images (void)
static int source_image_type (FILE *fp)
static int load_image (const char *ident, const char *fullname, int format, FILE *fp, long page_no, pdf_obj *dict)
int pdf_ximage_findresource (const char *ident, long page_no, pdf_obj *dict)
void pdf_ximage_init_form_info (xform_info *info)
void pdf_ximage_init_image_info (ximage_info *info)
void pdf_ximage_set_image (pdf_ximage *I, void *image_info, pdf_obj *resource)
void pdf_ximage_set_form (pdf_ximage *I, void *form_info, pdf_obj *resource)
long pdf_ximage_get_page (pdf_ximage *I)
pdf_objpdf_ximage_get_reference (int id)
int pdf_ximage_defineresource (const char *ident, int subtype, void *info, pdf_obj *resource)
char * pdf_ximage_get_resname (int id)
int pdf_ximage_get_subtype (int id)
void pdf_ximage_set_attr (int id, long width, long height, double xdensity, double ydensity, double llx, double lly, double urx, double ury)
static void scale_to_fit_I (pdf_tmatrix *T, transform_info *p, pdf_ximage *I)
static void scale_to_fit_F (pdf_tmatrix *T, transform_info *p, pdf_ximage *I)
int pdf_ximage_scale_image (int id, pdf_tmatrix *M, pdf_rect *r, transform_info *p)
void set_distiller_template (char *s)

Variables

static struct opt_
static struct ic_

Class Documentation

struct attr_

Definition at line 64 of file pdfximage.c.

Collaboration diagram for attr_:
Class Members
pdf_rect bbox
long height
long width
double xdensity
double ydensity
struct pdf_ximage_

Definition at line 71 of file pdfximage.c.

Collaboration diagram for pdf_ximage_:
Class Members
pdf_obj * attr_dict
char * filename
char * ident
long page_no
pdf_obj * reference
char res_name
pdf_obj * resource
int subtype
char tempfile
struct opt_

Definition at line 91 of file pdfximage.c.

Class Members
char * cmdtmpl
int verbose
struct ic_

Definition at line 104 of file pdfximage.c.

Class Members
int capacity
int count
pdf_ximage * ximages

Define Documentation

#define CHECK_ID (   c,
  n 
)
Value:
do {\
  if ((n) < 0 || (n) >= (c)->count) {\
    ERROR("Invalid XObject ID: %d", (n));\
  }\
} while (0)

Definition at line 556 of file pdfximage.c.

#define dpx_fclose (   f)    (MFCLOSE((f)))

Definition at line 345 of file pdfximage.c.

#define dpx_find_file (   n,
  d,
 
)    (kpse_find_pict((n)))

Definition at line 343 of file pdfximage.c.

#define dpx_fopen (   n,
 
)    (MFOPEN((n),(m)))

Definition at line 344 of file pdfximage.c.

#define EBB_DPI   72

Definition at line 665 of file pdfximage.c.

#define GET_IMAGE (   c,
  n 
)    (&((c)->ximages[(n)]))

Definition at line 561 of file pdfximage.c.

#define IMAGE_TYPE_BMP   6

Definition at line 61 of file pdfximage.c.

#define IMAGE_TYPE_EPS   5

Definition at line 60 of file pdfximage.c.

#define IMAGE_TYPE_JPEG   1

Definition at line 57 of file pdfximage.c.

#define IMAGE_TYPE_MPS   4

Definition at line 59 of file pdfximage.c.

#define IMAGE_TYPE_PDF   0

Definition at line 56 of file pdfximage.c.

#define IMAGE_TYPE_PNG   2

Definition at line 58 of file pdfximage.c.

#define IMAGE_TYPE_UNKNOWN   -1

Definition at line 55 of file pdfximage.c.


Function Documentation

static int check_for_ps ( FILE *  fp) [static]

Definition at line 935 of file pdfximage.c.

{
  rewind (image_file);
  mfgets (work_buffer, WORK_BUFFER_SIZE, image_file);
  if (!strncmp (work_buffer, "%!", 2))
    return 1;
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int load_image ( const char *  ident,
const char *  fullname,
int  format,
FILE *  fp,
long  page_no,
pdf_obj dict 
) [static]

Definition at line 255 of file pdfximage.c.

{
  struct ic_ *ic = &_ic;
  int         id = -1; /* ret */
  pdf_ximage *I;

  id = ic->count;
  if (ic->count >= ic->capacity) {
    ic->capacity += 16;
    ic->ximages   = RENEW(ic->ximages, ic->capacity, pdf_ximage);
  }

  I  = &ic->ximages[id];
  pdf_init_ximage_struct(I, ident, fullname, page_no, dict);

  switch (format) {
  case  IMAGE_TYPE_JPEG:
    if (_opts.verbose)
      MESG("[JPEG]");
    if (jpeg_include_image(I, fp) < 0)
      goto error;
    I->subtype  = PDF_XOBJECT_TYPE_IMAGE;
    break;
#ifdef HAVE_LIBPNG
  case  IMAGE_TYPE_PNG:
    if (_opts.verbose)
      MESG("[PNG]");
    if (png_include_image(I, fp) < 0)
      goto error;
    I->subtype  = PDF_XOBJECT_TYPE_IMAGE;
    break;
#endif
  case  IMAGE_TYPE_BMP:
    if (_opts.verbose)
      MESG("[BMP]");
    if (bmp_include_image(I, fp) < 0)
      goto error;
    I->subtype  = PDF_XOBJECT_TYPE_IMAGE;
    break;
  case  IMAGE_TYPE_PDF:
    if (_opts.verbose)
      MESG("[PDF]");
    {
      int result = pdf_include_page(I, fp, fullname);
      if (result > 0)
       /* PDF version too recent */
       result = ps_include_page(I);
      if (result < 0)
       goto error;
    }
    if (_opts.verbose)
      MESG(",Page:%ld", I->page_no);
    I->subtype  = PDF_XOBJECT_TYPE_FORM;
    break;
  // case  IMAGE_TYPE_EPS:
  default:
    if (_opts.verbose)
      MESG(format == IMAGE_TYPE_EPS ? "[PS]" : "[UNKNOWN]");
    if (ps_include_page(I) < 0)
      goto error;
    if (_opts.verbose)
      MESG(",Page:%ld", I->page_no);
    I->subtype  = PDF_XOBJECT_TYPE_FORM;
  }

  switch (I->subtype) {
  case PDF_XOBJECT_TYPE_IMAGE:
    sprintf(I->res_name, "Im%d", id);
    break;
  case PDF_XOBJECT_TYPE_FORM:
    sprintf(I->res_name, "Fm%d", id);
    break;
  default:
    ERROR("Unknown XObject subtype: %d", I->subtype);
    goto error;
  }

  ic->count++;

  return  id;

 error:
  pdf_clean_ximage_struct(I);
  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void pdf_clean_ximage_struct ( pdf_ximage *  I) [static]

Definition at line 155 of file pdfximage.c.

{
  if (I->ident)
    RELEASE(I->ident);
  if (I->filename)
    RELEASE(I->filename);
  if (I->reference)
    pdf_release_obj(I->reference);
  if (I->resource)
    pdf_release_obj(I->resource);
  if (I->attr_dict)
    pdf_release_obj(I->attr_dict);
  pdf_init_ximage_struct(I, NULL, NULL, 0, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdf_close_images ( void  )

Definition at line 181 of file pdfximage.c.

{
  struct ic_ *ic = &_ic;
  if (ic->ximages) {
    int  i;
    for (i = 0; i < ic->count; i++) {
      pdf_ximage *I = ic->ximages+i;
      if (I->tempfile) {
       /*
        * It is important to remove temporary files at the end because
        * we cache file names. Since we use mkstemp to create them, we
        * might get the same file name again if delete the first file.
        * (This happens on NetBSD, reported by Jukka Salmi.)
        * We also use this to convert a PS file only once if multiple
        * pages are imported from that file.
        */
       if (_opts.verbose > 1)
         MESG("pdf_image>> deleting temporary file \"%s\"\n", I->filename);
       dpx_delete_temp_file(I->filename); /* temporary filename freed here */
       I->filename = NULL;
      }
      pdf_clean_ximage_struct(I);
    }
    RELEASE(ic->ximages);
    ic->ximages = NULL;
    ic->count = ic->capacity = 0;
  }

  if (_opts.cmdtmpl)
    RELEASE(_opts.cmdtmpl);
  _opts.cmdtmpl = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdf_init_images ( void  )

Definition at line 172 of file pdfximage.c.

{
  struct ic_ *ic = &_ic;
  ic->count    = 0;
  ic->capacity = 0;
  ic->ximages  = NULL;
}

Here is the caller graph for this function:

static void pdf_init_ximage_struct ( pdf_ximage *  I,
const char *  ident,
const char *  filename,
long  page_no,
pdf_obj dict 
) [static]

Definition at line 115 of file pdfximage.c.

{
  if (ident) {
    I->ident = NEW(strlen(ident)+1, char);
    strcpy(I->ident, ident);
  } else
    I ->ident = NULL;
  I->page_no  = page_no;
  if (filename) {
    I->filename = NEW(strlen(filename)+1, char);
    strcpy(I->filename, filename);
  } else
    I->filename = NULL;
  I->subtype  = -1;
  memset(I->res_name, 0, 16);
  I->reference = NULL;
  I->resource  = NULL;
  I->attr_dict = dict;

  I->attr.width = I->attr.height = 0;
  I->attr.xdensity = I->attr.ydensity = 1.0;
  I->attr.bbox.llx = I->attr.bbox.lly = 0;
  I->attr.bbox.urx = I->attr.bbox.ury = 0;

  I->tempfile = 0;
}

Here is the caller graph for this function:

static void pdf_set_ximage_tempfile ( pdf_ximage *  I,
const char *  filename 
) [static]

Definition at line 145 of file pdfximage.c.

{
  if (I->filename)
    RELEASE(I->filename);
  I->filename = NEW(strlen(filename)+1, char);
  strcpy(I->filename, filename);
  I->tempfile = 1;
}

Here is the caller graph for this function:

int pdf_ximage_defineresource ( const char *  ident,
int  subtype,
void *  info,
pdf_obj resource 
)

Definition at line 580 of file pdfximage.c.

{
  struct ic_ *ic = &_ic;
  int         id;
  pdf_ximage *I;

  id = ic->count;
  if (ic->count >= ic->capacity) {
    ic->capacity += 16;
    ic->ximages   = RENEW(ic->ximages, ic->capacity, pdf_ximage);
  }

  I = &ic->ximages[id];

  pdf_init_ximage_struct(I, ident, NULL, 0, NULL);

  switch (subtype) {
  case PDF_XOBJECT_TYPE_IMAGE:
    pdf_ximage_set_image(I, info, resource);
    sprintf(I->res_name, "Im%d", id);
    break;
  case PDF_XOBJECT_TYPE_FORM:
    pdf_ximage_set_form (I, info, resource);
    sprintf(I->res_name, "Fm%d", id);
    break;
  default:
    ERROR("Unknown XObject subtype: %d", subtype);
  }
  ic->count++;

  return  id;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pdf_ximage_findresource ( const char *  ident,
long  page_no,
pdf_obj dict 
)

Definition at line 348 of file pdfximage.c.

{
  struct ic_ *ic = &_ic;
  int         id = -1;
  pdf_ximage *I;
  char       *fullname, *f = NULL;
  int         format;
  FILE       *fp;

  for (id = 0; id < ic->count; id++) {
    I = &ic->ximages[id];
    if (I->ident && !strcmp(ident, I->ident)) {
      f = I->filename;
      if (I->page_no == page_no && I->attr_dict == dict) {
       return  id;
      }
    }
  }

  if (f) {
    /* we already have converted this file; f is the temporary file name */
    fullname = NEW(strlen(f)+1, char);
    strcpy(fullname, f);
  } else {
#ifdef NOKPSE
    /* try loading image */
    fullname = dpx_find_file(ident, "_pic_", "");
#else
    fullname = NEW(strlen(ident)+1, char);
    strcpy(fullname, ident);
#endif
    if (!fullname) {
      WARN("Error locating image file \"%s\"", ident);
      return  -1;
    }
  }

  fp = dpx_fopen(fullname, FOPEN_RBIN_MODE);
  if (!fp) {
    WARN("Error opening image file \"%s\"", fullname);
    RELEASE(fullname);
    return  -1;
  }
  if (_opts.verbose) {
    MESG("(Image:%s", ident);
    if (_opts.verbose > 1)
      MESG("[%s]", fullname);
  }

  format = source_image_type(fp);
  switch (format) {
#if 0
  case IMAGE_TYPE_MPS:
    if (_opts.verbose)
      MESG("[MPS]");
    id = mps_include_page(ident, fp);
    if (id < 0) {
      WARN("Try again with the distiller.");
      format = IMAGE_TYPE_EPS;
      rewind(fp);
    } else
      break;
#endif
  default:
    id = load_image(ident, fullname, format, fp, page_no, dict);
    break;
  }
  dpx_fclose(fp);

  RELEASE(fullname);

  if (_opts.verbose)
    MESG(")");

  if (id < 0)
    WARN("pdf: image inclusion failed for \"%s\".", ident);

  return  id;
}

Here is the call graph for this function:

Here is the caller graph for this function:

long pdf_ximage_get_page ( pdf_ximage *  I)

Definition at line 551 of file pdfximage.c.

{
  return I->page_no;
}

Here is the caller graph for this function:

Definition at line 564 of file pdfximage.c.

{
  struct ic_ *ic = &_ic;
  pdf_ximage *I;

  CHECK_ID(ic, id);

  I = GET_IMAGE(ic, id);
  if (!I->reference)
    I->reference = pdf_ref_obj(I->resource);

  return pdf_link_obj(I->reference);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* pdf_ximage_get_resname ( int  id)

Definition at line 616 of file pdfximage.c.

{
  struct ic_ *ic = &_ic;
  pdf_ximage *I;

  CHECK_ID(ic, id);

  I = GET_IMAGE(ic, id);

  return I->res_name;
}

Here is the caller graph for this function:

int pdf_ximage_get_subtype ( int  id)

Definition at line 629 of file pdfximage.c.

{
  struct ic_ *ic = &_ic;
  pdf_ximage *I;

  CHECK_ID(ic, id);

  I = GET_IMAGE(ic, id);

  return I->subtype;
}

Definition at line 443 of file pdfximage.c.

{
  info->flags    = 0;
  info->bbox.llx = 0;
  info->bbox.lly = 0;
  info->bbox.urx = 0;
  info->bbox.ury = 0;
  info->matrix.a = 1.0;
  info->matrix.b = 0.0;
  info->matrix.c = 0.0;
  info->matrix.d = 1.0;
  info->matrix.e = 0.0;
  info->matrix.f = 0.0;
}

Here is the caller graph for this function:

Definition at line 489 of file pdfximage.c.

{
  info->flags  = 0;
  info->width  = 0;
  info->height = 0;
  info->bits_per_component = 0;
  info->num_components = 0;
  info->min_dpi = 0;
  info->xdensity = info->ydensity = 1.0;
}

Here is the caller graph for this function:

int pdf_ximage_scale_image ( int  id,
pdf_tmatrix M,
pdf_rect r,
transform_info p 
)

Definition at line 782 of file pdfximage.c.

{
  struct ic_ *ic = &_ic;
  pdf_ximage *I;

  CHECK_ID(ic, id);

  I = GET_IMAGE(ic, id);

  pdf_setmatrix(M, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);

  switch (I->subtype) {
  /* Reference: PDF Reference 1.5 v6, p.302
   *
   * An image can be placed on the output page in any desired position,
   * orientation, and size by using the cm operator to modify the current
   * transformation matrix (CTM) so as to map the unit square of user space
   * to the rectangle or parallelogram in which the image is to be painted.
   *
   * There is neither BBox nor Matrix key in the image XObject.
   * Everything must be controlled by the cm operator.
   *
   * The argument [p] contains the user-defined bounding box, the scailing
   * factor of which is bp as EPS and PDF. On the other hand, I->attr
   * contains the (sampling) width and the (sampling) height of the image.
   *
   * There is no problem if a bitmap image has density information.
   * Otherwise, DVIPDFM's ebb generates bounding box as 100px = 72bp = 1in.
   * In this case, screen captured images look bad. Moreover, DVIPDFM's ebb
   * ignores all density information and use just 100px = 72bp = 1in.
   *
   * On the other hand, pdfTeX uses 100px = 100bp to get a better quality
   * for screen captured images.
   *
   * DVIPDFMx's xbb generates bounding box as 100px = 100bp in the same
   * way as pdfTeX. Furthermore, it takes care of density information too.
   */
  case PDF_XOBJECT_TYPE_IMAGE:
    scale_to_fit_I(M, p, I);
    if (p->flags & INFO_HAS_USER_BBOX) {
      r->llx = p->bbox.llx / (I->attr.width * I->attr.xdensity);
      r->lly = p->bbox.lly / (I->attr.height * I->attr.ydensity);
      r->urx = p->bbox.urx / (I->attr.width * I->attr.xdensity);
      r->ury = p->bbox.ury / (I->attr.height * I->attr.ydensity);
    } else {
      r->llx = 0.0;
      r->lly = 0.0;
      r->urx = 1.0;
      r->ury = 1.0;
    }
    break;
  /* User-defined transformation and clipping are controlled by
   * the cm operator and W operator, explicitly */
  case PDF_XOBJECT_TYPE_FORM:
    scale_to_fit_F(M, p, I);
    if (p->flags & INFO_HAS_USER_BBOX) {
      r->llx = p->bbox.llx;
      r->lly = p->bbox.lly;
      r->urx = p->bbox.urx;
      r->ury = p->bbox.ury;
    } else { /* I->attr.bbox from the image bounding box */
      r->llx = I->attr.bbox.llx;
      r->lly = I->attr.bbox.lly;
      r->urx = I->attr.bbox.urx;
      r->ury = I->attr.bbox.ury;
    }
    break;
  }

  return  0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdf_ximage_set_attr ( int  id,
long  width,
long  height,
double  xdensity,
double  ydensity,
double  llx,
double  lly,
double  urx,
double  ury 
)

Definition at line 642 of file pdfximage.c.

{
  struct ic_ *ic = &_ic;
  pdf_ximage *I;

  CHECK_ID(ic, id);

  I = GET_IMAGE(ic, id);
  I->attr.width = width;
  I->attr.height = height;
  I->attr.xdensity = xdensity;
  I->attr.ydensity = ydensity;
  I->attr.bbox.llx = llx;
  I->attr.bbox.lly = lly;
  I->attr.bbox.urx = urx;
  I->attr.bbox.ury = ury;
}
void pdf_ximage_set_form ( pdf_ximage *  I,
void *  form_info,
pdf_obj resource 
)

Definition at line 533 of file pdfximage.c.

{
  xform_info *info = form_info;

  I->subtype   = PDF_XOBJECT_TYPE_FORM;

  I->attr.bbox.llx = info->bbox.llx;
  I->attr.bbox.lly = info->bbox.lly;
  I->attr.bbox.urx = info->bbox.urx;
  I->attr.bbox.ury = info->bbox.ury;

  I->reference = pdf_ref_obj(resource);

  pdf_release_obj(resource); /* Caller don't know we are using reference. */
  I->resource  = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdf_ximage_set_image ( pdf_ximage *  I,
void *  image_info,
pdf_obj resource 
)

Definition at line 501 of file pdfximage.c.

{
  pdf_obj     *dict;
  ximage_info *info = image_info;

  if (!PDF_OBJ_STREAMTYPE(resource))
    ERROR("Image XObject must be of stream type.");

  I->subtype = PDF_XOBJECT_TYPE_IMAGE;

  I->attr.width  = info->width;  /* The width of the image, in samples */
  I->attr.height = info->height; /* The height of the image, in samples */
  I->attr.xdensity = info->xdensity;
  I->attr.ydensity = info->ydensity;

  I->reference = pdf_ref_obj(resource);

  dict = pdf_stream_dict(resource);
  pdf_add_dict(dict, pdf_new_name("Type"),    pdf_new_name("XObject"));
  pdf_add_dict(dict, pdf_new_name("Subtype"), pdf_new_name("Image"));
  pdf_add_dict(dict, pdf_new_name("Width"),   pdf_new_number(info->width));
  pdf_add_dict(dict, pdf_new_name("Height"),  pdf_new_number(info->height));
  pdf_add_dict(dict, pdf_new_name("BitsPerComponent"),
               pdf_new_number(info->bits_per_component));
  if (I->attr_dict)
    pdf_merge_dict(dict, I->attr_dict);

  pdf_release_obj(resource); /* Caller don't know we are using reference. */
  I->resource  = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pdf_ximage_set_verbose ( void  )

Definition at line 101 of file pdfximage.c.

{ _opts.verbose++; }

Here is the caller graph for this function:

static int ps_include_page ( pdf_ximage *  ximage) [static]

Definition at line 875 of file pdfximage.c.

{
  char  *distiller_template = _opts.cmdtmpl;
  char  *filename = ximage->filename;
  char  *temp;
  FILE  *fp;
  int    error = 0;

  if (!distiller_template) {
    WARN("No image converter available for converting file \"%s\" to PDF format.", filename);
    WARN(">> Please check if you have 'D' option in config file.");
    return  -1;
  }

  temp = dpx_create_temp_file();
  if (!temp) {
    WARN("Failed to create temporary file for image conversion: %s", filename);
    return  -1;
  }

  if (_opts.verbose > 1) {
    MESG("\n");
    MESG("pdf_image>> Converting file \"%s\" --> \"%s\" via:\n", filename, temp);
    MESG("pdf_image>>   %s\n", distiller_template);
    MESG("pdf_image>> ...");
  }

  error = dpx_file_apply_filter(distiller_template, filename, temp,
                               (unsigned short) pdf_get_version());
  if (error) {
    WARN("Image format conversion for \"%s\" failed...", filename);
    dpx_delete_temp_file(temp);
    return  error;
  }

  fp = MFOPEN(temp, FOPEN_RBIN_MODE);
  if (!fp) {
    WARN("Could not open conversion result \"%s\" for image \"%s\". Why?", temp, filename);
    dpx_delete_temp_file(temp);
    return  -1;
  }
  pdf_set_ximage_tempfile(ximage, temp);
  error = pdf_include_page(ximage, fp, temp);
  MFCLOSE(fp);

  /* See pdf_close_images for why we cannot delete temporary files here. */

  RELEASE(temp);

  if (error) {
    WARN("Failed to include image file \"%s\"", filename);
    WARN(">> Please check if");
    WARN(">>   %s", distiller_template);
    WARN(">>   %%o = output filename, %%i = input filename, %%b = input filename without suffix");
    WARN(">> can really convert \"%s\" to PDF format image.", filename);
  }

  return  error;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void scale_to_fit_F ( pdf_tmatrix T,
transform_info p,
pdf_ximage *  I 
) [static]

Definition at line 726 of file pdfximage.c.

{
  double  s_x, s_y, d_x, d_y;
  double  wd0, ht0, dp;

  if (p->flags & INFO_HAS_USER_BBOX) {
    wd0 =  p->bbox.urx - p->bbox.llx;
    ht0 =  p->bbox.ury - p->bbox.lly;
    d_x = -p->bbox.llx;
    d_y = -p->bbox.lly;
  } else {
    wd0 = I->attr.bbox.urx - I->attr.bbox.llx;
    ht0 = I->attr.bbox.ury - I->attr.bbox.lly;
    d_x = 0.0;
    d_y = 0.0; 
  }

  if (wd0 == 0.0) {
    WARN("Image width=0.0!");
    wd0 = 1.0;
  }
  if (ht0 == 0.0) {
    WARN("Image height=0.0!");
    ht0 = 1.0;
  }

  if ( (p->flags & INFO_HAS_WIDTH ) &&
       (p->flags & INFO_HAS_HEIGHT) ) {
    s_x = p->width  / wd0;
    s_y = (p->height + p->depth) / ht0;
    dp  = p->depth;
  } else if ( p->flags & INFO_HAS_WIDTH ) {
    s_x = p->width  / wd0;
    s_y = s_x;
    dp  = 0.0;
  } else if ( p->flags & INFO_HAS_HEIGHT) {
    s_y = (p->height + p->depth) / ht0;
    s_x = s_y;
    dp  = p->depth;
  } else {
    s_x = s_y = 1.0;
    dp  = 0.0;
  }

  T->a = s_x; T->c = 0.0;
  T->b = 0.0; T->d = s_y;
  T->e = s_x * d_x; T->f = s_y * d_y - dp;

  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void scale_to_fit_I ( pdf_tmatrix T,
transform_info p,
pdf_ximage *  I 
) [static]

Definition at line 668 of file pdfximage.c.

{
  double  s_x, s_y, d_x, d_y;
  double  wd0, ht0, dp, xscale, yscale;

  if (p->flags & INFO_HAS_USER_BBOX) {
    wd0 =  p->bbox.urx - p->bbox.llx;
    ht0 =  p->bbox.ury - p->bbox.lly;
    xscale = I->attr.width * I->attr.xdensity / wd0;
    yscale = I->attr.height * I->attr.ydensity / ht0;
    d_x = -p->bbox.llx / wd0;
    d_y = -p->bbox.lly / ht0;
  } else {
    wd0 = I->attr.width * I->attr.xdensity;
    ht0 = I->attr.height * I->attr.ydensity;
    xscale = yscale = 1.0;
    d_x = 0.0;
    d_y = 0.0; 
  }

  if (wd0 == 0.0) {
    WARN("Image width=0.0!");
    wd0 = 1.0;
  }
  if (ht0 == 0.0) {
    WARN("Image height=0.0!");
    ht0 = 1.0;
  }

  if ( (p->flags & INFO_HAS_WIDTH ) &&
       (p->flags & INFO_HAS_HEIGHT) ) {
    s_x = p->width * xscale;
    s_y = (p->height + p->depth) * yscale;
    dp  = p->depth * yscale;
  } else if ( p->flags & INFO_HAS_WIDTH ) {
    s_x = p->width * xscale;
    s_y = s_x * ((double)I->attr.height / I->attr.width);
    dp  = 0.0;
  } else if ( p->flags & INFO_HAS_HEIGHT) {
    s_y = (p->height + p->depth) * yscale;
    s_x = s_y * ((double)I->attr.width / I->attr.height);
    dp  = p->depth * yscale;
  } else {
    s_x = wd0;
    s_y = ht0;
    dp  = 0.0;
  }
  T->a = s_x; T->c = 0.0;
  T->b = 0.0; T->d = s_y;
  T->e = d_x * s_x / xscale; T->f = d_y * s_y / yscale - dp;

  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_distiller_template ( char *  s)

Definition at line 861 of file pdfximage.c.

{
  if (_opts.cmdtmpl)
    RELEASE(_opts.cmdtmpl);
  if (!s || *s == '\0')
    _opts.cmdtmpl = NULL;
  else {
    _opts.cmdtmpl = NEW(strlen(s) + 1, char);
    strcpy(_opts.cmdtmpl, s);
  }
  return;
}
static int source_image_type ( FILE *  fp) [static]

Definition at line 216 of file pdfximage.c.

{
  int  format = IMAGE_TYPE_UNKNOWN;

  rewind(fp);
  /*
   * Make sure we check for PS *after* checking for MP since
   * MP is a special case of PS.
   */
  if (check_for_jpeg(fp))
  {
    format = IMAGE_TYPE_JPEG;
  }
#ifdef  HAVE_LIBPNG
  else if (check_for_png(fp))
  {
    format = IMAGE_TYPE_PNG;
  }
#endif
  else if (check_for_bmp(fp))
  {
    format = IMAGE_TYPE_BMP;
  } else if (check_for_pdf(fp)) {
    format = IMAGE_TYPE_PDF;
#if 0
  } else if (check_for_mp(fp)) {
    format = IMAGE_TYPE_MPS;
#endif
  } else if (check_for_ps(fp)) {
    format = IMAGE_TYPE_EPS;
  } else {
    format = IMAGE_TYPE_UNKNOWN;
  }
  rewind(fp);

  return  format;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

struct ic_ [static]
Initial value:
 {
  0, 0, NULL
}

Definition at line 110 of file pdfximage.c.

struct opt_ [static]
Initial value:
 {
  0, NULL
}

Definition at line 97 of file pdfximage.c.