Файл src/boxbasic.c

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

Функции

BOXboxCreate (l_int32 x, l_int32 y, l_int32 w, l_int32 h)
BOXboxCopy (BOX *box)
BOXboxClone (BOX *box)
void boxDestroy (BOX **pbox)
l_int32 boxGetGeometry (BOX *box, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
l_int32 boxSetGeometry (BOX *box, l_int32 x, l_int32 y, l_int32 w, l_int32 h)
l_int32 boxGetRefcount (BOX *box)
l_int32 boxChangeRefcount (BOX *box, l_int32 delta)
BOXAboxaCreate (l_int32 n)
BOXAboxaCopy (BOXA *boxa, l_int32 copyflag)
void boxaDestroy (BOXA **pboxa)
l_int32 boxaAddBox (BOXA *boxa, BOX *box, l_int32 copyflag)
l_int32 boxaExtendArray (BOXA *boxa)
l_int32 boxaGetCount (BOXA *boxa)
BOXboxaGetBox (BOXA *boxa, l_int32 index, l_int32 accessflag)
l_int32 boxaGetBoxGeometry (BOXA *boxa, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph)
l_int32 boxaReplaceBox (BOXA *boxa, l_int32 index, BOX *box)
l_int32 boxaInsertBox (BOXA *boxa, l_int32 index, BOX *box)
l_int32 boxaRemoveBox (BOXA *boxa, l_int32 index)
BOXAAboxaaCreate (l_int32 n)
BOXAAboxaaCopy (BOXAA *baas, l_int32 copyflag)
void boxaaDestroy (BOXAA **pbaa)
l_int32 boxaaAddBoxa (BOXAA *baa, BOXA *ba, l_int32 copyflag)
l_int32 boxaaExtendArray (BOXAA *baa)
l_int32 boxaaGetCount (BOXAA *baa)
l_int32 boxaaGetBoxCount (BOXAA *baa)
BOXAboxaaGetBoxa (BOXAA *baa, l_int32 index, l_int32 accessflag)
l_int32 boxaaReplaceBoxa (BOXAA *baa, l_int32 index, BOXA *boxa)
l_int32 boxaaInsertBoxa (BOXAA *baa, l_int32 index, BOXA *boxa)
l_int32 boxaaRemoveBoxa (BOXAA *baa, l_int32 index)
l_int32 boxaaAddBox (BOXAA *baa, l_int32 index, BOX *box, l_int32 accessflag)
BOXAAboxaaRead (const char *filename)
BOXAAboxaaReadStream (FILE *fp)
l_int32 boxaaWrite (const char *filename, BOXAA *baa)
l_int32 boxaaWriteStream (FILE *fp, BOXAA *baa)
BOXAboxaRead (const char *filename)
BOXAboxaReadStream (FILE *fp)
l_int32 boxaWrite (const char *filename, BOXA *boxa)
l_int32 boxaWriteStream (FILE *fp, BOXA *boxa)
l_int32 boxPrintStreamInfo (FILE *fp, BOX *box)
BOXAAboxaaReadVersion2 (const char *filename)
BOXAAboxaaReadStreamVersion2 (FILE *fp)

Переменные

static const l_int32 INITIAL_PTR_ARRAYSIZE = 20

Функции

l_int32 boxaaAddBox ( BOXAA baa,
l_int32  index,
BOX box,
l_int32  accessflag 
)

boxaaAddBox()

Input: boxaa index (of boxa with boxaa) box (to be added) accessflag (L_INSERT, L_COPY or L_CLONE) Return: 0 if OK, 1 on error

Notes: (1) Adds to an existing boxa only.

l_int32 boxaaAddBoxa ( BOXAA baa,
BOXA ba,
l_int32  copyflag 
)

boxaaAddBoxa()

Input: boxaa boxa (to be added) copyflag (L_INSERT, L_COPY, L_CLONE) Return: 0 if OK, 1 on error

BOXAA* boxaaCopy ( BOXAA baas,
l_int32  copyflag 
)

boxaaCopy()

Input: baas (input boxaa to be copied) copyflag (L_COPY, L_CLONE) Return: baad (new boxaa, composed of copies or clones of the boxa in baas), or null on error

Notes: (1) L_COPY makes a copy of each boxa in baas. L_CLONE makes a clone of each boxa in baas.

BOXAA* boxaaCreate ( l_int32  n  ) 

boxaaCreate()

Input: size of boxa ptr array to be alloc'd (0 for default) Return: baa, or null on error

l_int32 boxaAddBox ( BOXA boxa,
BOX box,
l_int32  copyflag 
)

boxaAddBox()

Input: boxa box (to be added) copyflag (L_INSERT, L_COPY, L_CLONE) Return: 0 if OK, 1 on error

void boxaaDestroy ( BOXAA **  pbaa  ) 

boxaaDestroy()

Input: &boxaa (<will be="" set="" to="" null="" before="" returning>="">) Return: void

l_int32 boxaaExtendArray ( BOXAA baa  ) 

boxaaExtendArray()

Input: boxaa Return: 0 if OK, 1 on error

BOXA* boxaaGetBoxa ( BOXAA baa,
l_int32  index,
l_int32  accessflag 
)

boxaaGetBoxa()

Input: boxaa index (to the index-th boxa) accessflag (L_COPY or L_CLONE) Return: boxa, or null on error

l_int32 boxaaGetBoxCount ( BOXAA baa  ) 

boxaaGetBoxCount()

Input: boxaa Return: count (number of boxes), or 0 if no boxes or on error

l_int32 boxaaGetCount ( BOXAA baa  ) 

boxaaGetCount()

Input: boxaa Return: count (number of boxa), or 0 if no boxa or on error

l_int32 boxaaInsertBoxa ( BOXAA baa,
l_int32  index,
BOXA boxa 
)

boxaaInsertBoxa()

Input: boxaa index (location in boxaa to insert new boxa) boxa (new boxa to be inserted) Return: 0 if OK, 1 on error

Notes: (1) This shifts boxa[i] --> boxa[i + 1] for all i >= index, and then inserts boxa as boxa[index]. (2) To insert at the beginning of the array, set index = 0. (3) To append to the array, it's easier to use boxaaAddBoxa(). (4) This should not be used repeatedly to insert into large arrays, because the function is O(n).

BOXAA* boxaaRead ( const char *  filename  ) 

boxaaRead()

Input: filename Return: boxaa, or null on error

BOXAA* boxaaReadStream ( FILE *  fp  ) 

boxaaReadStream()

Input: stream Return: boxaa, or null on error

BOXAA* boxaaReadStreamVersion2 ( FILE *  fp  ) 

boxaaReadStreamVersion2()

Input: stream Return: boxaa, or null on error

BOXAA* boxaaReadVersion2 ( const char *  filename  ) 

boxaaReadVersion2()

Input: filename Return: boxaa, or null on error

Notes: (1) These old functions only work on version 2 boxaa. They will go to an archive directory sometime after Sept 2009. (2) The current format uses BOXAA_VERSION_NUMBER == 3)

l_int32 boxaaRemoveBoxa ( BOXAA baa,
l_int32  index 
)

boxaaRemoveBoxa()

Input: boxaa index (of the boxa to be removed) Return: 0 if OK, 1 on error

Notes: (1) This removes boxa[index] and then shifts boxa[i] --> boxa[i - 1] for all i > index. (2) The removed boxaa is destroyed. (2) This should not be used repeatedly on large arrays, because the function is O(n).

l_int32 boxaaReplaceBoxa ( BOXAA baa,
l_int32  index,
BOXA boxa 
)

boxaaReplaceBoxa()

Input: boxaa index (to the index-th boxa) boxa (insert and replace any existing one) Return: 0 if OK, 1 on error

Notes: (1) Any existing boxa is destroyed, and the input one is inserted in its place. (2) If the index is invalid, return 1 (error)

l_int32 boxaaWrite ( const char *  filename,
BOXAA baa 
)

boxaaWrite()

Input: filename boxaa Return: 0 if OK, 1 on error

l_int32 boxaaWriteStream ( FILE *  fp,
BOXAA baa 
)

boxaaWriteStream()

Input: stream boxaa Return: 0 if OK, 1 on error

BOXA* boxaCopy ( BOXA boxa,
l_int32  copyflag 
)

boxaCopy()

Input: boxa copyflag (L_COPY, L_CLONE, L_COPY_CLONE) Return: new boxa, or null on error

Notes: (1) See pix.h for description of the copyflag. (2) The copy-clone makes a new boxa that holds clones of each box.

BOXA* boxaCreate ( l_int32  n  ) 

boxaCreate()

Input: n (initial number of ptrs) Return: boxa, or null on error

void boxaDestroy ( BOXA **  pboxa  ) 

boxaDestroy()

Input: &boxa (<will be="" set="" to="" null="" before="" returning>="">) Return: void

Note:

  • Decrements the ref count and, if 0, destroys the boxa.
  • Always nulls the input ptr.

l_int32 boxaExtendArray ( BOXA boxa  ) 

boxaExtendArray()

Input: boxa Return: 0 if OK; 1 on error

BOX* boxaGetBox ( BOXA boxa,
l_int32  index,
l_int32  accessflag 
)

boxaGetBox()

Input: boxa index (to the index-th box) accessflag (L_COPY or L_CLONE) Return: box, or null on error

l_int32 boxaGetBoxGeometry ( BOXA boxa,
l_int32  index,
l_int32 px,
l_int32 py,
l_int32 pw,
l_int32 ph 
)

boxaGetBoxGeometry()

Input: boxa index (to the index-th box) &x, &y, &w, &h (<optional return>="">; each can be null) Return: 0 if OK, 1 on error

l_int32 boxaGetCount ( BOXA boxa  ) 

boxaGetCount()

Input: boxa Return: count, or 0 on error

l_int32 boxaInsertBox ( BOXA boxa,
l_int32  index,
BOX box 
)

boxaInsertBox()

Input: boxa index (location in boxa to insert new value) box (new box to be inserted) Return: 0 if OK, 1 on error

Notes: (1) This shifts box[i] --> box[i + 1] for all i >= index, and then inserts box as box[index]. (2) To insert at the beginning of the array, set index = 0. (3) To append to the array, it's easier to use boxaAddBox(). (4) This should not be used repeatedly to insert into large arrays, because the function is O(n).

BOXA* boxaRead ( const char *  filename  ) 

boxaRead()

Input: filename Return: boxa, or null on error

BOXA* boxaReadStream ( FILE *  fp  ) 

boxaReadStream()

Input: stream Return: boxa, or null on error

l_int32 boxaRemoveBox ( BOXA boxa,
l_int32  index 
)

boxaRemoveBox()

Input: boxa index (of box to be removed) Return: 0 if OK, 1 on error

Notes: (1) This removes box[index] and then shifts box[i] --> box[i - 1] for all i > index. (2) It should not be used repeatedly to remove boxes from large arrays, because the function is O(n).

l_int32 boxaReplaceBox ( BOXA boxa,
l_int32  index,
BOX box 
)

boxaReplaceBox()

Input: boxa index (to the index-th box) box (insert to replace existing one) Return: 0 if OK, 1 on error

Notes: (1) In-place replacement of one box. (2) The previous box at that location is destroyed.

l_int32 boxaWrite ( const char *  filename,
BOXA boxa 
)

boxaWrite()

Input: filename boxa Return: 0 if OK, 1 on error

l_int32 boxaWriteStream ( FILE *  fp,
BOXA boxa 
)

boxaWriteStream()

Input: stream boxa Return: 0 if OK, 1 on error

l_int32 boxChangeRefcount ( BOX box,
l_int32  delta 
)

BOX* boxClone ( BOX box  ) 

boxClone()

Input: box Return: ptr to same box, or null on error

BOX* boxCopy ( BOX box  ) 

boxCopy()

Input: box Return: copy of box, or null on error

BOX* boxCreate ( l_int32  x,
l_int32  y,
l_int32  w,
l_int32  h 
)

boxCreate()

Input: x, y, width, height Return: box, or null on error

Notes: (1) This clips the box to the +quad. If no part of the box is in the +quad, this returns NULL.

void boxDestroy ( BOX **  pbox  ) 

boxDestroy()

Input: &box (<will be="" set="" to="" null="" before="" returning>="">) Return: void

Notes: (1) Decrements the ref count and, if 0, destroys the box. (2) Always nulls the input ptr.

l_int32 boxGetGeometry ( BOX box,
l_int32 px,
l_int32 py,
l_int32 pw,
l_int32 ph 
)

boxGetGeometry()

Input: box &x, &y, &w, &h (<optional return>="">; each can be null) Return: 0 if OK, 1 on error

l_int32 boxGetRefcount ( BOX box  ) 

l_int32 boxPrintStreamInfo ( FILE *  fp,
BOX box 
)

boxPrintStreamInfo()

Input: stream box Return: 0 if OK, 1 on error

Notes: (1) This outputs information about the box, for debugging. (2) Use serialization functions to write to file if you want to read the data back.

l_int32 boxSetGeometry ( BOX box,
l_int32  x,
l_int32  y,
l_int32  w,
l_int32  h 
)

boxSetGeometry()

Input: box x, y, w, h (use -1 to leave unchanged) Return: 0 if OK, 1 on error


Переменные

const l_int32 INITIAL_PTR_ARRAYSIZE = 20 [static]


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