~ubuntu-branches/debian/experimental/cuneiform/experimental

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rcutp/sources/main/rcut_4rselstr.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk, libm.diff, swapbytes.diff
  • Date: 2010-09-14 15:53:54 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914155354-hhxaa13xmhb82e3e
Tags: 1.0.0+dfsg-1
* New upstream release (closes: #575419).
* New maintainer (closes: #543893).
* Document in README.source how to repackage upstream tarball.
* Update debian/copyright.
  + Document that the package is auto-buildable.
  + Document which files were stripped from the upstream tarball.
  + Convert to the DEP-5 format.
* Drop README.Debian, no longer needed.
* Rewrite debian/rules from scratch using dh.
  + Bump debhelper minimum version to 7.4.4 (for cmake support).
  + Turn on MAKE_VERBOSE_MAKEFILE.
  + Disable call to dh_makeshlibs to avoid creation of spurious
    calls to ldconfig in postrm/postinst.
  + Add get-orig-source target.
* Remove unused overrides.
* Link to GraphicsMagick rather than ImageMagick:
  + Build-depend on graphicsmagick-libmagick-dev-compat.
  + Add patch to properly initialize the library. [graphicsmagick.diff]    
* Bump standards version to 3.9.1 (no changes needed).
* Force upgrade of ocrodjvu to at least 0.4.2; earlier versions of ocrodjvu
  don't support this version of Cuneiform.
* List all the supported languages in the package description.
* Update the manual page.
  + Document --dotmatrix, --fax and --singlecolumn options.
  + Document all output formats.
  + Don't use hyphen as minus sign.
  + Fix a few formatting issues.
* Drop Vcs-* fields.
* Add watch file.
* Add patch from Dmitrijs Ledkovs to link the lao library with libm.
  [libm.diff]
* Add patch for a for a more portable function to swap byte order.
  [swapbytes.diff]
* Set Architecture to any; there's no good reason to limit it.
* Run rudimentary tests at build time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Copyright (c) 1993-2008, Cognitive Technologies
3
3
All rights reserved.
4
4
 
5
 
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
6
 
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
7
 
 
8
 
      * ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
9
 
        ���� ����������� �� ��������� �����, ���� ������ ������� � �����������
10
 
        ����� �� ��������.
11
 
      * ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
12
 
        ������ ����������, ������������ ��� ���������������, ������ �����������
13
 
        ��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
14
 
        ����������� ����� �� ��������.
15
 
      * �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
16
 
        ���� ������������ � �������� �������� ��������� �/��� �����������
17
 
        ���������, ���������� �� ���� ��, ��� ���������������� �����������
18
 
        ����������.
19
 
 
20
 
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
21
 
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
22
 
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
23
 
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
24
 
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
25
 
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
26
 
������������� ������, ��������� � �������������� ��� ���������� ����������
27
 
������������� ������������� ��������� (������� ������ ������, ��� ������,
28
 
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
29
 
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
30
 
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
31
 
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
 
5
Разрешается повторное распространение и использование как в виде исходного кода,
 
6
так и в двоичной форме, с изменениями или без, при соблюдении следующих условий:
 
7
 
 
8
      * При повторном распространении исходного кода должны оставаться указанное
 
9
        выше уведомление об авторском праве, этот список условий и последующий
 
10
        отказ от гарантий.
 
11
      * При повторном распространении двоичного кода в документации и/или в
 
12
        других материалах, поставляемых при распространении, должны сохраняться
 
13
        указанная выше информация об авторском праве, этот список условий и
 
14
        последующий отказ от гарантий.
 
15
      * Ни название Cognitive Technologies, ни имена ее сотрудников не могут
 
16
        быть использованы в качестве средства поддержки и/или продвижения
 
17
        продуктов, основанных на этом ПО, без предварительного письменного
 
18
        разрешения.
 
19
 
 
20
ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК
 
21
ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ,
 
22
ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ
 
23
ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ
 
24
МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ
 
25
НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ
 
26
ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ
 
27
НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ,
 
28
СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ
 
29
ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ,
 
30
НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ
 
31
ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ.
32
32
 
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:
66
66
static int count_cut_let;
67
67
//static PAGEINFO info = {0};
68
68
//static char* image_name = NULL;
69
 
static Word16 biBitCount = 0;
 
69
static uint16_t biBitCount = 0;
70
70
static bool env_set = false;
71
71
static int medium_h;
72
72
static int inf_let_w;
77
77
static int min_cut_down_let_w;
78
78
static int sup_prob_w;
79
79
/*********************************************************************************************/
80
 
static int GetCountCutLetters(CCOM_comp* comp, Word8* pmasp);
81
 
static int IfNeedCut(CCOM_comp* comp, BOOL* type_let);
82
 
//static BOOL GetMasP(Rect16 Rc,Word8** ppmasp);
83
 
static BOOL JNotInMas2(int j,int* mas,int size,int bound);
84
 
static BOOL JNotInMas(int j,int* mas,int size,int bound);
85
 
static BOOL IfZpt(CCOM_comp* comp);
86
 
static BOOL IfCav(CCOM_comp* comp);
87
 
static int GetBoundFromStr(CCOM_comp* comp,BOOL IfCav,int& max_bottom,int& min_top);
88
 
static BOOL NotNeedCut(CCOM_comp* comp);
 
80
static int GetCountCutLetters(CCOM_comp* comp, uchar* pmasp);
 
81
static int IfNeedCut(CCOM_comp* comp, Bool* type_let);
 
82
//static Bool GetMasP(Rect16 Rc,uchar** ppmasp);
 
83
static Bool JNotInMas2(int j,int* mas,int size,int bound);
 
84
static Bool JNotInMas(int j,int* mas,int size,int bound);
 
85
static Bool IfZpt(CCOM_comp* comp);
 
86
static Bool IfCav(CCOM_comp* comp);
 
87
static int GetBoundFromStr(CCOM_comp* comp,Bool IfCav,int& max_bottom,int& min_top);
 
88
static Bool NotNeedCut(CCOM_comp* comp);
89
89
static int ExBound(CCOM_comp* comp,int bound);
90
90
static int GetRastWide(RecRaster* rast,int& left,int& right);
91
 
static BOOL IfHightLetters(CCOM_comp* comp,BOOL Up,int real_left,int real_right);
92
 
static BOOL IfNearLetters(CCOM_comp* cutting,CCOM_comp* comp);
 
91
static Bool IfHightLetters(CCOM_comp* comp,Bool Up,int real_left,int real_right);
 
92
static Bool IfNearLetters(CCOM_comp* cutting,CCOM_comp* comp);
93
93
static void NotCutDownLetter(RecRaster* rast,int& bound,int rast_bound,int new_rast_bound,int delta,int mini_w,int scale);
94
 
static BOOL IfWhiteRow(RecRaster* rast,int row);
 
94
static Bool IfWhiteRow(RecRaster* rast,int row);
95
95
/*********************************************************************************************/
96
96
RCUTP_FUNC(Bool32) RCUTP_RSelStr_SetEnv(/*char* szImageName,*/ int _medium_h, int _inf_let_w,
97
97
                                                                                int _inf_dust_h, int _inf_let_h, Handle hCCOM,
98
98
                                                                                int _sup_dust_w, int _min_cut_down_let_w,
99
 
                                                                                int _sup_prob_w, const Word16 biBit)
 
99
                                                                                int _sup_prob_w, const uint16_t biBit)
100
100
{
101
101
        if (_medium_h < 0 || _inf_let_w < 0 || _inf_dust_h < 0 || _inf_let_h < 0 ||
102
102
                _sup_dust_w < 0 || _min_cut_down_let_w < 0 || _sup_prob_w < 0 || !hCCOM)
125
125
        env_set = false;
126
126
}
127
127
/*********************************************************************************************/
128
 
RCUTP_FUNC(int) RCUTP_RSelStr_CP(CCOM_comp* comp, BOOL* type_let, Word8* pmasp)
 
128
RCUTP_FUNC(int) RCUTP_RSelStr_CP(CCOM_comp* comp, Bool* type_let, uchar* pmasp)
129
129
{
130
130
        if (!comp || !env_set || !pmasp) return 0;
131
131
 
134
134
        return IfNeedCut(comp, type_let);
135
135
}
136
136
/*********************************************************************************************/
137
 
int GetCountCutLetters(CCOM_comp* comp, Word8* pmasp)
 
137
int GetCountCutLetters(CCOM_comp* comp, uchar* pmasp)
138
138
{
139
 
 Word8 Data[1000];
 
139
 uchar Data[1000];
140
140
 memset (Data, 0, sizeof (Data));
141
 
// Word8* pmasp=Data;
 
141
// uchar* pmasp=Data;
142
142
 Rect16 Rc;
143
143
 
144
144
 
166
166
 
167
167
 int newstr;
168
168
 int bytewide=(w+7)/8;
169
 
 Word8 bytep;
 
169
 uchar bytep;
170
170
 int rect=128>>(7-(bytewide*8-w));
171
171
 int count_black=0;
172
172
 int i;
243
243
         return count;
244
244
}
245
245
/*********************************************************************************************/
246
 
int IfNeedCut(CCOM_comp* comp, BOOL* type_let)
 
246
int IfNeedCut(CCOM_comp* comp, Bool* type_let)
247
247
{
248
248
 int bound;
249
249
 int upper=-1;
287
287
}
288
288
 
289
289
/*********************************************************************************************/
290
 
BOOL JNotInMas2(int j,int* mas,int size,int bound)
 
290
Bool JNotInMas2(int j,int* mas,int size,int bound)
291
291
{
292
292
  int i;
293
293
  for(i=j+medium_h;i>=j;i--)
309
309
        return TRUE;
310
310
}
311
311
/*********************************************************************************************/
312
 
BOOL JNotInMas(int j,int* mas,int size,int bound)
 
312
Bool JNotInMas(int j,int* mas,int size,int bound)
313
313
{
314
314
        for(size--;size>bound;size--)
315
315
        {
319
319
        return TRUE;
320
320
}
321
321
/*********************************************************************************************/
322
 
BOOL IfZpt(CCOM_comp* comp)
 
322
Bool IfZpt(CCOM_comp* comp)
323
323
{
324
324
 int bound=comp->upper+inf_dust_h-1;
325
325
 
342
342
 return FALSE;
343
343
}
344
344
/*********************************************************************************************/
345
 
BOOL IfCav(CCOM_comp* comp)
 
345
Bool IfCav(CCOM_comp* comp)
346
346
{
347
347
 int bound=comp->upper+comp->h-1-inf_dust_h;
348
348
 
380
380
 return FALSE;
381
381
}
382
382
/*********************************************************************************************/
383
 
int GetBoundFromStr(CCOM_comp* comp,BOOL IfCav,int& max_bottom,int& min_top)
 
383
int GetBoundFromStr(CCOM_comp* comp,Bool IfCav,int& max_bottom,int& min_top)
384
384
{
385
385
 int up=comp->upper;
386
386
 int down=comp->upper+comp->h-1;
424
424
 return (max_bottom+min_top)>>1;
425
425
}
426
426
/*********************************************************************************************/
427
 
BOOL NotNeedCut(CCOM_comp* comp)
 
427
Bool NotNeedCut(CCOM_comp* comp)
428
428
{
429
429
 CCOM_comp Test;
430
430
 CCOM_comp Test_Next;
438
438
 Test_Next.upper=bound+1;
439
439
 Test_Next.h=comp->h-Test.h;
440
440
 
441
 
 BOOL ret1=FALSE;
442
 
 BOOL ret2=FALSE;
 
441
 Bool ret1=FALSE;
 
442
 Bool ret2=FALSE;
443
443
 
444
444
 if(IfNearLetters(comp,&Test))
445
445
        ret1=TRUE;
471
471
 int left_bound;
472
472
 int right_bound;
473
473
 int bytewide=((rast.lnPixWidth+63)/64)*8;
474
 
 Word8 bytep;
475
 
 BOOL Not_move_down=FALSE;
 
474
 uchar bytep;
 
475
 Bool Not_move_down=FALSE;
476
476
 
477
477
 if(rast_bound+delta>rast.lnPixHeight||rast_bound-delta<0)
478
478
         return bound;
597
597
        return wide;
598
598
}
599
599
/*********************************************************************************************/
600
 
BOOL IfHightLetters(CCOM_comp* comp,BOOL Up,int real_left,int real_right)
 
600
Bool IfHightLetters(CCOM_comp* comp,Bool Up,int real_left,int real_right)
601
601
{
602
602
  int Root_Up=comp->upper;
603
603
  int Root_Down=comp->upper+comp->h-1;
604
604
  int left=real_left;
605
605
  int right=real_right;
606
606
  int double_width=inf_let_w*3;
607
 
  BOOL fl_as_cav=FALSE;
 
607
  Bool fl_as_cav=FALSE;
608
608
 
609
609
  CCOM_comp* co=CCOM_GetFirst((CCOM_handle)HCCOM,NULL);
610
610
  while(co)
650
650
 return FALSE;
651
651
}
652
652
/*********************************************************************************************/
653
 
BOOL IfNearLetters(CCOM_comp* cutting,CCOM_comp* comp)
 
653
Bool IfNearLetters(CCOM_comp* cutting,CCOM_comp* comp)
654
654
{
655
655
 CCOM_comp* co;
656
656
 int med_h=(2*(comp->upper)+comp->h-1)/2;
709
709
{
710
710
 int left_bound;
711
711
 int right_bound;
712
 
 Word8 bytep;
 
712
 uchar bytep;
713
713
 int bytewide=((rast->lnPixWidth+63)/64)*8;
714
 
 BOOL fl_cut=FALSE;
715
 
 BOOL fl_break=FALSE;
 
714
 Bool fl_cut=FALSE;
 
715
 Bool fl_break=FALSE;
716
716
 int oldleft;
717
717
 int oldright;
718
718
 int min_wide=10000;
793
793
           break;
794
794
 }
795
795
 
796
 
 //�����?
 
796
 //дырка?
797
797
 
798
798
 left_bound=0;
799
799
 right_bound=rast->lnPixWidth-1;
837
837
 }
838
838
}
839
839
/*********************************************************************************************/
840
 
BOOL IfWhiteRow(RecRaster* rast,int row)
 
840
Bool IfWhiteRow(RecRaster* rast,int row)
841
841
{
842
842
 int bytewide=8*((rast->lnPixWidth+63)/64);
843
843
 int byte_row=row>>3;
844
844
 int rect_row=128>>(row%8);
845
 
 Word8* Raster=rast->Raster;
 
845
 uchar* Raster=rast->Raster;
846
846
 for(int i=rast->lnPixHeight-1;i>=0;i--)
847
847
 {
848
848
         if(Raster[i*bytewide+byte_row]&rect_row)