~ubuntu-branches/ubuntu/precise/cuneiform/precise

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/lns32/src/hliner.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk, c-assert.diff, slovenian-slv.diff
  • Date: 2011-01-26 21:53:07 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110126215307-62x61mcesr607qb7
Tags: 1.0.0+dfsg-2
* Upload to unstable.
* Explicitly build-depend on pkg-config. Thanks to Stefano Rivera for the
  bug report.
* Add Vcs-* fields.
* Use the standard C assert() macro, rather than custom Cuneiform one.
  [c-assert.diff]
* Pass CFLAGS, CXXFLAGS and LDFLAGS (get from dpkg-buildflags) to cmake
  (closes: #608345). Thanks to Sami Liedes for the bug report.
  + Build depend on dpkg-dev (>= 1.15.7).
* Pass --parallel to dh.
  + Bump debhelper minimum version to 7.4.10.
* Update debian/copyright to the latest DEP-5 version.
* Bump year in debian/copyright.
* Explicitly link to GraphicsMagick (rather than via the ImageMagick
  compatibility layer).
* Don't ship /usr/lib/cuneiform/*.so symlinks. These libraries are
  considered private, at least until #598616 is fixed.
* Rename some private variables in debian/rules to make them lowercase.
* Update patch headers.
* Provide proper ‘build-arch’ and ‘build-indep’ targets in debian/rules.
* Document input format in the manual page (closes: #572061). Thanks to
  Janusz S. Bień for the bug report.
* Use ‘slv’ (rather than ‘slo’) as language code for Slovenian.
  [slovenian-slv.diff]
* Fix package description: Slovenian is supported, Slovak is not.
* Improve documentation of the language (-l) option (closes: #602512).
  Thanks to Jari Aalto for the bug report.
* Install reasons file for vrms.

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:
79
79
 
80
80
 
81
81
 
82
 
static Int32 nByteWidth;
83
 
static Int32 nLine=0;
 
82
static int32_t nByteWidth;
 
83
static int32_t nLine=0;
84
84
 
85
85
//static Bool  bReady = FALSE;
86
86
 
87
 
static XMatrix< Word8 > xmImageMap;
 
87
static XMatrix< uchar > xmImageMap;
88
88
static XStack<Line16>   xsLines;
89
 
extern const Word8 bit1_cnt[256];
90
 
extern const Word8 bit0_cnt[256];
91
 
static const Word8* BlackBitsCountTbl=bit1_cnt;
 
89
extern const uchar bit1_cnt[256];
 
90
extern const uchar bit0_cnt[256];
 
91
static const uchar* BlackBitsCountTbl=bit1_cnt;
92
92
static Tiger_ImageInfo ImageInfo={0};
93
93
 
94
94
 
124
124
   nLine=0;
125
125
}
126
126
 
127
 
inline Word8* GetMapLine( int n )
 
127
inline uchar* GetMapLine( int n )
128
128
{
129
129
   return &(xmImageMap.Get( n, 0 ));
130
130
}
131
131
 
132
 
Bool32   HLiner_AddImageLine( Word8* pLine )
 
132
Bool32   HLiner_AddImageLine( uchar* pLine )
133
133
{
134
134
   if (nLine < 0 || nLine > ImageInfo.wImageHeight-1)
135
135
      RET_FALSE;
136
136
 
137
 
   Word8* res = GetMapLine(nLine/2);
138
 
   int nWords = (ImageInfo.wImageWidth+15) / 16; //Almi: ���� ����� ��� ������ 21 mar 2002 - ����: = ImageInfo.wImageByteWidth >> 1;
 
137
   uchar* res = GetMapLine(nLine/2);
 
138
   int nWords = (ImageInfo.wImageWidth+15) / 16; //Almi: Вася нашёл эту ошибку 21 mar 2002 - было: = ImageInfo.wImageByteWidth >> 1;
139
139
   while (nWords--)
140
140
   {
141
141
      *res += BlackBitsCountTbl[*pLine++];   // get 16 bits
207
207
   return (jj - j) > 3;
208
208
}
209
209
 
210
 
Int32    HLiner_Analyze(void) // returns count of extracted lines
 
210
int32_t    HLiner_Analyze(void) // returns count of extracted lines
211
211
{
212
212
   int gap = 3; // count of zero cells on up and down direction
213
213
   int wid = 3; // count of notzero cells on left or right side
214
214
   int nHeight = xmImageMap.GetHeight();
215
215
   int nWidth  = xmImageMap.GetWidth();
216
 
 
 
216
 
217
217
   int i(0);
218
218
   for (i=gap; i<nHeight-gap-1; i++)  // by lines
219
219
   {
220
 
      Word8* line_hi = GetMapLine(i - gap);
221
 
      Word8* line_on = GetMapLine(i);
222
 
      Word8* line_lo = GetMapLine(i + gap);
 
220
      uchar* line_hi = GetMapLine(i - gap);
 
221
      uchar* line_on = GetMapLine(i);
 
222
      uchar* line_lo = GetMapLine(i + gap);
223
223
      for (int j=wid; j<nWidth-wid-1; j++)  // first column
224
224
      {
225
225
         if (!line_on[j])
238
238
      }
239
239
   }
240
240
 
241
 
   // ���������� ����� � ������� ��������
 
241
   // замазываем дырки и убиваем одиночек
242
242
   for (i=gap; i<nHeight-gap-1; i++)  // by lines
243
243
   {
244
 
      Word8* line_on = GetMapLine(i);
 
244
      uchar* line_on = GetMapLine(i);
245
245
      for (int j=wid; j<nWidth-wid-1; j++)  // first column
246
246
      {
247
247
         if (line_on[j] == 100)
261
261
 
262
262
   // now link lines from start to end
263
263
   //
264
 
   Word8* line_on = NULL;
 
264
   uchar* line_on = NULL;
265
265
   Line16 ln={0};
266
266
   for (i=gap; i<nHeight-gap-1; i++)  // by lines
267
267
   {
268
 
      Word8* line_on = GetMapLine(i);
 
268
      uchar* line_on = GetMapLine(i);
269
269
      for (int j=wid; j<nWidth-wid-1; j++)  // first column
270
270
      {
271
271
         if (line_on[j] != 100)
300
300
   return  xsLines.GetCurCnt();
301
301
}
302
302
 
303
 
Int32  HLiner_GetCount(void)
 
303
int32_t  HLiner_GetCount(void)
304
304
{
305
305
   return  xsLines.GetCurCnt();
306
306
}
307
307
 
308
 
Line16*  HLiner_GetLine( Int32 nLineIndex )
 
308
Line16*  HLiner_GetLine( int32_t nLineIndex )
309
309
{
310
310
   return &(xsLines[nLineIndex]);
311
311
} // 0..count-1