2
2
Copyright (c) 1993-2008, Cognitive Technologies
5
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
6
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
8
* ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
9
���� ����������� �� ��������� �����, ���� ������ ������� � �����������
11
* ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
12
������ ����������, ������������ ��� ���������������, ������ �����������
13
��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
14
����������� ����� �� ��������.
15
* �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
16
���� ������������ � �������� �������� ��������� �/��� �����������
17
���������, ���������� �� ���� ��, ��� ���������������� �����������
20
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
21
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
22
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
23
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
24
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
25
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
26
������������� ������, ��������� � �������������� ��� ���������� ����������
27
������������� ������������� ��������� (������� ������ ������, ��� ������,
28
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
29
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
30
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
31
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
5
Разрешается повторное распространение и использование как в виде исходного кода,
6
так и в двоичной форме, с изменениями или без, при соблюдении следующих условий:
8
* При повторном распространении исходного кода должны оставаться указанное
9
выше уведомление об авторском праве, этот список условий и последующий
11
* При повторном распространении двоичного кода в документации и/или в
12
других материалах, поставляемых при распространении, должны сохраняться
13
указанная выше информация об авторском праве, этот список условий и
14
последующий отказ от гарантий.
15
* Ни название Cognitive Technologies, ни имена ее сотрудников не могут
16
быть использованы в качестве средства поддержки и/или продвижения
17
продуктов, основанных на этом ПО, без предварительного письменного
20
ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК
21
ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ,
22
ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ
23
ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ
24
МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ
25
НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ
26
ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ
27
НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ,
28
СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ
29
ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ,
30
НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ
31
ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ.
33
33
Redistribution and use in source and binary forms, with or without modification,
34
34
are permitted provided that the following conditions are met:
72
71
#include "compat_defs.h"
75
extern BYTE db_status; // snap presence byte
76
extern BYTE db_trace_flag; // 2 - more detailed estimate (ALT-F7)
79
extern BYTE *ForRaster1;
81
static void begin(INT,INT);
74
extern uchar db_status; // snap presence byte
75
extern uchar db_trace_flag; // 2 - more detailed estimate (ALT-F7)
78
extern uchar *ForRaster1;
80
static void begin(int16_t,int16_t);
82
81
static void allcuts();
83
82
static void interlines();
84
static void minlincut(CHAR);
85
static void fixcut(INT,INT,INT,INT);
86
static INT scamin(INT,INT,INT);
87
static void regmin(CHAR);
83
static void minlincut(char);
84
static void fixcut(int16_t,int16_t,int16_t,int16_t);
85
static int16_t scamin(int16_t,int16_t,int16_t);
86
static void regmin(char);
88
87
static void make_limits();
89
88
static void findbotbnd();
90
static INT bot_serif(CHAR);
91
// static INT verifh(PCHAR,CHAR,CHAR);
92
static INT walltest(INT,INT,INT,INT,INT);
93
static INT middle_puso(CHAR);
94
static INT lower_gap(CHAR);
95
static void lower_pen(CHAR);
89
static int16_t bot_serif(char);
90
// static int16_t verifh(pchar,char,CHAR);
91
static int16_t walltest(int16_t,int16_t,int16_t,int16_t,int16_t);
92
static int16_t middle_puso(char);
93
static int16_t lower_gap(char);
94
static void lower_pen(char);
96
95
static void findtopbnd();
97
static INT top_serif(CHAR);
98
static INT upper_gap(CHAR);
99
// static INT lower_gap2(CHAR);
100
static void define_cat(struct extrem_elem *,CHAR);
96
static int16_t top_serif(char);
97
static int16_t upper_gap(char);
98
// static int16_t lower_gap2(char);
99
static void define_cat(struct extrem_elem *,char);
101
100
static void make_func();
102
static INT make_extrem(PCHAR,struct extrem_elem *);
103
static INT make_absextr(CHAR,struct extrem_elem *);
101
static int16_t make_extrem(pchar,struct extrem_elem *);
102
static int16_t make_absextr(char,struct extrem_elem *);
104
103
static void make_info();
105
static CHAR bodyes[128], cut_place[128];
106
static CHAR foots[128], heads[128];
104
static char bodyes[128], cut_place[128];
105
static char foots[128], heads[128];
107
106
static struct extrem_elem exbody[MAX_HOR/2];
108
107
static struct extrem_elem exfoot[MAX_HOR/2];
109
108
static struct extrem_elem exhead[MAX_HOR/2];
109
static int16_t totalh;
111
110
//Lepik searches objezd:
112
static INT SearchObjezd(INT x, PBYTE c,
115
INT height, INT y_beg);
118
static void begin(INT width,INT height)
111
static int16_t SearchObjezd(int16_t x, puchar c,
112
int16_t width, int16_t y,
113
int16_t dh, int16_t r0,
114
int16_t height, int16_t y_beg);
117
static void begin(int16_t width,int16_t height)
120
119
// This procedure sets up all variables.
252
251
{ // NOT USED YET analyze points at lines
255
static void minlincut(CHAR arg)
254
static void minlincut(char arg)
257
256
// This procedure builds graphics and finds all reasonable cutting points.
260
INT nx, cline,min, max, svf, svn, svl,twh, tw2, tw3, is4,
259
int16_t nx, cline,min, max, svf, svn, svl,twh, tw2, tw3, is4,
261
260
wdsfl, lastx, lastw, curw, nfix, flgr, fldef;
262
261
struct info_elm *inf;
291
if ((INT)min >= (INT)(inf->botf)) min=inf->botf;
292
if ((INT)max <= (INT)(inf->toph)) max=inf->toph;
293
if ((INT)is4 > (INT)t_width)
290
if ((int16_t)min >= (int16_t)(inf->botf)) min=inf->botf;
291
if ((int16_t)max <= (int16_t)(inf->toph)) max=inf->toph;
292
if ((int16_t)is4 > (int16_t)t_width)
294
293
{ wdsfl++; nfix=2; } // may look at thin line
295
if (((INT)(max-min) > (INT)twh) && ((nx >(INT)5) && svn))
294
if (((int16_t)(max-min) > (int16_t)twh) && ((nx >(int16_t)5) && svn))
296
295
{ fixcut(svf,svl,svn,arg); svn=0; max=0; min=127; }
297
if ((INT)lastw == (INT)curw)
296
if ((int16_t)lastw == (int16_t)curw)
299
if ((INT)lastw > (INT)curw) // became narrower
298
if ((int16_t)lastw > (int16_t)curw) // became narrower
301
if (((INT)nx > (INT)(t_height-4)) && ((INT)(nx-lastx) > (INT)2))
300
if (((int16_t)nx > (int16_t)(t_height-4)) && ((int16_t)(nx-lastx) > (int16_t)2))
302
301
// close to pattern end
304
303
if ((lastw<<2) > tw3) // too thick
394
393
while ((nx>4) && (nx <(t_height-4)) && ((points[nx].sumb-y) <= 1));
395
394
if (abs(m-a) > 2)
404
static void regmin(CHAR c)
403
static void regmin(char c)
405
404
// cut in x=bestx, method=c;
407
INT v, line_num; CHAR rept, full, w, wx, ww, dh, h, vr;
406
int16_t v, line_num; char rept, full, w, wx, ww, dh, h, vr;
408
407
struct info_elm *inf;
409
408
struct own_cut *ad;
676
static INT walltest(INT flg, INT dn1, INT dn2, INT k1, INT k2)
675
static int16_t walltest(int16_t flg, int16_t dn1, int16_t dn2, int16_t k1, int16_t k2)
678
INT nx, w, wt, n1, n2, maxh, minf;
677
int16_t nx, w, wt, n1, n2, maxh, minf;
680
679
maxh=0; minf=256;
681
680
wt= t_width * k1;
1044
1043
struct short_line_header *l_ptr;
1045
1044
struct segment *s_ptr;
1046
INT n,x,y,z,bd,bn, cps,cpn, u,p;
1047
CHAR *h1, *h2, *h3, *f1, *f2, *f3, *cb, *cp;
1045
int16_t n,x,y,z,bd,bn, cps,cpn, u,p;
1046
char *h1, *h2, *h3, *f1, *f2, *f3, *cb, *cp;
1050
1049
for (n=0; n < t_height; n++)
1052
heads[n]=(CHAR)t_width;
1053
bodyes[n]=(CHAR)t_width;
1051
heads[n]=(char)t_width;
1052
bodyes[n]=(char)t_width;
1301
1300
c_rastror(s_raster,t_raster(),s_width,s_height);
1302
1301
// turn s_raster for 90 degrees clockwise
1303
t_comp_ptr=c_locomp(t_raster(),t_width_b,t_height,0,(INT)(-t_left_shift));
1302
t_comp_ptr=c_locomp(t_raster(),t_width_b,t_height,0,(int16_t)(-t_left_shift));
1304
1303
// extraction components from t_raster
1305
1304
if (t_comp_ptr == NULL)
1307
1306
t_line_ptr=c_boxln(t_comp_ptr);
1308
1307
// box presentation of a component ->
1309
1308
// line presentation of the component
1310
if ((i=(CHAR)make_graph()) <= 0) // make graph of shortened lines for
1309
if ((i=(char)make_graph()) <= 0) // make graph of shortened lines for
1311
1310
// turned raster
1371
1370
c_rastror(s_raster,t_raster(),s_width,s_height); // turn s_raster for 90 degrees clockwise
1372
t_comp_ptr=c_locomp(t_raster(),t_width_b,t_height,0,(INT)(-t_left_shift)); // extraction components from t_raster
1371
t_comp_ptr=c_locomp(t_raster(),t_width_b,t_height,0,(int16_t)(-t_left_shift)); // extraction components from t_raster
1373
1372
if (t_comp_ptr == NULL) return -1;
1374
1373
t_line_ptr=c_boxln(t_comp_ptr); // box presentation of a component -> line presentation of the component
1375
if ((i=(CHAR)make_graph()) <= 0 && width<20) return i; // make graph of shortened lines for turned raster
1374
if ((i=(char)make_graph()) <= 0 && width<20) return i; // make graph of shortened lines for turned raster
1377
//Alik_define_cut_points((PCHAR)ForRaster1,&oct[1],width,height,row);
1376
//Alik_define_cut_points((pchar)ForRaster1,&oct[1],width,height,row);
1378
1377
RCUTP_SetBL_for_CutPoints(minrow,bbs1,bbs2,bbs3,bbs4,Nb1,Nb2,Nb3,language);
1379
RCUTP_CutPoints((PCHAR)ForRaster1, &oct[1], width, height, row);
1378
RCUTP_CutPoints((pchar)ForRaster1, &oct[1], width, height, row);
1381
1380
for (a1=&ans[1],oc1=&oct[1],n=0, a=0; n<STK_H-1; n++)
1393
1392
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1394
1393
// AK changed 26.03.98
1395
MN *cut_rast(PBYTE r,INT width, INT height,INT upper, INT left,
1396
struct cut_elm *cuts, CHAR p, CHAR flg, CHAR *svp, cut_pos *cpos)
1394
MN *cut_rast(puchar r,int16_t width, int16_t height,int16_t upper, int16_t left,
1395
struct cut_elm *cuts, char p, char flg, char *svp, cut_pos *cpos)
1401
INT totc, dx, y, r0, tr1, tr2, r1, r2, f1;
1400
int16_t totc, dx, y, r0, tr1, tr2, r1, r2, f1;
1402
1401
// flg - request type :
1403
1402
// 0 - glue back
1404
1403
// 1 - make cut
1475
1474
for (y=0; y < dh; y++,r0++,c+=dx)
1477
if ( s < svp || s > (svp + 32 )) //AK! add
1476
if ( (char*)s < svp || (char*)s > (svp + 32 )) //AK! add
1482
if ((BYTE)(*c & bt) != 0) // interval starts or continues
1481
if ((uchar)(*c & bt) != 0) // interval starts or continues
1485
1484
if( !cuts_point_methode )
1486
1485
if ((fl ==0) &&(!(f1 & 1))) // beginning of vertical interval
1489
ret = SearchObjezd(x, c, width, y, dh, r0, height, (INT)(height -h));
1488
ret = SearchObjezd(x, c, width, y, dh, r0, height, (int16_t)(height -h));
1601
return(c_locomp(r,(INT)((width+7)>>3),height,upper,left));
1600
return(c_locomp(r,(int16_t)((width+7)>>3),height,upper,left));
1605
1604
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1606
1605
#define obLook 4
1607
1606
// 0 1 2 3 4 5 6 7
1608
static BYTE bits[8] ={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
1609
static BYTE lstr[8] ={0x80,0xC0,0xE0,0xF0,0x78,0x3C,0x1E,0x0F};
1610
static BYTE rstr[8] ={0xF0,0x78,0x3C,0x1E,0x0F,0x07,0x03,0x01};
1611
static BYTE aux[8] ={0x07,0x03,0x01,0x00,0x00,0x80,0xC0,0xE0};
1614
INT SearchObjezd(INT x, // column number where cutting is going.
1615
PBYTE c, // pointer to curr byte in raster
1616
INT width, // width of raster (pixs)
1617
INT y, // current row (in relative coords)
1618
INT dh, // no of rows to investigate(rel coords)
1619
INT r0, // first row (in rast coords)
1620
INT height, // height of raster
1621
INT beg_y) // first row for cut
1607
static uchar bits[8] ={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
1608
static uchar lstr[8] ={0x80,0xC0,0xE0,0xF0,0x78,0x3C,0x1E,0x0F};
1609
static uchar rstr[8] ={0xF0,0x78,0x3C,0x1E,0x0F,0x07,0x03,0x01};
1610
static uchar aux[8] ={0x07,0x03,0x01,0x00,0x00,0x80,0xC0,0xE0};
1613
int16_t SearchObjezd(int16_t x, // column number where cutting is going.
1614
puchar c, // pointer to curr byte in raster
1615
int16_t width, // width of raster (pixs)
1616
int16_t y, // current row (in relative coords)
1617
int16_t dh, // no of rows to investigate(rel coords)
1618
int16_t r0, // first row (in rast coords)
1619
int16_t height, // height of raster
1620
int16_t beg_y) // first row for cut
1625
INT dx; // width of raster in bytes.
1626
INT bitNo; // Curr Bit No in byte
1627
BYTE CurB, aCurB, Mask, aMask, Accu, aAccu;
1628
INT strategy; // 0 - left and right strips in one byte,
1624
int16_t dx; // width of raster in bytes.
1625
int16_t bitNo; // Curr Bit No in byte
1626
uchar CurB, aCurB, Mask, aMask, Accu, aAccu;
1627
int16_t strategy; // 0 - left and right strips in one byte,
1629
1628
// 1 - right split by byte,
1630
1629
// 2 - left split by byte.