Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions | Variables
imgs.cpp File Reference
`#include "mfcpch.h"`
`#include <unistd.h>`
`#include <string.h>`
`#include "allheaders.h"`
`#include "stderr.h"`
`#include "tprintf.h"`
`#include "imgerrs.h"`
`#include "memry.h"`
`#include "imgs.h"`
`#include "imgunpk.h"`

Go to the source code of this file.

## Macros

#define | FIXED_COLOURS 32 /*number of fixed colours */
#define | MIN_4BIT 48 /*4bpp range */
#define | MAX_4BIT 64
#define | MIN_6BIT 64 /*6bpp range */
#define | MAX_6BIT 128
#define | BLACK_PIX 0
#define | EXTERN

## Functions

inT32 | check_legal_image_size (inT32 x, inT32 y, inT8 bits_per_pixel)
DLLSYM void | copy_sub_image (IMAGE *source, inT32 xstart, inT32 ystart, inT32 xext, inT32 yext, IMAGE *dest, inT32 xdest, inT32 ydest, BOOL8 adjust_grey)
DLLSYM void | enlarge_sub_image (IMAGE *source, inT32 xstart, inT32 ystart, IMAGE *dest, inT32 xdest, inT32 ydest, inT32 xext, inT32 yext, inT32 scale, BOOL8 adjust_grey)
DLLSYM void | fast_reduce_sub_image (IMAGE *source, inT32 xstart, inT32 ystart, inT32 xext, inT32 yext, IMAGE *dest, inT32 xdest, inT32 ydest, inT32 scale, BOOL8 adjust_grey)
DLLSYM void | reduce_sub_image (IMAGE *source, inT32 xstart, inT32 ystart, inT32 xext, inT32 yext, IMAGE *dest, inT32 xdest, inT32 ydest, inT32 scale, BOOL8 adjust_grey)
DLLSYM void | invert_image (IMAGE *image)
DLLSYM void | bias_sub_image (IMAGE *source, inT32 xstart, inT32 ystart, inT32 xext, inT32 yext, uinT8 bias)
DLLSYM void | starbase_to_normal (IMAGE *source, inT32 xstart, inT32 ystart, inT32 xext, inT32 yext, IMAGE *dest, inT32 xdest, inT32 ydest, BOOL8 preserve_grey)

## Variables

const uinT8 | grey_scales [FIXED_COLOURS]
EXTERN int | image_default_resolution = 300

## Macro Definition Documentation

#define BLACK_PIX 0

Definition at line 50 of file imgs.cpp.

#define EXTERN

Definition at line 60 of file imgs.cpp.

#define FIXED_COLOURS 32 /*number of fixed colours */

Definition at line 45 of file imgs.cpp.

#define MAX_4BIT 64

Definition at line 47 of file imgs.cpp.

#define MAX_6BIT 128

Definition at line 49 of file imgs.cpp.

#define MIN_4BIT 48 /*4bpp range */

Definition at line 46 of file imgs.cpp.

#define MIN_6BIT 64 /*6bpp range */

Definition at line 48 of file imgs.cpp.

## Function Documentation

DLLSYM void bias_sub_image | ( | IMAGE * | source,
|  | inT32 | xstart,
|  | inT32 | ystart,
|  | inT32 | xext,
|  | inT32 | yext,
|  | uinT8 | bias
| ) |  |

Definition at line 832 of file imgs.cpp.

{
IMAGELINE copyline; //copy of line
uinT8 *copy; //source pointer
inT32 pixel; //pixel index
inT32 y; //line index
uinT8 bytespp; //bytes per pixel
if (xstart < 0 || ystart < 0)
return;
if (xext <= 0)
xext = source->get_xsize (); //default to all
if (xext > source->get_xsize () - xstart)
//clip to smallest
xext = source->get_xsize () - xstart;
if (yext <= 0)
yext = source->get_ysize (); //default to all
if (yext > source->get_ysize () - ystart)
//clip to smallest
yext = source->get_ysize () - ystart;
if (xext <= 0 || yext <= 0)
return; //nothing to do
bytespp = source->get_bpp () == 24 ? 3 : 1;
for (y = 0; y < yext; y++) {
source->check_legal_access (xstart, ystart + y, xext);
source->fast_get_line (xstart, ystart + y, xext, &copyline);
for (pixel = xext * bytespp, copy = copyline.pixels; pixel > 0;
pixel--, copy++)
*copy += bias; //add bias
source->fast_put_line (xstart, ystart + y, xext, &copyline);
}
}

inT32 check_legal_image_size | ( | inT32 | x,
|  | inT32 | y,
|  | inT8 | bits_per_pixel
| ) |  |

Definition at line 240 of file imgs.cpp.

{
if (x <= 0 || y <= 0) {
BADIMAGESIZE.error ("check_legal_image_size", TESSLOG, "(%d,%d)", x, y);
return -1; //failed
}
if (bits_per_pixel != 1 && bits_per_pixel != 2 &&
bits_per_pixel != 4 && bits_per_pixel != 5 &&
bits_per_pixel != 6 && bits_per_pixel != 8 &&
bits_per_pixel != 16 && bits_per_pixel != 24 &&
bits_per_pixel != 32) {
BADBPP.error ("check_legal_image_size", TESSLOG, "%d", bits_per_pixel);
return -1;
}
//bytes per line
return COMPUTE_IMAGE_XDIM (x, bits_per_pixel);
}

DLLSYM void copy_sub_image | ( | IMAGE * | source,
|  | inT32 | xstart,
|  | inT32 | ystart,
|  | inT32 | xext,
|  | inT32 | yext,
|  | IMAGE * | dest,
|  | inT32 | xdest,
|  | inT32 | ydest,
|  | BOOL8 | adjust_grey
| ) |  |

Definition at line 270 of file imgs.cpp.

{
IMAGELINE copyline; //copy of line
uinT8 *copy; //source pointer
inT8 shift; //shift factor
inT32 pixel; //pixel index
inT32 y; //line index
inT32 yoffset; //current adjusted offset
inT32 bytesize; //no of bytes to copy
inT32 srcppb; //pixels per byte
BOOL8 aligned;
if (xstart < 0 || ystart < 0 || xdest < 0 || ydest < 0)
return;
if (xext <= 0)
xext = source->xsize; //default to all
if (xext > source->xsize - xstart)
//clip to smallest
xext = source->xsize - xstart;
if (xext > dest->xsize - xdest)
xext = dest->xsize - xdest;
if (yext <= 0)
yext = source->ysize; //default to all
if (yext > source->ysize - ystart)
//clip to smallest
yext = source->ysize - ystart;
if (yext > dest->ysize - ydest)
yext = dest->ysize - ydest;
if (xext <= 0 || yext <= 0)
return; //nothing to do
srcppb = 8 / source->bpp; //pixels per byte
if (source->bpp == dest->bpp || !adjust_grey)
shift = 0; //no adjustment
else {
shift = source->bps - dest->bps;
if (shift < 0)
shift = -shift; //keep positive
}
aligned = source->bpp == dest->bpp;
if (aligned && srcppb != 0) {
aligned = xstart % srcppb == 0
&& xdest % srcppb == 0
&& (xext % srcppb == 0 || xdest + xext == dest->xsize);
}
for (y = 0; y < yext; y++) {
if (ystart >= ydest)
yoffset = y; //top down
else
yoffset = yext - y - 1; //bottom up
source->check_legal_access (xstart, ystart + yoffset, xext);
dest->check_legal_access (xdest, ydest + yoffset, xext);
if (aligned) {
bytesize = COMPUTE_IMAGE_XDIM (xext, source->bpp);
//get bytes per line
if (srcppb == 0)
//do cheap move
memmove (dest->image + (dest->ymax - 1 - ydest - yoffset) * dest->xdim + xdest * 3, source->image + (source->ymax - 1 - ystart - yoffset) * source->xdim + xstart * 3, (unsigned) bytesize);
else
//do cheap move
memmove (dest->image + (dest->ymax - 1 - ydest - yoffset) * dest->xdim + xdest / srcppb, source->image + (source->ymax - 1 - ystart - yoffset) * source->xdim + xstart / srcppb, (unsigned) bytesize);
}
else {
if (shift == 0) {
source->fast_get_line (xstart, ystart + yoffset, xext,
&copyline);
}
else if (source->bpp < dest->bpp) {
source->get_line (xstart, ystart + yoffset, xext, &copyline, 0);
if (source->bpp <= shift
&& (source->bpp == 1 || source->bpp == 4)) {
if (source->bpp == 1) {
for (pixel = 0, copy = copyline.pixels; pixel < xext;
pixel++, copy++)
if (*copy)
*copy = 0xff;
}
else {
for (pixel = 0, copy = copyline.pixels; pixel < xext;
pixel++, copy++)
//scale up
*copy = (*copy << shift) | *copy;
}
}
else {
for (pixel = 0, copy = copyline.pixels; pixel < xext;
pixel++)
*copy++ <<= shift; //scale up
}
}
else {
source->get_line (xstart, ystart + yoffset, xext, &copyline, 0);
if (source->bpp == 24) {
for (pixel = 0, copy = copyline.pixels + 1; pixel < xext;
pixel++) {
*copy >>= shift;
copy += 3;
}
}
else {
for (pixel = 0, copy = copyline.pixels; pixel < xext;
pixel++)
*copy++ >>= shift; //scale down
}
}
dest->put_line (xdest, ydest + yoffset, xext, &copyline, 0);
}
}
}

DLLSYM void enlarge_sub_image | ( | IMAGE * | source,
|  | inT32 | xstart,
|  | inT32 | ystart,
|  | IMAGE * | dest,
|  | inT32 | xdest,
|  | inT32 | ydest,
|  | inT32 | xext,
|  | inT32 | yext,
|  | inT32 | scale,
|  | BOOL8 | adjust_grey
| ) |  |

Definition at line 398 of file imgs.cpp.

{
inT8 shift; //shift factor
uinT8 pixel; //current pixel
inT32 srcext; //source extent
inT32 xoffset; //column index
inT32 yoffset; //line index
inT32 xindex, yindex; //index in super pixel
inT32 startxindex; //initial x index
inT32 xscale; //x scale factor
uinT8 *src; //source pixels
uinT8 *destpix; //dest pixels
IMAGELINE copyline; //copy of line
IMAGELINE bigline; //expanded line
if (xstart < 0 || ystart < 0 || xdest < 0 || ydest < 0)
return;
if (xext <= 0)
xext = dest->xsize; //default to all
if (xext > source->xsize * scale - xstart)
//clip to smallest
xext = source->xsize * scale - xstart;
if (xext > dest->xsize - xdest)
xext = dest->xsize - xdest;
if (yext <= 0)
yext = dest->ysize; //default to all
if (yext > source->ysize * scale - ystart)
yext = source->ysize * scale - ystart;
if (yext > dest->ysize - ydest)
yext = dest->ysize - ydest;
if (xext <= 0 || yext <= 0)
return; //nothing to do
xindex = xstart % scale; //offset in super pixel
startxindex = xindex;
yindex = ystart % scale;
//no of source pixels
srcext = (xext + xindex + scale - 1) / scale;
xstart /= scale; //actual start
ystart /= scale;
if (adjust_grey) {
shift = dest->bps - source->bps;
}
else
shift = 0; //no adjustment
bigline.init (xext * 3);
bigline.bpp = dest->bpp == 24 ? source->bpp : dest->bpp;
for (yoffset = 0; yoffset < yext; ystart++) {
source->check_legal_access (xstart, ystart, srcext);
dest->check_legal_access (xdest, ydest + yoffset, xext);
source->fast_get_line (xstart, ystart, srcext, &copyline);
src = copyline.pixels;
destpix = bigline.pixels;
xscale = scale; //enlargement factor
if (source->bpp == 24 && dest->bpp == 24) {
for (xoffset = 0, xindex = startxindex; xoffset < xext;
src += source->bytespp) {
xoffset += xscale - xindex;
if (xoffset > xext)
xscale -= xoffset - xext;
for (; xindex < xscale; xindex++) {
*destpix++ = *src;
*destpix++ = *(src + 1);
*destpix++ = *(src + 2);
}
xindex = 0;
}
}
else {
if (source->bpp == 24)
src++;
for (xoffset = 0, xindex = startxindex; xoffset < xext;
src += source->bytespp) {
xoffset += xscale - xindex;
if (xoffset > xext)
//clip to dest limit
xscale -= xoffset - xext;
if (shift == 0)
pixel = *src;
else if (shift > 0)
pixel = *src << shift;
else
pixel = *src >> (-shift);
for (; xindex < xscale; xindex++)
*destpix++ = pixel; //duplicate pixel
xindex = 0;
}
}
for (; yoffset < yext && yindex < scale; yindex++, yoffset++) {
dest->put_line (xdest, ydest + yoffset, xext, &bigline, 0);
}
yindex = 0;
}
}

DLLSYM void fast_reduce_sub_image | ( | IMAGE * | source,
|  | inT32 | xstart,
|  | inT32 | ystart,
|  | inT32 | xext,
|  | inT32 | yext,
|  | IMAGE * | dest,
|  | inT32 | xdest,
|  | inT32 | ydest,
|  | inT32 | scale,
|  | BOOL8 | adjust_grey
| ) |  |

Definition at line 516 of file imgs.cpp.

{
inT8 shift; //shift factor
inT32 xfactor; //run on x coord
inT32 divisor; //total cell area
inT32 xindex, yindex; //into averaging square
inT32 xcoord; //current x coord
inT32 destext; //destination size
inT32 yoffset; //current adjusted offset
uinT8 *pixel; //ptr to source pixels
inT32 *sums; //ptr to sums array
IMAGELINE copyline; //copy of line
inT32 *linesums; //averaging sums
if (xstart < 0 || ystart < 0 || xdest < 0 || ydest < 0)
return;
if (xext <= 0)
xext = source->xsize; //default to all
if (xext > source->xsize - xstart)
//clip to smallest
xext = source->xsize - xstart;
if (xext > (dest->xsize - xdest) * scale)
xext = (dest->xsize - xdest) * scale;
if (yext <= 0)
yext = source->ysize; //default to all
if (yext > source->ysize - ystart)
//clip to smallest
yext = source->ysize - ystart;
if (yext > (dest->ysize - ydest) * scale)
yext = (dest->ysize - ydest) * scale;
if (xext <= 0 || yext <= 0)
return; //nothing to do
xfactor = xext % scale; //left overs
if (xfactor == 0)
xfactor = scale;
//destination pixels
destext = (xext + scale - 1) / scale;
if (adjust_grey)
//shift factor
shift = dest->bps - source->bps;
else
shift = 0; //no adjustment
linesums = new inT32[destext * source->bytespp];
for (yoffset = 0; yoffset < yext; ydest++) {
source->check_legal_access (xstart, ystart + yoffset, xext);
dest->check_legal_access (xdest, ydest, destext);
for (xindex = destext * source->bytespp - 1; xindex >= 0; xindex--)
linesums[xindex] = 0; //zero sums
for (yindex = 0; yindex < scale
&& ystart + yoffset < source->ysize; yindex += 3) {
source->fast_get_line (xstart, ystart + yoffset, xext, &copyline);
pixel = copyline.pixels; //start of line
if (source->bpp == 24) {
for (xcoord = 1, sums = linesums; xcoord < destext;
xcoord++, sums += 3) {
for (xindex = 0; xindex < scale; xindex += 2) {
*sums += *pixel++;
*(sums + 1) += *pixel++;
*(sums + 2) += *pixel++;
pixel += 3;
}
if (scale & 1)
pixel -= 3; //correct position
}
for (xindex = 0; xindex < xfactor; xindex += 2) {
*sums += *pixel++;
*(sums + 1) += *pixel++;
*(sums + 2) += *pixel++;
pixel += 3;
}
}
else {
for (xcoord = 1, sums = linesums; xcoord < destext;
xcoord++, sums++) {
for (xindex = 0; xindex < scale; xindex += 2) {
*sums += *pixel;
pixel += 2;
}
if (scale & 1)
pixel--; //correct position
}
for (xindex = 0; xindex < xfactor; xindex += 2) {
*sums += *pixel;
pixel += 2;
}
}
yoffset += 3; //every 3 lines
}
if (yindex > scale)
yoffset -= yindex - scale; //back on right scale
copyline.init (); //set pixels back to array
copyline.bpp = source->bpp;
pixel = copyline.pixels;
//pixels in block
divisor = ((yindex + 2) / 3) * ((scale + 1) / 2);
if (shift <= 0) {
divisor <<= (-shift); //do greyscale correction
for (sums = linesums, xindex = (destext - 1) * source->bytespp;
xindex > 0; xindex--)
//turn to destination value
*pixel++ = (uinT8) (*sums++ / divisor);
for (xindex = source->bytespp; xindex > 0; xindex--)
*pixel++ = *sums++
/ (((yindex + 2) / 3) * ((xfactor + 1) / 2) << (-shift));
//lastone different
}
else {
for (sums = linesums, xindex = (destext - 1) * source->bytespp;
xindex > 0; xindex--)
*pixel++ = (uinT8) ((*sums++ << shift) / divisor);
//destination value
for (xindex = source->bytespp; xindex > 0; xindex--)
//last one different
*pixel++ = (*(sums++) << shift) / (((yindex + 2) / 3) * ((xfactor + 1) / 2));
}
//put in destination
dest->put_line (xdest, ydest, destext, &copyline, 0);
}
delete [] linesums;
}

DLLSYM void invert_image | ( | IMAGE * | image | ) |

Definition at line 797 of file imgs.cpp.

{
uinT8 mask; //bit mask
uinT8 bytespp; //bytes per pixel
inT32 xsize, ysize; /*size of image */
inT32 xindex, yindex; /*index into image */
uinT8 *pixel; /*current pixel */
IMAGELINE line; /*line of image */
bytespp = image->get_bpp () == 24 ? 3 : 1;
xsize = image->get_xsize (); /*find sizes */
ysize = image->get_ysize ();
//pixel mask
mask = (1 << image->get_bpp ()) - 1;
/*do each line */
for (yindex = ysize - 1; yindex >= 0; yindex--) {
image->fast_get_line (0, yindex, xsize, &line);
for (pixel = line.pixels, xindex = xsize * bytespp; xindex > 0;
xindex--) {
*pixel = (*pixel) ^ mask; //invert image only
++pixel;
}
/*put it back */
image->fast_put_line (0, yindex, xsize, &line);
}
}

DLLSYM void reduce_sub_image | ( | IMAGE * | source,
|  | inT32 | xstart,
|  | inT32 | ystart,
|  | inT32 | xext,
|  | inT32 | yext,
|  | IMAGE * | dest,
|  | inT32 | xdest,
|  | inT32 | ydest,
|  | inT32 | scale,
|  | BOOL8 | adjust_grey
| ) |  |

Definition at line 658 of file imgs.cpp.

{
inT8 shift; //shift factor
inT32 xfactor; //run on x coord
inT32 divisor; //total cell area
inT32 div2; //total cell area divided by 2
inT32 xindex, yindex; //into averaging square
inT32 xcoord; //current x coord
inT32 destext; //destination size
inT32 yoffset; //current adjusted offset
uinT8 *pixel; //ptr to source pixels
inT32 *sums; //ptr to sums array
IMAGELINE copyline; //copy of line
inT32 *linesums; //averaging sums
if (xstart < 0 || ystart < 0 || xdest < 0 || ydest < 0)
return;
if (xext <= 0)
xext = source->xsize; //default to all
if (xext > source->xsize - xstart)
//clip to smallest
xext = source->xsize - xstart;
if (xext > (dest->xsize - xdest) * scale)
xext = (dest->xsize - xdest) * scale;
if (yext <= 0)
yext = source->ysize; //default to all
if (yext > source->ysize - ystart)
//clip to smallest
yext = source->ysize - ystart;
if (yext > (dest->ysize - ydest) * scale)
yext = (dest->ysize - ydest) * scale;
if (xext <= 0 || yext <= 0)
return; //nothing to do
xfactor = xext % scale; //left overs
if (xfactor == 0)
xfactor = scale;
//destination pixels
destext = (xext + scale - 1) / scale;
if (adjust_grey)
//shift factor
shift = dest->bps - source->bps;
else
shift = 0; //no adjustment
linesums = new inT32[destext * source->bytespp];
for (yoffset = 0; yoffset < yext; ydest++) {
source->check_legal_access (xstart, ystart + yoffset, xext);
dest->check_legal_access (xdest, ydest, destext);
for (xindex = 0; xindex < (destext) * source->bytespp; xindex++)
linesums[xindex] = 0; //zero sums
for (yindex = 0; yindex < scale && ystart + yoffset < source->ysize;
yindex++) {
source->fast_get_line (xstart, ystart + yoffset, xext, &copyline);
pixel = copyline.pixels; //start of line
if (source->bpp == 24) {
for (xcoord = 1, sums = linesums; xcoord < destext;
xcoord++, sums += 3) {
for (xindex = 0; xindex < scale; xindex++) {
*sums += *pixel++;
*(sums + 1) += *pixel++;
*(sums + 2) += *pixel++;
}
}
for (xindex = 0; xindex < xfactor; xindex++) {
*sums += *pixel++;
*(sums + 1) += *pixel++;
*(sums + 2) += *pixel++;
}
}
else {
for (xcoord = 1, sums = linesums; xcoord < destext;
xcoord++, sums++) {
for (xindex = 0; xindex < scale; xindex++)
*sums += *pixel++;
}
for (xindex = 0; xindex < xfactor; xindex++)
*sums += *pixel++;
}
yoffset++; //next line
}
copyline.init (); //set pixels back to array
copyline.set_bpp (source->bpp);
pixel = copyline.pixels;
divisor = yindex * scale;
if (divisor == 0) {
tprintf
("Impossible:divisor=0!, yindex=%d, scale=%d, yoffset=%d,yext=%d\n",
yindex, scale, yoffset, yext);
break;
}
if (shift <= 0) {
divisor <<= (-shift); //do greyscale correction
div2 = divisor / 2;
for (sums = linesums, xindex = (destext - 1) * source->bytespp;
xindex > 0; xindex--)
*pixel++ = (uinT8) ((div2 + *sums++) / divisor);
//turn to destination value
div2 = (yindex * xfactor << (-shift)) / 2;
for (xindex = source->bytespp; xindex > 0; xindex--)
*pixel++ =
(uinT8) ((div2 + *sums++) / (yindex * xfactor << (-shift)));
//lastone different
}
else {
div2 = divisor / 2;
for (sums = linesums, xindex = (destext - 1) * source->bytespp;
xindex > 0; xindex--)
*pixel++ = (uinT8) ((div2 + (*sums++ << shift)) / divisor);
//destination value
div2 = (yindex * xfactor) / 2;
for (xindex = source->bytespp; xindex > 0; xindex--)
*pixel++ =
(uinT8) ((div2 + (*sums++ << shift)) / (yindex * xfactor));
//last one different
}
//put in destination
dest->put_line (xdest, ydest, destext, &copyline, 0);
}
delete [] linesums;
}

DLLSYM void starbase_to_normal | ( | IMAGE * | source,
|  | inT32 | xstart,
|  | inT32 | ystart,
|  | inT32 | xext,
|  | inT32 | yext,
|  | IMAGE * | dest,
|  | inT32 | xdest,
|  | inT32 | ydest,
|  | BOOL8 | preserve_grey
| ) |  |

Definition at line 882 of file imgs.cpp.

{
IMAGELINE copyline; //copy of line
uinT8 *copy; //source pointer
inT8 shift4; //shift factor
inT8 shift6; //shift factor
inT8 colour_shift; //shift of colours
uinT8 white_level; //dest white value
inT32 pixel; //pixel index
inT32 y; //line index
inT32 yoffset; //current adjusted offset
inT8 srcppb; //pixels per byte
if (xstart < 0 || ystart < 0 || xdest < 0 || ydest < 0)
return;
if (xext <= 0)
xext = source->get_xsize (); //default to all
if (xext > source->get_xsize () - xstart)
//clip to smallest
xext = source->get_xsize () - xstart;
if (xext > dest->get_xsize () - xdest)
xext = dest->get_xsize () - xdest;
if (yext <= 0)
yext = source->get_ysize (); //default to all
if (yext > source->get_ysize () - ystart)
//clip to smallest
yext = source->get_ysize () - ystart;
if (yext > dest->get_ysize () - ydest)
yext = dest->get_ysize () - ydest;
if (xext <= 0 || yext <= 0)
return; //nothing to do
//pixels per byte
srcppb = 8 / source->get_bpp ();
shift4 = 4 - dest->get_bpp (); //for different bpps
shift6 = 6 - dest->get_bpp ();
//for grey preserve
colour_shift = 8 - dest->get_bpp ();
white_level = dest->get_white_level ();
for (y = 0; y < yext; y++) {
if (ystart >= ydest)
yoffset = y; //top down
else
yoffset = yext - y - 1; //bottom up
source->check_legal_access (xstart, ystart + yoffset, xext);
dest->check_legal_access (xdest, ydest + yoffset, xext);
source->get_line (xstart, ystart + yoffset, xext, &copyline, 0);
for (pixel = 0, copy = copyline.pixels; pixel < xext; pixel++) {
if (*copy < FIXED_COLOURS && preserve_grey)
*copy = grey_scales[*copy] >> colour_shift;
else if (*copy < FIXED_COLOURS) {
if (*copy == BLACK_PIX)
*copy = white_level; //black->white
else
*copy = 0; //others->black
}
else if (*copy >= MIN_4BIT && *copy < MAX_4BIT) {
if (shift4 < 0)
*copy = (*copy - MIN_4BIT) << (-shift4);
else
*copy = (*copy - MIN_4BIT) >> shift4;
}
else if (*copy >= MIN_6BIT && *copy < MAX_6BIT) {
if (shift6 < 0)
*copy = (*copy - MIN_6BIT) << (-shift6);
else
*copy = (*copy - MIN_6BIT) >> shift6;
}
else {
*copy = white_level; //white the rest
}
copy++;
}
dest->put_line (xdest, ydest + yoffset, xext, &copyline, 0);
}
}

## Variable Documentation

const uinT8 grey_scales[FIXED_COLOURS]

Initial value:
{
0, 255, 76, 227, 151, 179, 28, 104,
149, 72, 215, 67, 53, 44, 156, 137,
110, 153, 79, 181, 166, 218, 55, 81,
129, 105, 179, 149, 168, 69, 84, 126
}

Definition at line 52 of file imgs.cpp.

EXTERN int image_default_resolution = 300

"Image resolution dpi"

Definition at line 64 of file imgs.cpp.