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
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
33
Redistribution and use in source and binary forms, with or without modification,
34
are permitted provided that the following conditions are met:
36
* Redistributions of source code must retain the above copyright notice,
37
this list of conditions and the following disclaimer.
38
* Redistributions in binary form must reproduce the above copyright notice,
39
this list of conditions and the following disclaimer in the documentation
40
and/or other materials provided with the distribution.
41
* Neither the name of the Cognitive Technologies nor the names of its
42
contributors may be used to endorse or promote products derived from this
43
software without specific prior written permission.
45
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
49
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58
#include "searchneg.h"
62
void DelIn(Handle hCPage,NegList** proot,int& nRc)
71
memset (Data, 0, sizeof (Data));
78
if((nowout->neg).pRc[0].bottom-(nowout->neg).pRc[(nowout->neg).nRc-1].top>(nowout->neg).pRc[0].right-(nowout->neg).pRc[0].left)
82
while(nowin && nowout)
96
if(!(nowin->neg.pRc[(nowin->neg).nRc-1].top>=nowout->neg.pRc[0].bottom||nowout->neg.pRc[(nowout->neg).nRc-1].top>=nowin->neg.pRc[0].bottom))
98
if( ((nowout->neg).pRc[0].left<(nowin->neg).pRc[0].left)&&((nowout->neg).pRc[0].right>(nowin->neg).pRc[0].left))
100
Rc.bottom=(nowout->neg).pRc[0].bottom;
101
Rc.top=(nowout->neg).pRc[(nowout->neg).nRc-1].top;
102
Rc.left=(nowout->neg).pRc[0].left;
103
Rc.right=(nowin->neg).pRc[0].left;
105
if(!GetMasP(&Rc,&pmasp))
108
blackout=NegBlack(pmasp,Rc);
109
Rc.bottom=(nowin->neg).pRc[0].bottom;
110
Rc.top=(nowin->neg).pRc[(nowin->neg).nRc-1].top;
111
Rc.left=(nowout->neg).pRc[0].right;
112
Rc.right=(nowin->neg).pRc[0].right;
113
if(Rc.right<=Rc.left)
118
if(!GetMasP(&Rc,&pmasp))
121
blackin=NegBlack(pmasp,Rc);
123
if(blackout>=blackin)
161
double NegBlack(Word8* pmasp,Rect16 Rc)
163
int w=Rc.right-Rc.left+1;
164
const int bytewide=(w+7)/8;
165
int h=Rc.bottom-Rc.top+1;
166
register int i=7-(bytewide*8-w);
171
register Word8 bytep;
172
register int count_black=w*h;
173
register Word8* p=pmasp;
174
register Word8* pend=p+h*bytewide;
182
count_black-=((bytep&(128>>k))>>(7-k));
187
count_black-=((bytep>>7)+((bytep&64)>>6)+((bytep&32)>>5)+((bytep&16)>>4)+((bytep&8)>>3)+((bytep&4)>>2)+((bytep&2)>>1)+(bytep&1));
192
return (double)(count_black)/(double)(w*h);
195
void CutNegStr(Handle hCPage,NegList** proot,int& nRc,int skew)
202
NegList* now=(*proot);
207
memset (Data, 0, sizeof (Data));
214
w=(now->neg).pRc[0].right-(now->neg).pRc[0].left+1;
215
h=(now->neg).pRc[0].bottom-(now->neg).pRc[0].top+1;
216
if( (h<=inf_neg_h*2) || (w<=inf_neg_w ) || (h>w) )
224
if((now->neg).rot.pmasp)
225
pmasp=(now->neg).rot.pmasp;
229
if(!(GetMasP((now->neg).pRc,&pmasp)) )
238
NegInvert(pmasp,(now->neg).pRc[0]);
239
Rc.top=now->neg.pRc->top;
240
Rc.bottom=now->neg.pRc->bottom;
241
RSELSTR_CutStr(&((now->neg).pRc),(now->neg).nRc,(now->neg).len_mas,pmasp,DPIX,DPIY,30);
254
now->neg.pRc[now->neg.nRc-1].top=Rc.top;
255
now->neg.pRc->bottom=Rc.bottom;
263
void CutNeg(Handle hCPage,NegList** proot,int& nRc,int skew)
268
NegList* root=(*proot);
276
register Word8 bytep;
277
register int count_black;
284
register Word8* pend;
289
const int size_Rect16=sizeof(Rect16);
291
memset (Data, 0, sizeof (Data));
297
/* if(IsNegBlack(hCPage,now))
299
if((now->neg).rot.pmasp)
300
RSELSTR_UnRotateRect(-skew,&((now->neg).pRc[0]),1,(now->neg).rot.Rc,(now->neg).rot.begx,(now->neg).rot.movey,(now->neg).rot.flmovey,(now->neg).rot.hi);
301
DeleteRotateMas(&((now->neg).rot.pmasp),&((now->neg).rot.begx),&((now->neg).rot.movey),&((now->neg).rot.flmovey),&((now->neg).rot.hi));
308
w=(now->neg).pRc[0].right-(now->neg).pRc[0].left+1;
309
h=(now->neg).pRc[0].bottom-(now->neg).pRc[0].top+1;
310
if( (h<=inf_neg_h*3) || (w<=inf_neg_w ) )
312
if((now->neg).rot.pmasp)
313
RSELSTR_UnRotateRect(-skew,&((now->neg).pRc[0]),1,(now->neg).rot.Rc,(now->neg).rot.begx,(now->neg).rot.movey,(now->neg).rot.flmovey,(now->neg).rot.hi);
314
DeleteRotateMas(&((now->neg).rot.pmasp),&((now->neg).rot.begx),&((now->neg).rot.movey),&((now->neg).rot.flmovey),&((now->neg).rot.hi));
321
if((now->neg).rot.pmasp)
322
pmasp=(now->neg).rot.pmasp;
327
if(!(GetMasP(now->neg.pRc,&pmasp)) )
340
top=(now->neg).pRc[0].top;
344
pend=pmasp+(bytewide-1);
346
neg_top=(now->neg).pRc[0].top;
347
neg_bottom=(now->neg).pRc[0].bottom;
348
neg_left=(now->neg).pRc[0].left;
349
neg_right=(now->neg).pRc[0].right;
350
stop=neg_bottom-top+1-inf_neg_h;
362
count_black-=((bytep>>7)+((bytep&64)>>6)+((bytep&32)>>5)+((bytep&16)>>4)+((bytep&8)>>3)+((bytep&4)>>2)+((bytep&2)>>1)+(bytep&1));
367
count_black-=((bytep&(128>>k))>>(7-k));
369
proc=((double)(count_black))/((double)(w));
373
if(proc<=neg_cut_white)
376
if(IsNegSize(top-neg_top+1,w)&&(!(IfNegIn(root,nRc,oldtop,top,neg_left,neg_right))) )
380
Rc.left=(now->neg).pRc[0].left;
381
Rc.right=(now->neg).pRc[0].right;
382
if((now->neg).rot.pmasp)
384
RSELSTR_UnRotateRect(-skew,&Rc,1,(now->neg).rot.Rc,(now->neg).rot.begx,(now->neg).rot.movey,(now->neg).rot.flmovey,(now->neg).rot.hi);
387
temp=new NegList(Rc);
388
memcpy(&(temp->neg.rot.Rc),&(now->neg.rot.Rc),size_Rect16);
390
PostRotate(temp,skew);
397
if(proc>=neg_cut_black)
412
if(((now->neg).pRc[0].bottom-oldtop+1<inf_neg_h)||((IfNegIn(root,nRc,oldtop,top,(now->neg).pRc[0].left,(now->neg).pRc[0].right))) )
423
(now->neg).pRc[0].top=oldtop;
424
if((now->neg).rot.pmasp)
426
RSELSTR_UnRotateRect(-skew,&((now->neg).pRc[0]),1,(now->neg).rot.Rc,(now->neg).rot.begx,(now->neg).rot.movey,(now->neg).rot.flmovey,(now->neg).rot.hi);
427
PostRotate(now,skew);
429
DeleteRotateMas(&((now->neg).rot.pmasp),&((now->neg).rot.begx),&((now->neg).rot.movey),&((now->neg).rot.flmovey),&((now->neg).rot.hi));
439
BOOL IfNegIn(NegList* root,int nRc,int top,int bottom,int left,int right)
444
int s_top=3*(DPIY+1)/300;
445
int s_bot=3*(DPIY+1)/300;
453
neg_top=(now->neg).pRc[0].top;
454
neg_bottom=(now->neg).pRc[0].bottom;
455
neg_left=(now->neg).pRc[0].left;
456
neg_right=(now->neg).pRc[0].right;
457
if((neg_top==top)&&(neg_bottom==bottom)&&(neg_left==left)&&(neg_right==right))
460
d_bot=neg_bottom-bottom;
461
if((d_top<s_top)&&(d_bot<s_bot))
463
if( ((neg_left<=left)&&(neg_right>left)) || ((neg_left>left)&&(right>neg_left)) )
473
BOOL SearchNegBySize(CCOM_handle hCCOM, Handle hCPage,NegList** ROOT,int& nRC)
479
pcomp = CCOM_GetFirst (hCCOM, NULL);
483
GetPageInfo(hCPage,&info);
488
if( IsNegSize(Rc.bottom-Rc.top+1,Rc.right-Rc.left+1) )
490
if(!(root=new NegList(Rc) ))
497
pcomp = CCOM_GetNext (pcomp, NULL);
503
if( IsNegSize(Rc.bottom-Rc.top+1,Rc.right-Rc.left+1) )
507
if(!(root=new NegList(Rc) ))
514
temp=new NegList(Rc);
530
void SearchNegByBlack(Handle hCPage,NegList** proot,int& nRC)
532
NegList* now=(*proot);
536
if(!(IsNegBlack(hCPage,now)) )
551
BOOL IfDrob(Handle hCPage,Rect16* pRc,int num,CCOM_comp * pdr)
555
int oldbot=pRc[num].bottom;
556
int oldtop=pRc[num].top;
558
int oldright=pRc[num].right;
559
int oldleft=pRc[num].left;
560
int delta_top=pRc[num].top-pdr->upper;
561
if(delta_top<0) delta_top=-delta_top;
562
int delta_bottom=pRc[num].bottom-pdr->upper-pdr->h+1;
563
if(delta_bottom<0) delta_bottom=-delta_bottom;
565
if( (left-oldright)>inteps || (left-oldright)<0 )
567
if( (delta_top>delta) || (delta_bottom>delta) )
570
if(oldtop>pdr->upper) pRc[num].top=pdr->upper;
571
if(oldbot<pdr->upper+pdr->h-1) pRc[num].bottom=pdr->upper+pdr->h-1;
572
pRc[num].left=oldright;
574
if( !(IsNegBlack(hCPage,now,num)) )
577
pRc[num].bottom=oldbot;
578
pRc[num].right=oldright;
579
pRc[num].left=oldleft;
584
pRc[num].left=oldleft;
585
pRc[num].right=pdr->left+pdr->w-1;
594
void NormNeg(Handle hCPage,NegList* now,NegList** proot,int& nRc)
599
Rect16* Rc=(now->neg).pRc;
603
register Word8 bytep;
604
register int count_black;
609
register Word8* pend;
613
if((now->neg).rot.pmasp)
615
pmasp=(now->neg).rot.pmasp;
620
memset (Data, 0, sizeof (Data));
623
if(!(GetMasP(Rc,&pmasp)) )
628
BOOL top=FALSE,left=FALSE,right=FALSE,bottom=FALSE;
632
while( ((*Rc).bottom+1)>Height )
638
while( ((*Rc).right+1)>Width )
641
int prewide=(((*Rc).right-(*Rc).left+8)/8)*8;
642
if( ((*Rc).left+prewide)>Width )
646
if(!(GetMasP(Rc,&pmasp)) )
648
//��������!!! ����� �� ������ ���������������
649
if((*Rc).top<5) top=TRUE;
650
if((*Rc).left<5) left=TRUE;
651
if((*Rc).right>(Int16)(Width)-5) right=TRUE;
652
if((*Rc).bottom>(Int16)(Height)-5) bottom=TRUE;
656
if(top) ((*Rc).top)++;
657
if(bottom) ((*Rc).bottom)--;
658
if(left) ((*Rc).left)++;
659
if(right) ((*Rc).right)--;
661
if( GetMasP(Rc,&pmasp) )
676
w=(*Rc).right-(*Rc).left+1;
677
h=(*Rc).bottom-(*Rc).top+1;
678
const int bytewide=(w+7)/8;
687
stop=h-topp-inf_neg_h;
689
black_del=sup_neg_black_del;
695
// if( (h-topp)>(w-lp) ) black_del=sup_neg_black_del;
696
// else black_del=weak_neg_black_del;
701
count_black-=((bytep>>7)+((bytep&64)>>6)+((bytep&32)>>5)+((bytep&16)>>4)+((bytep&8)>>3)+((bytep&4)>>2)+((bytep&2)>>1)+(bytep&1));
705
count_black-=((bytep&(128>>k))>>(7-k));
707
proc=((double)(count_black))/((double)(i));
715
if( !(IsNegSize(h-topp,w-lp)) )
724
stop=(h-topp)-inf_neg_h;
725
black_del=sup_neg_black_del;
726
pend=pmasp+(h-1)*bytewide;
731
// if( (h-topp)>(w-lp) ) black_del=sup_neg_black_del;
732
// else black_del=weak_neg_black_del;
736
count_black-=((bytep&(128>>k))>>(7-k));
741
count_black-=((bytep>>7)+((bytep&64)>>6)+((bytep&32)>>5)+((bytep&16)>>4)+((bytep&8)>>3)+((bytep&4)>>2)+((bytep&2)>>1)+(bytep&1));
743
proc=((double)(count_black))/((double)(i));
751
if( !(IsNegSize(h-topp,w-lp)) )
760
if( (h-topp)<(w-lp) )
761
black_del=sup_neg_black_del-.2;
763
black_del=weak_neg_black_del;
765
stop=(w-lp-inf_neg_h);
766
pbeg=pmasp+topp*bytewide+(lp>>3);
768
pend=pbeg+i*bytewide;
772
pbeg=pmasp+topp*bytewide+(lp>>3);
773
pend=pbeg+i*bytewide;
778
for(p=pbeg;p<=pend;p+=bytewide)
780
count_black-=((*p)>>7);
784
for(p=pbeg;p<=pend;p+=bytewide)
786
count_black-=(((*p)&64)>>6);
790
for(p=pbeg;p<=pend;p+=bytewide)
792
count_black-=(((*p)&32)>>5);
796
for(p=pbeg;p<=pend;p+=bytewide)
798
count_black-=(((*p)&16)>>4);
802
for(p=pbeg;p<=pend;p+=bytewide)
804
count_black-=(((*p)&8)>>3);
808
for(p=pbeg;p<=pend;p+=bytewide)
810
count_black-=(((*p)&4)>>2);
814
for(p=pbeg;p<=pend;p+=bytewide)
816
count_black-=(((*p)&2)>>1);
820
for(p=pbeg;p<=pend;p+=bytewide)
822
count_black-=((*p)&1);
829
proc=((double)(count_black))/((double)(h-topp));
835
if( !(IsNegSize(h-topp,w-lp)) )
844
if( (h-topp)<(w-lp) )
845
black_del=sup_neg_black_del-.2;
847
black_del=weak_neg_black_del;
849
stop=(w-lp-inf_neg_h);
850
pbeg=pmasp+topp*bytewide+((w-1)>>3);
852
pend=pbeg+i*bytewide;
856
pbeg=pmasp+topp*bytewide+((w-1)>>3);
857
pend=pbeg+i*bytewide;
859
switch(w&7)// real need w-1!!!
862
for(p=pbeg;p<=pend;p+=bytewide)
864
count_black-=((*p)>>7);
870
for(p=pbeg;p<=pend;p+=bytewide)
872
count_black-=(((*p)&64)>>6);
876
for(p=pbeg;p<=pend;p+=bytewide)
878
count_black-=(((*p)&32)>>5);
882
for(p=pbeg;p<=pend;p+=bytewide)
884
count_black-=(((*p)&16)>>4);
888
for(p=pbeg;p<=pend;p+=bytewide)
890
count_black-=(((*p)&8)>>3);
894
for(p=pbeg;p<=pend;p+=bytewide)
896
count_black-=(((*p)&4)>>2);
900
for(p=pbeg;p<=pend;p+=bytewide)
902
count_black-=(((*p)&2)>>1);
906
for(p=pbeg;p<=pend;p+=bytewide)
908
count_black-=((*p)&1);
913
proc=((double)(count_black))/((double)(h-topp));
919
if( !(IsNegSize(h-topp-2,w-lp-2)) )
928
(*Rc).right=(*Rc).left+w-1-1;
930
(*Rc).bottom=(*Rc).top+h-1-1;
935
void NegMoveMas(Rect16* pRc,int& nRc,int num)
938
for(i=num;i<(nRc-1);i++)
940
pRc[i].left=pRc[i+1].left;
941
pRc[i].top=pRc[i+1].top;
942
pRc[i].right=pRc[i+1].right;
943
pRc[i].bottom=pRc[i+1].bottom;
948
void NegMoveMas(Rotating* rot,int nRc,int num)
951
r.begx=rot[num].begx;
952
r.flmovey=rot[num].flmovey;
954
r.movey=rot[num].movey;
955
r.pmasp=rot[num].pmasp;
956
for(int i=num;i<nRc-1;i++)
958
rot[i].begx=rot[i+1].begx;
959
rot[i].flmovey=rot[i+1].flmovey;
960
rot[i].hi=rot[i+1].hi;
961
rot[i].movey=rot[i+1].movey;
962
rot[i].pmasp=rot[i+1].pmasp;
965
rot[i].flmovey=r.flmovey;
967
rot[i].movey=r.movey;
968
rot[i].pmasp=r.pmasp;
969
DeleteRotateMas(rot[i].pmasp,rot[i].begx,rot[i].movey,rot[i].flmovey,rot[i].hi);
972
void PMoveMas(double* p,int nRc,int num)
975
for(i=num;i<(nRc-1);i++)
980
void NegMoveMasR(Rect16* pRc,int& nRc,int num)
985
pRc[i].left=pRc[i-1].left;
986
pRc[i].top=pRc[i-1].top;
987
pRc[i].right=pRc[i-1].right;
988
pRc[i].bottom=pRc[i-1].bottom;
994
BOOL IsNegSize(Int16 h,Int16 w)
996
if( (h<inf_neg_h) || (w<inf_neg_h) ) return FALSE;
997
if( (h<inf_neg_w) && (w<inf_neg_w) ) return FALSE;
1001
BOOL IsNegBlack(Handle hCPage,NegList* now)
1005
if((now->neg).rot.pmasp)
1006
pmasp=(now->neg).rot.pmasp;
1010
memset (Data, 0, sizeof (Data));
1012
if(!(GetMasP(now->neg.pRc,&pmasp)) )
1014
while(IsNegSize((now->neg).pRc[0].bottom-(now->neg).pRc[0].top+1,(now->neg).pRc[0].right-(now->neg).pRc[0].left+1) )
1016
((now->neg).pRc[0].top)++;
1017
((now->neg).pRc[0].bottom)--;
1018
((now->neg).pRc[0].left)++;
1019
((now->neg).pRc[0].right)--;
1021
if( GetMasP((now->neg).pRc,&pmasp) )
1025
if(!(GetMasP((now->neg).pRc,&pmasp)) )
1029
int w=(now->neg).pRc[0].right-(now->neg).pRc[0].left+1;
1030
int h=(now->neg).pRc[0].bottom-(now->neg).pRc[0].top+1;
1031
const int bytewide=(w+7)/8;
1032
register int count_black=w*h;
1033
register Word8 bytep;
1040
register Word8* p=pmasp;
1041
const Word8* pend=p+h*bytewide;
1049
count_black-=((bytep&(128>>k))>>(7-k));
1054
count_black-=((bytep>>7)+((bytep&64)>>6)+((bytep&32)>>5)+((bytep&16)>>4)+((bytep&8)>>3)+((bytep&4)>>2)+((bytep&2)>>1)+(bytep&1));
1060
proc=((double)(count_black))/((double)(w*h));
1062
if(proc>inf_neg_black)
1069
BOOL GetMasP(Handle hCPage,Rect16 Rc,Word8** ppmasp)
1073
int h=Rc.bottom-Rc.top+1;
1074
int w=Rc.right-Rc.left+1;
1083
PAGEINFO info = {0};
1084
CIMAGEInfoDataInGet DataInto = {0};
1085
CIMAGEInfoDataOutGet DataOut = {0};
1086
Word8 Name[CPAGE_MAXNAME];
1090
/* 1. ���������� � ������� ����� �����������. */
1091
DataInto.dwHeight = (Word32)(h);
1092
DataInto.dwWidth = (Word32)(prewide);
1093
DataInto.wByteWidth = (Word16)(prewide/8);
1094
DataInto.dwX = left;
1095
DataInto.dwY = upper;
1096
DataInto.MaskFlag = 0x00;
1097
GetPageInfo(hCPage,&info);
1098
for (i=0; i<CPAGE_MAXNAME; i++)
1099
Name[i] = ImageName[i];
1100
DataOut.dwWidth = DataInto.dwWidth;
1101
DataOut.dwHeight = DataInto.dwHeight;
1102
DataOut.wByteWidth = DataInto.wByteWidth;
1103
DataOut.byBit = (Word16)info.BitPerPixel;
1104
DataOut.lpData = *ppmasp;
1106
/* 5. ������ ����� �����������. */
1107
ret = CIMAGE_GetData (Name, &DataInto, &DataOut);
1110
if (DataOut.lpData==NULL)
1112
*ppmasp = DataOut.lpData;
1116
BOOL GetMasP(Rect16* pRc,Word8** ppmasp)
1118
*ppmasp=pNegImage->GetPmasp(pRc);
1124
void PrintFrameComp(Handle hCPage,Rect16* pRc,int num)
1130
int h=pRc[num].bottom-pRc[num].top+1;
1131
int w=pRc[num].right-pRc[num].left+1;
1136
memset (Data, 0, sizeof (Data));
1138
if( !(GetMasP(&(pRc[num]),&pmasp)) )
1144
for(j=0;j<(bytewide-1);j++)
1147
for(k=128;k>=1;k=k>>1)
1148
if( (bytep&k)==0 ) printf("b");
1152
for(k=128;k>=rect;k=k>>1)
1153
if( (bytep&k)==0 ) printf("b");
1157
for(j=0;j<(bytewide-1);j++)
1159
bytep=pmasp[(h-1)*bytewide+j];
1160
for(k=128;k>=1;k=k>>1)
1161
if( (bytep&k)==0 ) printf("b");
1164
bytep=pmasp[(h-1)*bytewide+j];
1165
for(k=128;k>=rect;k=k>>1)
1166
if( (bytep&k)==0 ) printf("b");
1171
{bytep=pmasp[i*bytewide];
1172
if( (bytep&128)==0 ) printf("b");
1178
{bytep=pmasp[i*bytewide-1];
1179
if( (bytep&rect)==0 ) printf("b");
1185
BOOL InitNegMas(Rect16** ppRc,int len)
1188
if(!((*ppRc)=new Rect16[len]))
1194
BOOL InitNegMas(RecVersions** ppRc,int len)
1197
if(!((*ppRc)= new RecVersions[len]))
1202
BOOL InitNegMas(UniVersions** ppRc,int len)
1205
if(!((*ppRc)= new UniVersions[len]))
1211
BOOL InitNegMas(CCOM_comp*** ppRc,int len)
1214
if(!((*ppRc)=new CCOM_comp*[len]))
1219
void DelNegMas(Rect16 **masp)
1225
void DelNegMas(RecVersions *masp)
1230
void DelNegMas(UniVersions *masp)
1235
void DelNegMas(CCOM_comp **masp)
1241
BOOL AddLenNegMas(Rect16** ppRc,int& len,int add)
1244
if(!(InitNegMas(&dop,len)) )
1249
if(!(InitNegMas(ppRc,len+add)) )
1261
BOOL AddLenNegMas(CCOM_comp*** ppRc,int& len,int add)
1264
if(!(InitNegMas(&dop,len)) )
1269
if(!(InitNegMas(ppRc,len+add)) )
1281
void InitRc(Rect16* pRc,CCOM_comp * pcomp)
1283
pRc->left = pcomp->left;
1284
pRc->right = pcomp->left + pcomp->w - 1;
1285
pRc->top = pcomp->upper;
1286
pRc->bottom = pcomp->upper + pcomp->h - 1;
1290
void InitRc(Rect16* pRc,int nRc,CCOM_comp * pcomp)
1292
pRc[nRc].left = pcomp->left;
1293
pRc[nRc].right = pcomp->left + pcomp->w - 1;
1294
pRc[nRc].top = pcomp->upper;
1295
pRc[nRc].bottom = pcomp->upper + pcomp->h - 1;
1298
void NegInvert(Word8* pmasp,Rect16 N)
1301
Word8* pend=pmasp+(N.bottom-N.top+1)*( (N.right-N.left+8)/8 );
1314
void PostRotate(NegList* now,int skew)
1318
const int size_Rect16=sizeof(Rect16);
1319
memcpy(&Rc,&(now->neg.rot.Rc),size_Rect16);
1320
memcpy(&Rect,(now->neg.pRc),size_Rect16);
1321
const int h=Rc.bottom-Rc.top+1;
1323
if(h<3*(Rect.bottom-Rect.top))
1328
Rect.left+=((Rc.bottom-Rect.bottom)*skew)/2048;
1329
Rect.right-=((Rect.top-Rc.top)*skew)/2048;
1333
Rect.left+=((Rc.top-Rect.top)*skew)/2048;
1334
Rect.right-=((Rect.bottom-Rc.bottom)*skew)/2048;
1337
if(Rect.left>=Rect.right)
1338
Rect.right=Rect.left+1;
1340
memcpy(now->neg.pRc,&Rect,size_Rect16);
1345
/*union of two strogo more massivs
1349
void un(float [],float [],float [],int);
1352
{float *a,*b,*c,s;int n,i=0;FILE *f,*g;
1353
printf("Enter N\n");scanf("%d",&n);
1354
a=(float*)malloc(n*sizeof(float));
1355
b=(float*)malloc(n*sizeof(float));
1356
c=(float*)malloc((2*n+1)*sizeof(float));
1357
do{f=fopen("a.dat","r");g=fopen("b.dat","r");}while((f==NULL)||(g==NULL));
1358
while(fscanf(f,"%f",&s)>0){a[i]=s;i++;printf("%f ",s);}fclose(f);
1360
while(fscanf(g,"%f",&s)>0){b[i]=s;i++;printf("%f ",s);}fclose(g);printf("\n");
1362
while(c[i]!='\0'){printf("%f ",c[i]);i++;}
1365
void un(float a[],float b[],float c[],int n)
1366
{int i,j,l=0,m=0,d,e=0,k;float x;
1367
for(i=0; i<n; i++){x=b[i];d=n;
1368
while(e!=d){k=(d+e)/2;if(x>a[k]) e=k+1;else d=k;}
1369
if(x==a[d]){c[l]=a[m];l++;m++;continue;}
1370
for(j=m ; j<d ; j++){c[l]=a[m];l++;m++;}
1371
c[l]=x;l++;} c[l]='\0';