Файл src/textops.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "allheaders.h"

Функции

static l_int32 stringAllWhitespace (char *textstr, l_int32 *pval)
static l_int32 stringLeadingWhitespace (char *textstr, l_int32 *pval)
SARRAYbmfGetLineStrings (BMF *bmf, const char *textstr, l_int32 maxw, l_int32 firstindent, l_int32 *ph)
NUMAbmfGetWordWidths (BMF *bmf, const char *textstr, SARRAY *sa)
l_int32 bmfGetStringWidth (BMF *bmf, const char *textstr, l_int32 *pw)
l_int32 pixSetTextblock (PIX *pixs, BMF *bmf, const char *textstr, l_uint32 val, l_int32 x0, l_int32 y0, l_int32 wtext, l_int32 firstindent, l_int32 *poverflow)
l_int32 pixSetTextline (PIX *pixs, BMF *bmf, const char *textstr, l_uint32 val, l_int32 x0, l_int32 y0, l_int32 *pwidth, l_int32 *poverflow)
SARRAYsplitStringToParagraphs (char *textstr, l_int32 splitflag)

Функции

SARRAY* bmfGetLineStrings ( BMF bmf,
const char *  textstr,
l_int32  maxw,
l_int32  firstindent,
l_int32 ph 
)

bmfGetLineStrings()

Input: bmf textstr maxw (max width of a text line in pixels) firstindent (indentation of first line, in x-widths) &h (<return> height required to hold text bitmap) Return: sarray of text strings for each line, or null on error

Notes: (1) Divides the input text string into an array of text strings, each of which will fit withing maxw bits of width.

l_int32 bmfGetStringWidth ( BMF bmf,
const char *  textstr,
l_int32 pw 
)

bmfGetStringWidth()

Input: bmf textstr &w (<return> width of text string, in pixels for the font represented by the bmf) Return: 0 if OK, 1 on error

NUMA* bmfGetWordWidths ( BMF bmf,
const char *  textstr,
SARRAY sa 
)

bmfGetWordWidths()

Input: bmf textstr sa (of individual words) Return: numa (of word lengths in pixels for the font represented by the bmf), or null on error

l_int32 pixSetTextblock ( PIX pixs,
BMF bmf,
const char *  textstr,
l_uint32  val,
l_int32  x0,
l_int32  y0,
l_int32  wtext,
l_int32  firstindent,
l_int32 poverflow 
)

pixSetTextblock()

Input: pixs (input image) bmf (bitmap font data) textstr (block text string to be set) val (color to set the text) x0 (left edge for each line of text) y0 (baseline location for the first text line) wtext (max width of each line of generated text) firstindent (indentation of first line, in x-widths) &overflow (<return> 0 if text is contained in input pix; 1 if it is clipped) Return: 0 if OK, 1 on error

Notes: (1) This function paints a set of lines of text over an image. (2) is the pixel value to be painted through the font mask. For RGB, it is easiest to use hex notation: 0xRRGGBB00, where RR is the hex representation of the red intensity, etc. The last two hex digits are 00 (byte value 0), assigned to the A component. Note that, as usual, RGBA proceeds from left to right in the order from MSB to LSB (see pix.h for details). (3) should be chosen to agree with the depth of pixs. For example, if pixs has 8 bpp, val should be some value between 0 (black) and 255 (white).

l_int32 pixSetTextline ( PIX pixs,
BMF bmf,
const char *  textstr,
l_uint32  val,
l_int32  x0,
l_int32  y0,
l_int32 pwidth,
l_int32 poverflow 
)

pixSetTextline()

Input: pixs (input image) bmf (bitmap font data) textstr (text string to be set on the line) val (color to set the text) x0 (left edge for first char) y0 (baseline location for all text on line) &width (<return> width of generated text) &overflow (<return> 0 if text is contained in input pix; 1 if it is clipped) Return: 0 if OK, 1 on error

Notes: (1) This function paints a line of text over an image. (2) is the pixel value to be painted through the font mask. For RGB, it is easiest to use hex notation: 0xRRGGBB00, where RR is the hex representation of the red intensity, etc. The last two hex digits are 00 (byte value 0), assigned to the A component. Note that, as usual, RGBA proceeds from left to right in the order from MSB to LSB (see pix.h for details). (3) should be chosen to agree with the depth of pixs. For example, if pixs has 8 bpp, val should be some value between 0 (black) and 255 (white).

SARRAY* splitStringToParagraphs ( char *  textstr,
l_int32  splitflag 
)

splitStringToParagraphs()

Input: textstring splitting flag (see enum in bmf.h; valid values in {1,2,3}) Return: sarray (where each string is a paragraph of the input), or null on error.

static l_int32 stringAllWhitespace ( char *  textstr,
l_int32 pval 
) [static]

stringAllWhitespace()

Input: textstring &val (<return> 1 if all whitespace; 0 otherwise) Return: 0 if OK, 1 on error

static l_int32 stringLeadingWhitespace ( char *  textstr,
l_int32 pval 
) [static]

stringLeadingWhitespace()

Input: textstring &val (<return> 1 if leading char is ' ' or ''; 0 otherwise) Return: 0 if OK, 1 on error


Документация по Leptonica. Последние изменения: Fri Aug 7 20:31:38 2009. Создано системой  doxygen 1.5.9