Main Page | Class List | File List | Class Members | File Members

gocr_image.h

Go to the documentation of this file.
00001 /* 00002 GOCR Copyright (C) 2000 Joerg Schulenburg Joerg.Schulenburg@physik.uni-magdeburg.de 00003 GOCR API Copyright (C) 2001 Bruno Barberi Gnecco <brunobg@sourceforge.net> 00004 00005 This program is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU General Public License 00007 as published by the Free Software Foundation; either version 2 00008 of the License, or (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 */ 00020 00021 00022 #ifndef _GOCR_IMAGE_H 00023 #define _GOCR_IMAGE_H 00024 00025 #ifndef _GOCR_MODULE_H 00026 # error "Do not call gocr_gui.h directly; call gocr_module.h instead." 00027 #endif. 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00045 #define GOCR_BLACK 0 00046 00050 #define GOCR_WHITE 1 00051 00052 00056 enum gocr_imagetype { 00057 GOCR_NONE, 00058 GOCR_BW, 00059 GOCR_GRAY, 00060 GOCR_COLOR, 00061 GOCR_OTHER 00062 }; 00066 typedef enum gocr_imagetype gocr_ImageType; 00067 00074 struct gocr_pixelbw { 00075 unsigned char value : 1; 00076 unsigned char mark1 : 1; 00077 unsigned char mark2 : 1; 00078 unsigned char mark3 : 1; 00079 unsigned char isblock : 1; 00080 unsigned char ischar : 1; 00081 unsigned char private1 : 1; 00082 unsigned char private2 : 1; 00083 }; 00087 typedef struct gocr_pixelbw gocr_PixelBW; 00088 00089 struct gocr_pixelgray { 00090 unsigned char pad : 1; 00091 unsigned char mark1 : 1; 00092 unsigned char mark2 : 1; 00093 unsigned char mark3 : 1; 00094 unsigned char isblock : 1; 00095 unsigned char ischar : 1; 00096 unsigned char private1 : 1; 00097 unsigned char private2 : 1; 00099 unsigned char value; 00100 }; 00101 typedef struct gocr_pixelgray gocr_PixelGray; 00102 00103 struct gocr_pixelcolor { 00104 unsigned char pad : 1; 00105 unsigned char mark1 : 1; 00106 unsigned char mark2 : 1; 00107 unsigned char mark3 : 1; 00108 unsigned char isblock : 1; 00109 unsigned char ischar : 1; 00110 unsigned char private1 : 1; 00111 unsigned char private2 : 1; 00113 unsigned char value[3]; 00114 }; 00115 typedef struct gocr_pixelcolor gocr_PixelColor; 00116 00117 00124 struct gocr_pixel { 00125 unsigned char pad : 1; 00126 unsigned char mark1 : 1; 00127 unsigned char mark2 : 1; 00128 unsigned char mark3 : 1; 00129 unsigned char isblock : 1; 00130 unsigned char ischar : 1; 00131 unsigned char private1 : 1; 00132 unsigned char private2 : 1; 00134 char value[0]; 00135 }; 00136 typedef struct gocr_pixel gocr_Pixel; 00137 00144 struct gocr_image { 00145 char *filename; 00146 int width, height; 00147 gocr_ImageType type; 00149 union { 00150 gocr_Pixel **pix; 00151 gocr_PixelBW **bw; 00152 gocr_PixelGray **gray; 00153 gocr_PixelColor **color; 00154 } data; 00155 00156 /* you are unlikely to change these below. Future: hide them */ 00157 unsigned char *mask; 00158 int threshold; 00159 int sons; 00160 struct gocr_image *parent; 00161 }; 00162 00166 typedef struct gocr_image gocr_Image; 00167 00168 /* image.c */ 00169 extern void gocr_imageFree ( gocr_Image *image ); 00170 extern int gocr_imageWrite ( gocr_Image *image, char *filename ); 00171 extern int gocr_mainImageWriteWithData ( char *filename ); 00172 00173 /* pixel.c */ 00174 extern inline int gocr_pixelGetMark1 ( gocr_Image *image, int x, int y ); 00175 extern inline int gocr_pixelSetMark1 ( gocr_Image *image, int x, int y, char value ); 00176 extern inline int gocr_pixelGetMark2 ( gocr_Image *image, int x, int y ); 00177 extern inline int gocr_pixelSetMark2 ( gocr_Image *image, int x, int y, char value ); 00178 extern inline int gocr_pixelGetMark3 ( gocr_Image *image, int x, int y ); 00179 extern inline int gocr_pixelSetMark3 ( gocr_Image *image, int x, int y, char value ); 00180 00181 #define gocr_isblock(image, x, y) \ 00182 ((gocr_Pixel *)((image)->data.pix[y]+(x)*_gocr_imagePixelSize(image)))->isblock 00183 #define gocr_ischar(image, x, y) \ 00184 ((gocr_Pixel *)((image)->data.pix[y]+(x)*_gocr_imagePixelSize(image)))->ischar 00185 00186 00187 extern void gocr_imagePixelSetBW ( gocr_Image *image, int x, int y, 00188 unsigned char data ); 00189 extern unsigned char gocr_imagePixelGetBW ( gocr_Image *image, int x, int y ); 00190 extern void gocr_imagePixelSetGray ( gocr_Image *image, int x, int y, 00191 unsigned char data ); 00192 extern unsigned char gocr_imagePixelGetGray ( gocr_Image *image, int x, int y ); 00193 extern void gocr_imagePixelSetColor ( gocr_Image *image, int x, int y, 00194 unsigned char data[3] ); 00195 extern unsigned char *gocr_imagePixelGetColor ( gocr_Image *image, int x, int y ); 00196 00199 #ifdef _GOCR_INTERNAL_H /*ok, this #ifdef sucks, but is a quick hack */ 00200 00201 extern int _gocr_imageLoad ( const char *filename, void *data ); 00202 extern size_t _gocr_imagePixelSize ( gocr_Image *image ); 00203 extern int _gocr_thresholdGrayToBW ( gocr_Image *image ); 00204 00205 #define _gocr_private1(image, x, y) \ 00206 ((gocr_Pixel *)((image)->data.pix[y]+(x)*_gocr_imagePixelSize(image)))->private1 00207 #define _gocr_private2(image, x, y) \ 00208 ((gocr_Pixel *)((image)->data.pix[y]+(x)*_gocr_imagePixelSize(image)))->private2 00209 #define _gocr_maskGet(img, x, y) \ 00210 !!(img->mask[(((y)*(img)->width+(x))>>3)]&(((y)*img->width+(x))%8)) 00211 #define _gocr_maskSet(img, x, y, v) \ 00212 img->mask[(((y)*(img)->width+(x))>>3)] &= ((v)&(1<<((y)*img->width+(x))%8)) 00213 #endif 00214 00221 extern gocr_Image *currentimage; 00222 00223 #ifdef __cplusplus 00224 } 00225 #endif 00226 00227 #endif

Generated on Thu Jul 29 16:43:27 2004 for GOCR API by doxygen 1.3.7