Leptonica  1.54
Файл src/graphics.c
#include <string.h>
#include <math.h>
#include "allheaders.h"

Функции

PTAgeneratePtaLine (l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2)
PTAgeneratePtaWideLine (l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width)
PTAgeneratePtaBox (BOX *box, l_int32 width)
PTAgeneratePtaBoxa (BOXA *boxa, l_int32 width, l_int32 removedups)
PTAgeneratePtaHashBox (BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline)
PTAgeneratePtaHashBoxa (BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 removedups)
PTAAgeneratePtaaBoxa (BOXA *boxa)
PTAAgeneratePtaaHashBoxa (BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline)
PTAgeneratePtaPolyline (PTA *ptas, l_int32 width, l_int32 closeflag, l_int32 removedups)
PTAgeneratePtaGrid (l_int32 w, l_int32 h, l_int32 nx, l_int32 ny, l_int32 width)
PTAconvertPtaLineTo4cc (PTA *ptas)
PTAgeneratePtaFilledCircle (l_int32 radius)
PTAgeneratePtaFilledSquare (l_int32 side)
PTAgeneratePtaLineFromPt (l_int32 x, l_int32 y, l_float64 length, l_float64 radang)
l_int32 locatePtRadially (l_int32 xr, l_int32 yr, l_float64 dist, l_float64 radang, l_float64 *px, l_float64 *py)
l_int32 pixRenderPlotFromNuma (PIX **ppix, NUMA *na, l_int32 plotloc, l_int32 linewidth, l_int32 max, l_uint32 color)
PTAmakePlotPtaFromNuma (NUMA *na, l_int32 size, l_int32 plotloc, l_int32 linewidth, l_int32 max)
l_int32 pixRenderPlotFromNumaGen (PIX **ppix, NUMA *na, l_int32 orient, l_int32 linewidth, l_int32 refpos, l_int32 max, l_int32 drawref, l_uint32 color)
PTAmakePlotPtaFromNumaGen (NUMA *na, l_int32 orient, l_int32 linewidth, l_int32 refpos, l_int32 max, l_int32 drawref)
l_int32 pixRenderPta (PIX *pix, PTA *pta, l_int32 op)
l_int32 pixRenderPtaArb (PIX *pix, PTA *pta, l_uint8 rval, l_uint8 gval, l_uint8 bval)
l_int32 pixRenderPtaBlend (PIX *pix, PTA *pta, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract)
l_int32 pixRenderLine (PIX *pix, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width, l_int32 op)
l_int32 pixRenderLineArb (PIX *pix, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
l_int32 pixRenderLineBlend (PIX *pix, l_int32 x1, l_int32 y1, l_int32 x2, l_int32 y2, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract)
l_int32 pixRenderBox (PIX *pix, BOX *box, l_int32 width, l_int32 op)
l_int32 pixRenderBoxArb (PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
l_int32 pixRenderBoxBlend (PIX *pix, BOX *box, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract)
l_int32 pixRenderBoxa (PIX *pix, BOXA *boxa, l_int32 width, l_int32 op)
l_int32 pixRenderBoxaArb (PIX *pix, BOXA *boxa, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
l_int32 pixRenderBoxaBlend (PIX *pix, BOXA *boxa, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract, l_int32 removedups)
l_int32 pixRenderHashBox (PIX *pix, BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 op)
l_int32 pixRenderHashBoxArb (PIX *pix, BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 rval, l_int32 gval, l_int32 bval)
l_int32 pixRenderHashBoxBlend (PIX *pix, BOX *box, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 rval, l_int32 gval, l_int32 bval, l_float32 fract)
l_int32 pixRenderHashBoxa (PIX *pix, BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 op)
l_int32 pixRenderHashBoxaArb (PIX *pix, BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 rval, l_int32 gval, l_int32 bval)
l_int32 pixRenderHashBoxaBlend (PIX *pix, BOXA *boxa, l_int32 spacing, l_int32 width, l_int32 orient, l_int32 outline, l_int32 rval, l_int32 gval, l_int32 bval, l_float32 fract)
l_int32 pixRenderPolyline (PIX *pix, PTA *ptas, l_int32 width, l_int32 op, l_int32 closeflag)
l_int32 pixRenderPolylineArb (PIX *pix, PTA *ptas, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_int32 closeflag)
l_int32 pixRenderPolylineBlend (PIX *pix, PTA *ptas, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval, l_float32 fract, l_int32 closeflag, l_int32 removedups)
l_int32 pixRenderGridArb (PIX *pix, l_int32 nx, l_int32 ny, l_int32 width, l_uint8 rval, l_uint8 gval, l_uint8 bval)
PIXpixRenderRandomCmapPtaa (PIX *pix, PTAA *ptaa, l_int32 polyflag, l_int32 width, l_int32 closeflag)
PIXpixRenderPolygon (PTA *ptas, l_int32 width, l_int32 *pxmin, l_int32 *pymin)
PIXpixFillPolygon (PIX *pixs, PTA *pta, l_int32 xmin, l_int32 ymin)
PIXpixRenderContours (PIX *pixs, l_int32 startval, l_int32 incr, l_int32 outdepth)
PIXfpixAutoRenderContours (FPIX *fpix, l_int32 ncontours)
PIXfpixRenderContours (FPIX *fpixs, l_float32 incr, l_float32 proxim)
PTApixGeneratePtaBoundary (PIX *pixs, l_int32 width)

Функции

PTA* convertPtaLineTo4cc ( PTA ptas)

convertPtaLineTo4cc()

Input: ptas (8-connected line of points) Return: ptad (4-connected line), or null on error

Notes: (1) When a polyline is generated with width = 1, the resulting line is not 4-connected in general. This function adds points as necessary to convert the line to 4-cconnected. It is useful when rendering 1 bpp on a pix. (2) Do not use this for lines generated with width > 1.

PIX* fpixAutoRenderContours ( FPIX fpix,
l_int32  ncontours 
)

fpixAutoRenderContours()

Input: fpix ncontours (> 1, < 500, typ. about 50) Return: pixd (8 bpp), or null on error

Notes: (1) The increment is set to get approximately . (2) The proximity to the target value for contour display is set to 0.15. (3) Negative values are rendered in red; positive values as black.

PIX* fpixRenderContours ( FPIX fpixs,
l_float32  incr,
l_float32  proxim 
)

fpixRenderContours()

Input: fpixs incr (increment between contours; must be > 0.0) proxim (required proximity to target value; default 0.15) Return: pixd (8 bpp), or null on error

Notes: (1) Values are displayed when val/incr is within +-proxim to an integer. The default value is 0.15; smaller values result in thinner contour lines. (2) Negative values are rendered in red; positive values as black.

PTAA* generatePtaaBoxa ( BOXA boxa)

generatePtaaBoxa()

Input: boxa Return: ptaa, or null on error

Notes: (1) This generates a pta of the four corners for each box in the boxa. (2) Each of these pta can be rendered onto a pix with random colors, by using pixRenderRandomCmapPtaa() with closeflag = 1.

PTAA* generatePtaaHashBoxa ( BOXA boxa,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline 
)

generatePtaaHashBoxa()

Input: boxa spacing (spacing between hash lines; must be > 1) width (hash line width) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) Return: ptaa, or null on error

Notes: (1) The orientation takes on one of 4 orientations (horiz, vertical, slope +1, slope -1). (2) The full outline is also drawn if = 1. (3) Each of these pta can be rendered onto a pix with random colors, by using pixRenderRandomCmapPtaa() with closeflag = 1.

PTA* generatePtaBox ( BOX box,
l_int32  width 
)

generatePtaBox()

Input: box width (of line) Return: ptad, or null on error

Notes: (1) Because the box is constructed so that we don't have any overlapping lines, there is no need to remove duplicates.

PTA* generatePtaBoxa ( BOXA boxa,
l_int32  width,
l_int32  removedups 
)

generatePtaBoxa()

Input: boxa width removedups (1 to remove, 0 to leave) Return: ptad, or null on error

Notes: (1) If the boxa has overlapping boxes, and if blending will be used to give a transparent effect, transparency artifacts at line intersections can be removed using removedups = 1.

generatePtaFilledCircle()

Input: radius Return: pta, or null on error

Notes: (1) The circle is has diameter = 2 * radius + 1. (2) It is located with the center of the circle at the point (radius, radius). (3) Consequently, it typically must be translated if it is to represent a set of pixels in an image.

generatePtaFilledSquare()

Input: side Return: pta, or null on error

Notes: (1) The center of the square can be chosen to be at (side / 2, side / 2). It must be translated by this amount when used for replication.

PTA* generatePtaGrid ( l_int32  w,
l_int32  h,
l_int32  nx,
l_int32  ny,
l_int32  width 
)

generatePtaGrid()

Input: w, h (of region where grid will be displayed) nx, ny (number of rectangles in each direction in grid) width (of rendered lines) Return: ptad, or null on error

PTA* generatePtaHashBox ( BOX box,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline 
)

generatePtaHashBox()

Input: box spacing (spacing between lines; must be > 1) width (of line) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) Return: ptad, or null on error

Notes: (1) The orientation takes on one of 4 orientations (horiz, vertical, slope +1, slope -1). (2) The full outline is also drawn if = 1.

PTA* generatePtaHashBoxa ( BOXA boxa,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline,
l_int32  removedups 
)

generatePtaHashBoxa()

Input: boxa spacing (spacing between lines; must be > 1) width (of line) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) removedups (1 to remove, 0 to leave) Return: ptad, or null on error

Notes: (1) The orientation takes on one of 4 orientations (horiz, vertical, slope +1, slope -1). (2) The full outline is also drawn if = 1. (3) If the boxa has overlapping boxes, and if blending will be used to give a transparent effect, transparency artifacts at line intersections can be removed using removedups = 1.

PTA* generatePtaLine ( l_int32  x1,
l_int32  y1,
l_int32  x2,
l_int32  y2 
)

generatePtaLine()

Input: x1, y1 (end point 1) x2, y2 (end point 2) Return: pta, or null on error

Notes: (1) Uses Bresenham line drawing, which results in an 8-connected line.

PTA* generatePtaLineFromPt ( l_int32  x,
l_int32  y,
l_float64  length,
l_float64  radang 
)

generatePtaLineFromPt()

Input: x, y (point of origination) length (of line, including starting point) radang (angle in radians, CW from horizontal) Return: pta, or null on error

Notes: (1) The of the line is 1 greater than the distance used in locatePtRadially(). Example: a distance of 1 gives rise to a length of 2.

PTA* generatePtaPolyline ( PTA ptas,
l_int32  width,
l_int32  closeflag,
l_int32  removedups 
)

generatePtaPolyline()

Input: pta (vertices of polyline) width closeflag (1 to close the contour; 0 otherwise) removedups (1 to remove, 0 to leave) Return: ptad, or null on error

PTA* generatePtaWideLine ( l_int32  x1,
l_int32  y1,
l_int32  x2,
l_int32  y2,
l_int32  width 
)

generatePtaWideLine()

Input: x1, y1 (end point 1) x2, y2 (end point 2) width Return: ptaj, or null on error

l_int32 locatePtRadially ( l_int32  xr,
l_int32  yr,
l_float64  dist,
l_float64  radang,
l_float64 px,
l_float64 py 
)

locatePtRadially()

Input: xr, yr (reference point) radang (angle in radians, CW from horizontal) dist (distance of point from reference point along line given by the specified angle) &x, &y (<return> location of point) Return: 0 if OK, 1 on error

PTA* makePlotPtaFromNuma ( NUMA na,
l_int32  size,
l_int32  plotloc,
l_int32  linewidth,
l_int32  max 
)

makePlotPtaFromNuma()

Input: numa size (pix height for horizontal plot; width for vertical plot) plotloc (location of plot: L_PLOT_AT_TOP, etc) linewidth (width of "line" that is drawn; between 1 and 7) max (maximum excursion in pixels from baseline) Return: ptad, or null on error

Notes: (1) This generates points from representing y(x) or x(y) with respect to a pix. A horizontal plot y(x) is drawn for a function of column position, and a vertical plot is drawn for a function x(y) of row position. The baseline is located so that all plot points will fit in the pix. (2) See makePlotPtaFromNumaGen() for more details.

PTA* makePlotPtaFromNumaGen ( NUMA na,
l_int32  orient,
l_int32  linewidth,
l_int32  refpos,
l_int32  max,
l_int32  drawref 
)

makePlotPtaFromNumaGen()

Input: numa orient (L_HORIZONTAL_LINE, L_VERTICAL_LINE) linewidth (width of "line" that is drawn; between 1 and 7) refpos (reference position: y for horizontal and x for vertical) max (maximum excursion in pixels from baseline) drawref (1 to draw the reference line and the normal to it) Return: ptad, or null on error

Notes: (1) This generates points from representing y(x) or x(y) with respect to a pix. For y(x), we draw a horizontal line at the reference position and a vertical line at the edge; then we draw the values of , scaled so that the maximum excursion from the reference position is pixels. (2) The start and delx parameters of are used to refer its values to the raster lines (L_VERTICAL_LINE) or columns (L_HORIZONTAL_LINE). (3) The linewidth is chosen in the interval [1 ... 7]. (4) should be chosen so the plot is entirely within the pix that it will be painted onto. (5) This would typically be used to plot, in place, a function computed along pixel rows or columns.

PIX* pixFillPolygon ( PIX pixs,
PTA pta,
l_int32  xmin,
l_int32  ymin 
)

pixFillPolygon()

Input: pixs (1 bpp, with 4-connected polygon outline) pta (vertices of the polygon) xmin, ymin (min values of vertices of polygon) Return: pixd (with outline filled), or null on error

Notes: (1) This fills the interior of the polygon, returning a new pix. It works for both convex and non-convex polygons. (2) To generate a filled polygon from a pta: PIX *pixt = pixRenderPolygon(pta, 1, &xmin, &ymin); PIX *pixd = pixFillPolygon(pixt, pta, xmin, ymin); pixDestroy(&pixt);

PTA* pixGeneratePtaBoundary ( PIX pixs,
l_int32  width 
)

pixGeneratePtaBoundary()

Input: pixs (1 bpp) width (of boundary line) Return: pta, or null on error

Notes: (1) Similar to ptaGetBoundaryPixels(), except here: * we only get pixels in the foreground * we can have a "line" width greater than 1 pixel. (2) Once generated, this can be applied to a random 1 bpp image to add a color boundary as follows: Pta *pta = pixGeneratePtaBoundary(pixs, width); Pix *pix1 = pixConvert1To8Cmap(pixs); pixRenderPtaArb(pix1, pta, rval, gval, bval);

l_int32 pixRenderBox ( PIX pix,
BOX box,
l_int32  width,
l_int32  op 
)

pixRenderBox()

Input: pix box width (thickness of box lines) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) Return: 0 if OK, 1 on error

l_int32 pixRenderBoxa ( PIX pix,
BOXA boxa,
l_int32  width,
l_int32  op 
)

pixRenderBoxa()

Input: pix boxa width (thickness of line) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) Return: 0 if OK, 1 on error

l_int32 pixRenderBoxaArb ( PIX pix,
BOXA boxa,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval 
)

pixRenderBoxaArb()

Input: pix boxa width (thickness of line) rval, gval, bval Return: 0 if OK, 1 on error

l_int32 pixRenderBoxaBlend ( PIX pix,
BOXA boxa,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval,
l_float32  fract,
l_int32  removedups 
)

pixRenderBoxaBlend()

Input: pix boxa width (thickness of line) rval, gval, bval fract (in [0.0 - 1.0]; complete transparency (no effect) if 0.0; no transparency if 1.0) removedups (1 to remove; 0 otherwise) Return: 0 if OK, 1 on error

l_int32 pixRenderBoxArb ( PIX pix,
BOX box,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval 
)

pixRenderBoxArb()

Input: pix (any depth, cmapped ok) box width (thickness of box lines) rval, gval, bval Return: 0 if OK, 1 on error

l_int32 pixRenderBoxBlend ( PIX pix,
BOX box,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval,
l_float32  fract 
)

pixRenderBoxBlend()

Input: pix box width (thickness of box lines) rval, gval, bval fract (in [0.0 - 1.0]; complete transparency (no effect) if 0.0; no transparency if 1.0) Return: 0 if OK, 1 on error

PIX* pixRenderContours ( PIX pixs,
l_int32  startval,
l_int32  incr,
l_int32  outdepth 
)

pixRenderContours()

Input: pixs (8 or 16 bpp; no colormap) startval (value of lowest contour; must be in [0 ... maxval]) incr (increment to next contour; must be > 0) outdepth (either 1 or depth of pixs) Return: pixd, or null on error

Notes: (1) The output can be either 1 bpp, showing just the contour lines, or a copy of the input pixs with the contour lines superposed.

l_int32 pixRenderGridArb ( PIX pix,
l_int32  nx,
l_int32  ny,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval 
)

pixRenderGridArb()

Input: pix (any depth, cmapped ok) nx, ny (number of rectangles in each direction) width (thickness of grid lines) rval, gval, bval Return: 0 if OK, 1 on error

l_int32 pixRenderHashBox ( PIX pix,
BOX box,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline,
l_int32  op 
)

pixRenderHashBox()

Input: pix box spacing (spacing between lines; must be > 1) width (thickness of box and hash lines) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) Return: 0 if OK, 1 on error

l_int32 pixRenderHashBoxa ( PIX pix,
BOXA boxa,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline,
l_int32  op 
)

pixRenderHashBoxa()

Input: pix boxa spacing (spacing between lines; must be > 1) width (thickness of box and hash lines) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) Return: 0 if OK, 1 on error

l_int32 pixRenderHashBoxaArb ( PIX pix,
BOXA boxa,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline,
l_int32  rval,
l_int32  gval,
l_int32  bval 
)

pixRenderHashBoxaArb()

Input: pix boxa spacing (spacing between lines; must be > 1) width (thickness of box and hash lines) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) rval, gval, bval Return: 0 if OK, 1 on error

l_int32 pixRenderHashBoxaBlend ( PIX pix,
BOXA boxa,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline,
l_int32  rval,
l_int32  gval,
l_int32  bval,
l_float32  fract 
)

pixRenderHashBoxaBlend()

Input: pix boxa spacing (spacing between lines; must be > 1) width (thickness of box and hash lines) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) rval, gval, bval fract (in [0.0 - 1.0]; complete transparency (no effect) if 0.0; no transparency if 1.0) Return: 0 if OK, 1 on error

l_int32 pixRenderHashBoxArb ( PIX pix,
BOX box,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline,
l_int32  rval,
l_int32  gval,
l_int32  bval 
)

pixRenderHashBoxArb()

Input: pix box spacing (spacing between lines; must be > 1) width (thickness of box and hash lines) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) rval, gval, bval Return: 0 if OK, 1 on error

l_int32 pixRenderHashBoxBlend ( PIX pix,
BOX box,
l_int32  spacing,
l_int32  width,
l_int32  orient,
l_int32  outline,
l_int32  rval,
l_int32  gval,
l_int32  bval,
l_float32  fract 
)

pixRenderHashBoxBlend()

Input: pix box spacing (spacing between lines; must be > 1) width (thickness of box and hash lines) orient (orientation of lines: L_HORIZONTAL_LINE, ...) outline (0 to skip drawing box outline) rval, gval, bval fract (in [0.0 - 1.0]; complete transparency (no effect) if 0.0; no transparency if 1.0) Return: 0 if OK, 1 on error

l_int32 pixRenderLine ( PIX pix,
l_int32  x1,
l_int32  y1,
l_int32  x2,
l_int32  y2,
l_int32  width,
l_int32  op 
)

pixRenderLine()

Input: pix x1, y1 x2, y2 width (thickness of line) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) Return: 0 if OK, 1 on error

l_int32 pixRenderLineArb ( PIX pix,
l_int32  x1,
l_int32  y1,
l_int32  x2,
l_int32  y2,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval 
)

pixRenderLineArb()

Input: pix x1, y1 x2, y2 width (thickness of line) rval, gval, bval Return: 0 if OK, 1 on error

l_int32 pixRenderLineBlend ( PIX pix,
l_int32  x1,
l_int32  y1,
l_int32  x2,
l_int32  y2,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval,
l_float32  fract 
)

pixRenderLineBlend()

Input: pix x1, y1 x2, y2 width (thickness of line) rval, gval, bval fract Return: 0 if OK, 1 on error

l_int32 pixRenderPlotFromNuma ( PIX **  ppix,
NUMA na,
l_int32  plotloc,
l_int32  linewidth,
l_int32  max,
l_uint32  color 
)

pixRenderPlotFromNuma()

Input: &pix (any type; replaced if not 32 bpp rgb) numa (to be plotted) plotloc (location of plot: L_PLOT_AT_TOP, etc) linewidth (width of "line" that is drawn; between 1 and 7) max (maximum excursion in pixels from baseline) color (plot color: 0xrrggbb00) Return: 0 if OK, 1 on error

Notes: (1) Simplified interface for plotting row or column aligned data on a pix. (2) This replaces with a 32 bpp rgb version if it is not already 32 bpp. It then draws the plot on the pix. (3) See makePlotPtaFromNumaGen() for more details.

l_int32 pixRenderPlotFromNumaGen ( PIX **  ppix,
NUMA na,
l_int32  orient,
l_int32  linewidth,
l_int32  refpos,
l_int32  max,
l_int32  drawref,
l_uint32  color 
)

pixRenderPlotFromNumaGen()

Input: &pix (any type; replaced if not 32 bpp rgb) numa (to be plotted) orient (L_HORIZONTAL_LINE, L_VERTICAL_LINE) linewidth (width of "line" that is drawn; between 1 and 7) refpos (reference position: y for horizontal and x for vertical) max (maximum excursion in pixels from baseline) drawref (1 to draw the reference line and the normal to it) color (plot color: 0xrrggbb00) Return: 0 if OK, 1 on error

Notes: (1) General interface for plotting row or column aligned data on a pix. (2) This replaces with a 32 bpp rgb version if it is not already 32 bpp. It then draws the plot on the pix. (3) See makePlotPtaFromNumaGen() for other input parameters.

PIX* pixRenderPolygon ( PTA ptas,
l_int32  width,
l_int32 pxmin,
l_int32 pymin 
)

pixRenderPolygon()

Input: ptas (of vertices, none repeated) width (of polygon outline) &xmin (<optional return>=""> min x value of input pts) &ymin (<optional return>=""> min y value of input pts) Return: pix (1 bpp, with outline generated), or null on error

Notes: (1) The pix is the minimum size required to contain the origin and the polygon. For example, the max x value of the input points is w - 1, where w is the pix width. (2) The rendered line is 4-connected, so that an interior or exterior 8-c.c. flood fill operation works properly.

l_int32 pixRenderPolyline ( PIX pix,
PTA ptas,
l_int32  width,
l_int32  op,
l_int32  closeflag 
)

pixRenderPolyline()

Input: pix ptas width (thickness of line) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) closeflag (1 to close the contour; 0 otherwise) Return: 0 if OK, 1 on error

Note: this renders a closed contour.

l_int32 pixRenderPolylineArb ( PIX pix,
PTA ptas,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval,
l_int32  closeflag 
)

pixRenderPolylineArb()

Input: pix ptas width (thickness of line) rval, gval, bval closeflag (1 to close the contour; 0 otherwise) Return: 0 if OK, 1 on error

Note: this renders a closed contour.

l_int32 pixRenderPolylineBlend ( PIX pix,
PTA ptas,
l_int32  width,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval,
l_float32  fract,
l_int32  closeflag,
l_int32  removedups 
)

pixRenderPolylineBlend()

Input: pix ptas width (thickness of line) rval, gval, bval fract (in [0.0 - 1.0]; complete transparency (no effect) if 0.0; no transparency if 1.0) closeflag (1 to close the contour; 0 otherwise) removedups (1 to remove; 0 otherwise) Return: 0 if OK, 1 on error

l_int32 pixRenderPta ( PIX pix,
PTA pta,
l_int32  op 
)

pixRenderPta()

Input: pix pta (arbitrary set of points) op (one of L_SET_PIXELS, L_CLEAR_PIXELS, L_FLIP_PIXELS) Return: 0 if OK, 1 on error

Notes: (1) L_SET_PIXELS puts all image bits in each pixel to 1 (black for 1 bpp; white for depth > 1) (2) L_CLEAR_PIXELS puts all image bits in each pixel to 0 (white for 1 bpp; black for depth > 1) (3) L_FLIP_PIXELS reverses all image bits in each pixel (4) This function clips the rendering to the pix. It performs clipping for functions such as pixRenderLine(), pixRenderBox() and pixRenderBoxa(), that call pixRenderPta().

l_int32 pixRenderPtaArb ( PIX pix,
PTA pta,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval 
)

pixRenderPtaArb()

Input: pix (any depth, cmapped ok) pta (arbitrary set of points) rval, gval, bval Return: 0 if OK, 1 on error

Notes: (1) If pix is colormapped, render this color (or the nearest color if the cmap is full) on each pixel. (2) If pix is not colormapped, do the best job you can using the input colors:

  • d = 1: set the pixels
  • d = 2, 4, 8: average the input rgb value
  • d = 32: use the input rgb value (3) This function clips the rendering to the pix.
l_int32 pixRenderPtaBlend ( PIX pix,
PTA pta,
l_uint8  rval,
l_uint8  gval,
l_uint8  bval,
l_float32  fract 
)

pixRenderPtaBlend()

Input: pix (32 bpp rgb) pta (arbitrary set of points) rval, gval, bval Return: 0 if OK, 1 on error

Notes: (1) This function clips the rendering to the pix.

PIX* pixRenderRandomCmapPtaa ( PIX pix,
PTAA ptaa,
l_int32  polyflag,
l_int32  width,
l_int32  closeflag 
)

pixRenderRandomCmapPtaa()

Input: pix (1, 2, 4, 8, 16, 32 bpp) ptaa polyflag (1 to interpret each Pta as a polyline; 0 to simply render the Pta as a set of pixels) width (thickness of line; use only for polyline) closeflag (1 to close the contour; 0 otherwise; use only for polyline mode) Return: pixd (cmapped, 8 bpp) or null on error

Notes: (1) This is a debugging routine, that displays a set of pixels, selected by the set of Ptas in a Ptaa, in a random color in a pix. (2) If == 1, each Pta is considered to be a polyline, and is rendered using and . Each polyline is rendered in a random color. (3) If == 0, all points in each Pta are rendered in a random color. The and parameters are ignored. (4) The output pix is 8 bpp and colormapped. Up to 254 different, randomly selected colors, can be used. (5) The rendered pixels replace the input pixels. They will be clipped silently to the input pix.