tesseract  4.0.0-1-g2a2b
blread.cpp File Reference
#include "blread.h"
#include <cstdio>
#include "host.h"
#include "ocrblock.h"
#include "scanutils.h"

Go to the source code of this file.

Macros

#define UNLV_EXT   ".uzn"
 

Functions

bool read_unlv_file (STRING name, int32_t xsize, int32_t ysize, BLOCK_LIST *blocks)
 
void FullPageBlock (int width, int height, BLOCK_LIST *blocks)
 

Macro Definition Documentation

◆ UNLV_EXT

#define UNLV_EXT   ".uzn"

Definition at line 26 of file blread.cpp.

Function Documentation

◆ FullPageBlock()

void FullPageBlock ( int  width,
int  height,
BLOCK_LIST *  blocks 
)

Definition at line 65 of file blread.cpp.

65  {
66  BLOCK_IT block_it(blocks);
67  BLOCK* block = new BLOCK("", TRUE, 0, 0, 0, 0, width, height);
68  block_it.add_to_end(block);
69 }
#define TRUE
Definition: capi.h:51
Definition: ocrblock.h:30

◆ read_unlv_file()

bool read_unlv_file ( STRING  name,
int32_t  xsize,
int32_t  ysize,
BLOCK_LIST *  blocks 
)

Definition at line 34 of file blread.cpp.

39  {
40  FILE *pdfp; //file pointer
41  BLOCK *block; //current block
42  int x; //current top-down coords
43  int y;
44  int width; //of current block
45  int height;
46  BLOCK_IT block_it = blocks; //block iterator
47 
48  name += UNLV_EXT; //add extension
49  if ((pdfp = fopen (name.string (), "rb")) == nullptr) {
50  return false; //didn't read one
51  } else {
52  while (tfscanf(pdfp, "%d %d %d %d %*s", &x, &y, &width, &height) >= 4) {
53  //make rect block
54  block = new BLOCK (name.string (), TRUE, 0, 0,
55  (int16_t) x, (int16_t) (ysize - y - height),
56  (int16_t) (x + width), (int16_t) (ysize - y));
57  //on end of list
58  block_it.add_to_end (block);
59  }
60  fclose(pdfp);
61  }
62  return true;
63 }
int tfscanf(FILE *stream, const char *format,...)
Definition: scanutils.cpp:192
#define TRUE
Definition: capi.h:51
const char * string() const
Definition: strngs.cpp:196
Definition: ocrblock.h:30
#define UNLV_EXT
Definition: blread.cpp:26