• shBitMapPrint
  • shRegPrint
  • regPrint.c

     This file contains printing routines used to create PostScript files 
     depicting images.
     Floyd-Steinberg dithering is used. The code in DERVISH is derived from
     Steve Kent's CCD program.
    

    Useful images can be often be obtained even in the case where one dot on the page corresponds to one pixel in the image.

    While the user supplies the resolution of their printer in dots per inch, the resulting PostScript file may be printed on any postscript printer, though the quality of the image is sometimes degraded. In fact, these routines generate encapsulated postscript. One may attempt to include the output in LaTeX, for example.

    Headers for these functions are available in

    
    

    shBitMapPrint

    Print a PostScript image to the file described by the file-descriptor FILE. File descriptors are obtained by calling the ANSI C function fopen(). The caller must close the file.

    The caller supplies PXL(R,C), a function which returns a pixel in the image at row R and column C.

    GAMMA is a parameter which controls the overall brightness of the image. A reasonable value when using a sqrt map is between 2 and 3.

    SIGNATURE:
      void shBitMapPrint(float inWide, /* width of paper in inches */
      		    float inHigh,  /* height of paper in inches */
      		    int dpi,	   /* assumed dots per inch */
      		    int imRows,    /* number of rows in input image */
      		    int imCols,	   /* number of columns in input image */
      		    char *title,   /* title to print   */
      		    FILE *file,    /* open file to print to*/
      		    float (*pxl)(int, int), /* user-supplied function to supply a
      					         floating -point number 0..1 representing
      					         the non-gamma corrected intensity at
      					         pixel (r,c)*/
      		    float gamma,    /* Value of gamma to use */
      		    int reverse,    /* if true reverse the image, else do not */
      		    int dither,     /* if true dither the image, else do not */
                          int numPixLabs, /* the number of pixel labels to put on image */
                          PIXLABEL pxText[]   /* the pixel labels */
      	)
      
    

    shRegPrint

     Render an image of the region to the named postscript file.
     By default, the image is printed reversed: (sky is white).
    

    By default, or if THRESH is equal to or larger than SAT, shRegPrint samples the image and computes saturation and threshhold values. Note that the calculated values will be returned, as the SAT and THRESH parameters are passed by reference.

    If using a sqrt map, a value for gamma of 3.2 is useful.

    Labels may be placed on the image by filling an array of PIXLABEL's and passing it and the number of labels to the routine. There are limitations on the labels: the format is either: r, c, text, where r,c is the row and column where the label is to be placed, or if text=="circle", "box", or "triangle" then r, c, text, width where width is the (diameter, width, base length) of the (circle, box, triangle) in pixels. If the text=="line", a line is drawn between r,c and width,col2. If the text=="rect", the format is r c text dr dc, where dr and dc are the width in rows and columns respectivly.

    SIGNATURE:
          void shRegPrint
          (
          REGION *reg,       /* IN: pointer to region to print */
          FILE *file,	       /* IN: pointer to FILE structure for PS output */
          float inWide,      /* IN: Prepare image for paper this wide */
          float inHigh,      /* IN: "        "     "    "    "   high */
          int dpi,	       /* IN: Expected printer resolution */
          float gamma,       /* IN: High values lighten the image */
          float *threshptr,  /* MOD: Pixels smaller then this are treated as thresh */
          float *satptr,     /* MOD: Pixels larger than this are treated as sat */
          char *title,       /* IN: Print this title on the page */
          int reverse,       /* IN: Reverse black and white if not 0 */
          int sqrtIn,        /* IN: use sqrt intensity map if 1; else linear */
          int dither,        /* IN: Dither image if 1; else do not */
          int numPixLabs,    /* the number of pixel labels to put on image */
          PIXLABEL pixText[]  /* the pixel labels */
          )