This file is indexed.

/usr/include/tesseract/img.h is in libtesseract-dev 3.02.01-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
/**********************************************************************
 * File:        img.h  (Formerly image.h)
 * Description: Class definition for the IMAGE class.
 * Author:      Ray Smith
 * Created:     Thu Jun 07 13:42:37 BST 1990
 *
 * (C) Copyright 1990, Hewlett-Packard Ltd.
 ** Licensed under the Apache License, Version 2.0 (the "License");
 ** you may not use this file except in compliance with the License.
 ** You may obtain a copy of the License at
 ** http://www.apache.org/licenses/LICENSE-2.0
 ** Unless required by applicable law or agreed to in writing, software
 ** distributed under the License is distributed on an "AS IS" BASIS,
 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 ** See the License for the specific language governing permissions and
 ** limitations under the License.
 *
 **********************************************************************/

#ifndef           IMG_H
#define           IMG_H

#include          "memry.h"

struct Pix;

/** 14inch * 400dpi */
#define MAXIMAGEWIDTH   (900*14) 

/** 14inch * 400dpi */
#define MAXIMAGEHEIGHT    (900*14)

#define COMPUTE_IMAGE_XDIM(xsize,bpp) ((bpp)>8 ? ((xsize)*(bpp)+7)/8 :((xsize)+8/(bpp)-1)/(8/(bpp)))

typedef inT8 (*IMAGE_OPENER) (int, inT32 *, inT32 *, inT8 *, inT8 *, inT32 *);
typedef inT8 (*IMAGE_READER) (int, uinT8 *, inT32, inT32, inT8, inT32);
typedef inT8 (*IMAGE_WRITER) (int, uinT8 *, inT32, inT32, inT8, inT8, inT32);

/** array of colours */
typedef uinT8 *COLOUR_PIX;
enum COLOUR_PIX_NAME
{
  RED_PIX,
  GREEN_PIX,
  BLUE_PIX
};

class DLLSYM IMAGELINE;

/** encapsulated image */
class DLLSYM IMAGE
{
  public:
    IMAGE();  //constructor

    ~IMAGE () {                  //destructor
      destroy();  //free memory
    }

    IMAGE & operator= (          //assignment
      IMAGE & source);

    /** 
     * create blank image
     * @param x x size required
     * @param y y size required
     * @param bits_per_pixel bpp required
     */
    inT8 create(inT32 x,
                inT32 y,
                inT8 bits_per_pixel);

    /** 
     * capture raw image
     * @param pixels pixels to capture
     * @param x x size required
     * @param y y size required
     * @param bits_per_pixel bpp required
     */
    inT8 capture(uinT8 *pixels,
                 inT32 x,
                 inT32 y,
                 inT8 bits_per_pixel);

    /** destroy image */
    void destroy();

    /** 
     * access function
     * @return xsize
     */
    inT32 get_xsize() {
      return xsize;
    }
    /** 
     * access function
     * @return ysize
     */
    inT32 get_ysize() {
      return ysize;
    }
    /** 
     * access function
     * @return bits per pixel
     */
    inT8 get_bpp() {
      return bpp;
    }
    /** 
     * access function
     * @return bits per sample
     */
    inT8 get_bps() {
      return bps;
    }
    /** photo interp */
    BOOL8 white_high() {
      return photo_interp;
    }
    /** access function */
    uinT8 get_white_level() {
      return (1 << bpp) - 1;
    }
    /** get resolution */
    inT32 get_res() {
      return res;
    }
    /** set resolution */
    void set_res(inT32 resolution) {
      res = resolution;
    }
    uinT8 *get_buffer() {
      return image;
    }

    /** 
     * access pixel
     * @param x coord
     * @param y coord
     */
    uinT8 pixel(inT32 x,
                inT32 y);

    /** 
     * get image line
     * @param x coord to start at
     * @param y line to get
     * @param width line to get
     * @param linebuf line to copy to
     */
    void fast_get_line(inT32 x,
                       inT32 y,
                       inT32 width,
                       IMAGELINE *linebuf);

    /** 
     * get image line
     * @param x coord to start at
     * @param y line to get
     * @param width line to get
     * @param linebuf line to copy to
     * @param margins size of margins
     */
    void get_line(inT32 x,
                  inT32 y,
                  inT32 width,
                  IMAGELINE *linebuf,
                  inT32 margins);
    /** 
     * get image column
     * @param x coord to start at
     * @param y line to get
     * @param height number of pixels to get
     * @param linebuf line to copy to
     * @param margins size of margins
     */
    void get_column(inT32 x,
                    inT32 y,
                    inT32 height,
                    IMAGELINE *linebuf,
                    inT32 margins);

    /** 
     * put image line
     * @param x coord to start at
     * @param y line to put
     * @param width number of pixels to put
     * @param linebuf line to copy from
     */
    void fast_put_line(inT32 x,
                       inT32 y,
                       inT32 width,
                       IMAGELINE *linebuf);

    /** 
     * put image line
     * @param x coord to start at
     * @param y line to put
     * @param width number of pixels to put
     * @param linebuf line to copy from
     * @param margins size of margins
     */
    void put_line(inT32 x,
                  inT32 y,
                  inT32 width,
                  IMAGELINE *linebuf,
                  inT32 margins);
    /** 
     * put image column
     * @param x coord to start at
     * @param y line to put
     * @param height number of pixels to put
     * @param linebuf line to copy to
     * @param margins size of margins
     */
    void put_column(inT32 x,
                    inT32 y,
                    inT32 height,
                    IMAGELINE *linebuf,
                    inT32 margins);

    /** 
     * check coordinates
     * @param x xcoord to check
     * @param y ycoord to check
     */
    void check_legal_access(inT32 x,
                            inT32 y,
                            inT32 xext);


    /** Methods to convert image types. Only available if Leptonica is available. */
    Pix* ToPix();
    void FromPix(const Pix* src_pix);

    /** 
     * Map function over window
     * @param win_width Window width
     * @param win_height Window height
     * @param convolve Conv function
     */
    void convolver (
      inT32 win_width,
      inT32 win_height,
      void (*convolve) (
      uinT8 ** pixels,           ///< Of window
      uinT8 bytespp,             ///< 1 or 3 for colour
      inT32 win_wd,              ///< Window width
      inT32 win_ht,              ///< Window height
      uinT8 ret_white_value,     ///< White value to RETURN
      uinT8 * result             ///< Result pixel(s)
      ));

                                 //copy rectangle
    friend DLLSYM void copy_sub_image(IMAGE *source,  //source image
                                      inT32 xstart,   //start coords
                                      inT32 ystart,
                                      inT32 xext,     //extent to copy
                                      inT32 yext,
                                      IMAGE *dest,    //destination image
                                      inT32 xdest,    //destination coords //shift to match bpp
                                      inT32 ydest,
                                      BOOL8 adjust_grey);

                                 //enlarge rectangle
    friend DLLSYM void enlarge_sub_image(IMAGE *source,       //source image
                                         inT32 xstart,        //scaled coords
                                         inT32 ystart,
                                         IMAGE *dest,         //destination image
                                         inT32 xdest,         //destination coords
                                         inT32 ydest,
                                         inT32 xext,          //extent to copy
                                         inT32 yext,
                                         inT32 scale,         //scale factor
                                         BOOL8 adjust_grey);  //shift to match bpp

                                 //reduce rectangle
    friend DLLSYM void fast_reduce_sub_image(IMAGE *source,       //source image
                                             inT32 xstart,        //start coords
                                             inT32 ystart,
                                             inT32 xext,          //extent to copy
                                             inT32 yext,
                                             IMAGE *dest,         //destination image
                                             inT32 xdest,         //destination coords
                                             inT32 ydest,
                                             inT32 scale,         //scale factor
                                             BOOL8 adjust_grey);  //shift to match bpp

                                 //reduce rectangle
    friend DLLSYM void reduce_sub_image(IMAGE *source,       //source image
                                        inT32 xstart,        //start coords
                                        inT32 ystart,
                                        inT32 xext,          //extent to copy
                                        inT32 yext,
                                        IMAGE *dest,         //destination image
                                        inT32 xdest,         //destination coords
                                        inT32 ydest,
                                        inT32 scale,         //scale factor
                                        BOOL8 adjust_grey);  //shift to match bpp

  private:
    inT8 bpp;                    ///< bits per pixel
    inT8 bps;                    ///< bits per sample
    inT8 bytespp;                ///< per pixel
    inT8 lineskip;               ///< waste bytes on line
    BOOL8 captured;              ///< true if buffer captured
    inT8 photo_interp;           ///< interpretation
    inT32 xsize, ysize;          ///< size of image
    inT32 res;                   ///< resolution
    uinT8 *image;                ///< the actual image
    inT32 xdim;                  ///< bytes per line
    inT32 bufheight;             ///< height of buffer
    int fd;                      ///< open file descriptor
    IMAGE_READER reader;         ///< reading function
    inT32 ymin;                  ///< bottom line in mem
    inT32 ymax;                  ///< top line in mem+1
    /**
     * read some more
     * @param y ycoord required
     */
    inT8 bufread(inT32 y);
};

class DLLSYM IMAGELINE           //one line of image
{
  public:
    uinT8 * pixels;              ///< image pixels
    inT8 bpp;                    ///< bits per pixel
    /** colour pixels */
    COLOUR_PIX operator[] (
    inT32 index) {
      return &pixels[index * 3]; //coercion access op
    }

    /** default constructor */
    IMAGELINE() {
      linewidth = 0;
      line = NULL;
      pixels = line;
      bpp = 8;
    }
    void init(                //setup size
              inT32 width) {  //size of line
      if (width <= 0)
        width = MAXIMAGEWIDTH;
      if (width > linewidth) {
        if (line != NULL)
          free_mem(line);
        linewidth = width;
        line = (uinT8 *) alloc_mem (linewidth * sizeof (uinT8));
      }
      pixels = line;
      bpp = 8;
    }
    ~IMAGELINE () {              //destructor
      if (line != NULL)
        free_mem(line);
    }

    /** For colour */
    void set_bpp(inT8 new_bpp) {
      if (new_bpp <= 8)
        bpp = 8;
      else
        bpp = 24;
    }

    void init() {
      if (line == NULL)
        init (0);
      else {
        pixels = line;
        bpp = 8;
      }
    }

    /**
     * copies a line
     * @param x coord to start at
     * @param y line to get
     * @param width no of pixels to get
     * @param linebuf line to copy to
     * @param margins size of margins
     */
    friend void IMAGE::get_line(inT32 x,
                                inT32 y,
                                inT32 width,
                                IMAGELINE *linebuf,
                                inT32 margins);
    /**
     * copies a column
     * @param x coord to start at
     * @param y line to get
     * @param height no of pixels to get
     * @param linebuf line to copy to
     * @param margins size of margins
     */
    friend void IMAGE::get_column(inT32 x,
                                  inT32 y,
                                  inT32 height,
                                  IMAGELINE *linebuf,
                                  inT32 margins);

    /**
     * writes a line
     * @param x coord to start at
     * @param y line to get
     * @param width no of pixels to put
     * @param linebuf line to copy to
     * @param margins size of margins
     */
    friend void IMAGE::put_line(inT32 x,
                                inT32 y,
                                inT32 width,
                                IMAGELINE *linebuf,
                                inT32 margins);

    /**
     * writes a column
     * @param x coord to start at
     * @param y line to get
     * @param height no of pixels to put
     * @param linebuf line to copy to
     * @param margins size of margins
     */
    friend void IMAGE::put_column(inT32 x,
                                  inT32 y,
                                  inT32 height,
                                  IMAGELINE *linebuf,
                                  inT32 margins);

    /**
     * @note may just change pointer
     * @param x coord to start at
     * @param y line to get
     * @param width no of pixels to get
     * @param linebuf line to copy to
     */
    friend void IMAGE::fast_get_line(inT32 x,
                                     inT32 y,
                                     inT32 width,
                                     IMAGELINE *linebuf);

    /**
     * @note may just change pointer
     * @param x coord to start at
     * @param y line to get
     * @param width no of pixels to put
     * @param linebuf line to copy to
     */
    friend void IMAGE::fast_put_line(inT32 x,
                                     inT32 y,
                                     inT32 width,
                                     IMAGELINE *linebuf);

  private:
    uinT8 * line;                ///< local buffer
    inT32 linewidth;             ///< width of buffer
};
#endif