tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/ccstruct/blread.cpp
Go to the documentation of this file.
00001 /**********************************************************************
00002  * File:        blread.cpp  (Formerly pdread.c)
00003  * Description: Friend function of BLOCK to read the uscan pd file.
00004  * Author:              Ray Smith
00005  * Created:             Mon Mar 18 14:39:00 GMT 1991
00006  *
00007  * (C) Copyright 1991, Hewlett-Packard Ltd.
00008  ** Licensed under the Apache License, Version 2.0 (the "License");
00009  ** you may not use this file except in compliance with the License.
00010  ** You may obtain a copy of the License at
00011  ** http://www.apache.org/licenses/LICENSE-2.0
00012  ** Unless required by applicable law or agreed to in writing, software
00013  ** distributed under the License is distributed on an "AS IS" BASIS,
00014  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  ** See the License for the specific language governing permissions and
00016  ** limitations under the License.
00017  *
00018  **********************************************************************/
00019 
00020 #include          <stdlib.h>
00021 #ifdef __UNIX__
00022 #include          <assert.h>
00023 #endif
00024 #include          "scanutils.h"
00025 #include          "fileerr.h"
00026 #include          "blread.h"
00027 
00028 #define UNLV_EXT  ".uzn"  // unlv zone file
00029 
00030 /**********************************************************************
00031  * read_unlv_file
00032  *
00033  * Read a whole unlv zone file to make a list of blocks.
00034  **********************************************************************/
00035 
00036 bool read_unlv_file(                    //print list of sides
00037                      STRING name,        //basename of file
00038                      inT32 xsize,        //image size
00039                      inT32 ysize,        //image size
00040                      BLOCK_LIST *blocks  //output list
00041                     ) {
00042   FILE *pdfp;                    //file pointer
00043   BLOCK *block;                  //current block
00044   int x;                         //current top-down coords
00045   int y;
00046   int width;                     //of current block
00047   int height;
00048   BLOCK_IT block_it = blocks;    //block iterator
00049 
00050   name += UNLV_EXT;              //add extension
00051   if ((pdfp = fopen (name.string (), "rb")) == NULL) {
00052     return false;                //didn't read one
00053   }
00054   else {
00055     while (fscanf (pdfp, "%d %d %d %d %*s", &x, &y, &width, &height) >= 4) {
00056                                  //make rect block
00057       block = new BLOCK (name.string (), TRUE, 0, 0,
00058                          (inT16) x, (inT16) (ysize - y - height),
00059                          (inT16) (x + width), (inT16) (ysize - y));
00060                                  //on end of list
00061       block_it.add_to_end (block);
00062     }
00063     fclose(pdfp);
00064   }
00065   return true;
00066 }
00067 
00068 void FullPageBlock(int width, int height, BLOCK_LIST *blocks) {
00069   BLOCK_IT block_it(blocks);
00070   BLOCK* block = new BLOCK("", TRUE, 0, 0, 0, 0, width, height);
00071   block_it.add_to_end(block);
00072 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines