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

Функции

PIXpixaDisplay (PIXA *pixa, l_int32 w, l_int32 h)
PIXpixaDisplayOnColor (PIXA *pixa, l_int32 w, l_int32 h, l_uint32 bgcolor)
PIXpixaDisplayRandomCmap (PIXA *pixa, l_int32 w, l_int32 h)
PIXpixaDisplayOnLattice (PIXA *pixa, l_int32 xspace, l_int32 yspace)
PIXpixaDisplayUnsplit (PIXA *pixa, l_int32 nx, l_int32 ny, l_int32 borderwidth, l_uint32 bordercolor)
PIXpixaDisplayTiled (PIXA *pixa, l_int32 maxwidth, l_int32 background, l_int32 spacing)
PIXpixaDisplayTiledInRows (PIXA *pixa, l_int32 outdepth, l_int32 maxwidth, l_float32 scalefactor, l_int32 background, l_int32 spacing, l_int32 border)
PIXpixaDisplayTiledAndScaled (PIXA *pixa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border)
PIXpixaaDisplay (PIXAA *pixaa, l_int32 w, l_int32 h)
PIXpixaaDisplayByPixa (PIXAA *pixaa, l_int32 xspace, l_int32 yspace, l_int32 maxw)
PIXApixaaDisplayTiledAndScaled (PIXAA *pixaa, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border)

Функции

PIX* pixaaDisplay ( PIXAA pixaa,
l_int32  w,
l_int32  h 
)

pixaaDisplay()

Input: pixaa w, h (if set to 0, determines the size from the b.b. of the components in pixaa) Return: pix, or null on error

Notes: (1) Each pix of the pixaa is displayed at the location given by its box, translated by the box of the containing pixa if it exists.

PIX* pixaaDisplayByPixa ( PIXAA pixaa,
l_int32  xspace,
l_int32  yspace,
l_int32  maxw 
)

pixaaDisplayByPixa()

Input: pixaa xspace between pix in pixa yspace between pixa max width of output pix Return: pix, or null on error

Notes: (1) Displays each pixa on a line (or set of lines), in order from top to bottom. Within each pixa, the pix are displayed in order from left to right. (2) The size of each pix in each pixa is assumed to be approximately equal to the size of the first pix in the pixa. If this assumption is not correct, this function will not work properly. (3) This ignores the boxa of the pixaa.

PIXA* pixaaDisplayTiledAndScaled ( PIXAA pixaa,
l_int32  outdepth,
l_int32  tilewidth,
l_int32  ncols,
l_int32  background,
l_int32  spacing,
l_int32  border 
)

pixaaDisplayTiledAndScaled()

Input: pixaa outdepth (output depth: 1, 8 or 32 bpp) tilewidth (each pix is scaled to this width) ncols (number of tiles in each row) background (0 for white, 1 for black; this is the color of the spacing between the images) spacing (between images, and on outside) border (width of additional black border on each image; use 0 for no border) Return: pixa (of tiled images, one image for each pixa in the pixaa), or null on error

Notes: (1) For each pixa, this generates from all the pix a tiled/scaled output pix, and puts it in the output pixa. (2) See comments in pixaDisplayTiledAndScaled().

PIX* pixaDisplay ( PIXA pixa,
l_int32  w,
l_int32  h 
)

pixaDisplay()

Input: pixa w, h (if set to 0, determines the size from the b.b. of the components in pixa) Return: pix, or null on error

Notes: (1) This uses the boxes to place each pix in the rendered composite. (2) Set w = h = 0 to use the b.b. of the components to determine the size of the returned pix. (3) Uses the first pix in pixa to determine the depth. (4) The background is written "white". On 1 bpp, each successive pix is "painted" (adding foreground), whereas for grayscale or color each successive pix is blitted with just the src. (5) If the pixa is empty, returns an empty 1 bpp pix.

PIX* pixaDisplayOnColor ( PIXA pixa,
l_int32  w,
l_int32  h,
l_uint32  bgcolor 
)

pixaDisplayOnColor()

Input: pixa w, h (if set to 0, determines the size from the b.b. of the components in pixa) color (background color to use) Return: pix, or null on error

Notes: (1) This uses the boxes to place each pix in the rendered composite. (2) Set w = h = 0 to use the b.b. of the components to determine the size of the returned pix. (3) If any pix in are colormapped, or if the pix have different depths, it returns a 32 bpp pix. Otherwise, the depth of the returned pixa equals that of the pix in . (4) If the pixa is empty, return null.

PIX* pixaDisplayOnLattice ( PIXA pixa,
l_int32  xspace,
l_int32  yspace 
)

pixaDisplayOnLattice()

Input: pixa xspace yspace Return: pix of composite images, or null on error

Notes: (1) This places each pix on sequentially on a regular lattice in the rendered composite. If a pix is too large to fit in the allocated lattice space, it is not rendered. (2) If any pix has a colormap, all pix are rendered in rgb. (3) This is useful when putting bitmaps of components, such as characters, into a single image.

PIX* pixaDisplayRandomCmap ( PIXA pixa,
l_int32  w,
l_int32  h 
)

pixaDisplayRandomCmap()

Input: pixa (of 1 bpp components, with boxa) w, h (if set to 0, determines the size from the b.b. of the components in pixa) Return: pix (8 bpp, cmapped, with random colors on the components), or null on error

Notes: (1) This uses the boxes to place each pix in the rendered composite. (2) By default, the background color is: black, cmap index 0. This can be changed by pixcmapResetColor()

PIX* pixaDisplayTiled ( PIXA pixa,
l_int32  maxwidth,
l_int32  background,
l_int32  spacing 
)

pixaDisplayTiled()

Input: pixa maxwidth (of output image) background (0 for white, 1 for black) spacing Return: pix of tiled images, or null on error

Notes: (1) This saves a pixa to a single image file of width not to exceed maxwidth, with background color either white or black, and with each subimage spaced on a regular lattice. (2) The lattice size is determined from the largest width and height, separately, of all pix in the pixa. (3) All pix in the pixa must be of equal depth. (4) If any pix has a colormap, all pix are rendered in rgb. (5) Careful: because no components are omitted, this is dangerous if there are thousands of small components and one or more very large one, because the size of the resulting pix can be huge!

PIX* pixaDisplayTiledAndScaled ( PIXA pixa,
l_int32  outdepth,
l_int32  tilewidth,
l_int32  ncols,
l_int32  background,
l_int32  spacing,
l_int32  border 
)

pixaDisplayTiledAndScaled()

Input: pixa outdepth (output depth: 1, 8 or 32 bpp) tilewidth (each pix is scaled to this width) ncols (number of tiles in each row) background (0 for white, 1 for black; this is the color of the spacing between the images) spacing (between images, and on outside) border (width of additional black border on each image; use 0 for no border) Return: pix of tiled images, or null on error

Notes: (1) This can be used to tile a number of renderings of an image that are at different scales and depths. (2) Each image, after scaling and optionally adding the black border, has width 'tilewidth'. Thus, the border does not affect the spacing between the image tiles. The maximum allowed border width is tilewidth / 5.

PIX* pixaDisplayTiledInRows ( PIXA pixa,
l_int32  outdepth,
l_int32  maxwidth,
l_float32  scalefactor,
l_int32  background,
l_int32  spacing,
l_int32  border 
)

pixaDisplayTiledInRows()

Input: pixa outdepth (output depth: 1, 8 or 32 bpp) maxwidth (of output image) scalefactor (applied to every pix; use 1.0 for no scaling) background (0 for white, 1 for black; this is the color of the spacing between the images) spacing (between images, and on outside) border (width of black border added to each image; use 0 for no border) Return: pixd (of tiled images), or null on error

Notes: (1) This saves a pixa to a single image file of width not to exceed maxwidth, with background color either white or black, and with each row tiled such that the top of each pix is aligned and separated by 'spacing' from the next one. A black border can be added to each pix. (2) All pix are converted to outdepth; existing colormaps are removed. (3) This does a reasonably spacewise-efficient job of laying out the individual pix images into a tiled composite.

PIX* pixaDisplayUnsplit ( PIXA pixa,
l_int32  nx,
l_int32  ny,
l_int32  borderwidth,
l_uint32  bordercolor 
)

pixaDisplayUnsplit()

Input: pixa nx (number of mosaic cells horizontally) ny (number of mosaic cells vertically) borderwidth (of added border on all sides) bordercolor (in our RGBA format: 0xrrggbbaa) Return: pix of tiled images, or null on error

Notes: (1) This is a logical inverse of pixaSplitPix(). It constructs a pix from a mosaic of tiles, all of equal size. (2) For added generality, a border of arbitrary color can be added to each of the tiles. (3) In use, pixa will typically have either been generated from pixaSplitPix() or will derived from a pixa that was so generated. (4) All pix in the pixa must be of equal depth, and, if colormapped, have the same colormap.