All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
blread.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * File: blread.cpp (Formerly pdread.c)
3  * Description: Friend function of BLOCK to read the uscan pd file.
4  * Author: Ray Smith
5  * Created: Mon Mar 18 14:39:00 GMT 1991
6  *
7  * (C) Copyright 1991, Hewlett-Packard Ltd.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #include <stdlib.h>
21 #ifdef __UNIX__
22 #include <assert.h>
23 #endif
24 #include "scanutils.h"
25 #include "fileerr.h"
26 #include "blread.h"
27 
28 #define UNLV_EXT ".uzn" // unlv zone file
29 
30 /**********************************************************************
31  * read_unlv_file
32  *
33  * Read a whole unlv zone file to make a list of blocks.
34  **********************************************************************/
35 
36 bool read_unlv_file( //print list of sides
37  STRING name, //basename of file
38  inT32 xsize, //image size
39  inT32 ysize, //image size
40  BLOCK_LIST *blocks //output list
41  ) {
42  FILE *pdfp; //file pointer
43  BLOCK *block; //current block
44  int x; //current top-down coords
45  int y;
46  int width; //of current block
47  int height;
48  BLOCK_IT block_it = blocks; //block iterator
49 
50  name += UNLV_EXT; //add extension
51  if ((pdfp = fopen (name.string (), "rb")) == NULL) {
52  return false; //didn't read one
53  } else {
54  while (tfscanf(pdfp, "%d %d %d %d %*s", &x, &y, &width, &height) >= 4) {
55  //make rect block
56  block = new BLOCK (name.string (), TRUE, 0, 0,
57  (inT16) x, (inT16) (ysize - y - height),
58  (inT16) (x + width), (inT16) (ysize - y));
59  //on end of list
60  block_it.add_to_end (block);
61  }
62  fclose(pdfp);
63  }
64  return true;
65 }
66 
67 void FullPageBlock(int width, int height, BLOCK_LIST *blocks) {
68  BLOCK_IT block_it(blocks);
69  BLOCK* block = new BLOCK("", TRUE, 0, 0, 0, 0, width, height);
70  block_it.add_to_end(block);
71 }
int tfscanf(FILE *stream, const char *format,...)
Definition: scanutils.cpp:229
void FullPageBlock(int width, int height, BLOCK_LIST *blocks)
Definition: blread.cpp:67
#define UNLV_EXT
Definition: blread.cpp:28
name_table name
Definition: ocrblock.h:30
#define TRUE
Definition: capi.h:28
Definition: strngs.h:44
#define NULL
Definition: host.h:144
const char * string() const
Definition: strngs.cpp:193
bool read_unlv_file(STRING name, inT32 xsize, inT32 ysize, BLOCK_LIST *blocks)
Definition: blread.cpp:36
short inT16
Definition: host.h:100
int inT32
Definition: host.h:102