types.cpp

来自「Ocr source code. provides an Ocr engine 」· C++ 代码 · 共 102 行

CPP
102
字号
/* types.cpp : code for classes (fully) defined in types.h * Author: Maxie D. Schmidt (created 5/20/2006)             */#include "types.h"#include "classnotes.h"#include "runutils.h"xy_point NULL_POINT() {     xy_point r_val;     r_val.x = r_val.y = -1;     return r_val;}box_t NULL_BOX() {     box_t r_val;     r_val.xy = NULL_POINT();     return r_val;}box_points NULL_PTS() {     box_points r_val;     r_val.r_most.x = r_val.r_most.y = -1;     return r_val;}png_file::png_file() {     is_valid = false;     filename = "";     height = width = 0;     buf = NULL;     tracks = NULL;     tracks_num_bytes = 0;          parsed = false;     scan_starting_line_num = 0;     plist = NULL;}png_file::~png_file() {     if(buf != NULL) {                    free(buf);          free(tracks);     }}// checks for black pixels or pixels within a range of (r, g, b) = (0, 0, 0);// the range is: r, g, b <= 100;bool png_file::grid(int row, int col) {     if((row >= height) || (col >= width) || (row < 0) || (col < 0))          return false;          unsigned char *ptr = buf + (row * width * 3) + (col * 3);     if(within_interval(*ptr, *(ptr + 1), *(ptr + 2), grid_rgb_int))          return true;          return false;}void png_file::mark(int row, int col) {     if((row >= height) || (row < 0) || (col >= width) || (col < 0))          return;     int byte_pos = (row * width + col) % 8;     unsigned char byte = (0x80 >> byte_pos);     *(tracks + ((row * width + col) / 8)) = byte |                                       (*(tracks + ((row * width + col) / 8)));}bool png_file::is_marked(int row, int col) {     if((row >= height) || (row < 0) || (col >= width) || (col < 0))          return false;     int byte = *(tracks + ((row * width + col) / 8));     int byte_pos = (row * width + col) % 8;     return ((0x80 >> byte_pos) & byte);}void png_file::cleanup_tracks() {     for(int i = 0; i < tracks_num_bytes; i++)          *(tracks + i) = 0x00;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?