⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 types.cpp

📁 Ocr source code. provides an Ocr engine that works in C++ language.
💻 CPP
字号:
/* 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -