Bool32 remove_overlayed(CCOM_comp *sour,CCOM_handle haCCOM) { CCOM_comp *cur=CCOM_GetFirst(haCCOM,NULL), *curn; int32_t over=0; do { curn=CCOM_GetNext(cur,NULL); if( cur->upper<sour->upper && sour->upper-cur->upper>10*sour->h) { // upper zone cur=curn; continue; } if( comp_over(sour,cur) ) { CCOM_Delete(haCCOM,cur); over++; } if( cur->upper-sour->upper>10*sour->h) break; // downer zone cur = curn; }while( cur!=NULL ); return (over>0); }
void UndoCutInRect(Handle hCPAGE, CCOM_handle hCCOM, Rect32* Rc) { CCOM_comp * comp; int16_t top = (int16_t) Rc->top; int16_t bottom = (int16_t) Rc->bottom; int16_t left = (int16_t) Rc->left; int16_t right = (int16_t) Rc->right; CCOM_USER_BLOCK ub; for (comp = CCOM_GetFirst(hCCOM, NULL); comp; comp = CCOM_GetNext(comp, NULL)) { int size = sizeof(uint32_t); if (comp->upper >= top && comp->left >= left && comp->upper + comp->h <= bottom && comp->left + comp->w <= right) { if (comp->large & CCOM_LR_KILLED) { ub.code = Code_UB_Kill; if (CCOM_GetUserBlock(comp, &ub)) { if (ub.size == size) { if (*((uint32_t*) (ub.data)) == Code_UB_Kill) CCOM_Reanimate(comp); } } } else { ub.code = Code_UB_Create; if (CCOM_GetUserBlock(comp, &ub)) { if (ub.size == size) { if (*((uint32_t*) (ub.data)) == Code_UB_Create) CCOM_Kill(comp); } } } } } }
/*---------------------------------------------------------------------------*/ Bool LoadComps_rv (Handle hC, void *vB, char *pStr, int Filter) { CCOM_comp * pcomp; Bool GoodComp, Fir; int SizeCurr, Deficit, nTeor, nRc; UN_BUFF *pB; Rect16 *pCurr; pB = (UN_BUFF *)vB; nRc = 0; Deficit = 0; pCurr = (Rect16 *)pB->vCurr; SizeCurr = pB->SizeCurr; nTeor = sizeof (Rect16); Fir = TRUE; while (1) { /* ключ к данным */ if (Fir) { pcomp = CCOM_GetFirst(hC, NULL); Fir = FALSE; } else pcomp = CCOM_GetNext (pcomp, NULL); if (pcomp==NULL) break; GoodComp = CompIsGood (pcomp, Filter); if (!GoodComp) continue; if (nTeor > SizeCurr) { Deficit++; continue; } nRc++; /* собственно данные */ pCurr->left = pcomp->left; pCurr->right = pcomp->left + pcomp->w - 1; pCurr->top = pcomp->upper; pCurr->bottom = pcomp->upper + pcomp->h - 1; pCurr++; SizeCurr -= sizeof (Rect16); } if (nRc==0) { sprintf (pStr, "Нет компонент"); return RV_EMPTY; } EndLastDataPart (vB, UN_DA_CompReal, UN_DT_Rect16, nTeor, nRc); if (Deficit > 0) { sprintf (pStr, "Не хватило памяти под %d %s!", Deficit, "коробки компонент"); return RV_DOUBT; } return RV_TRUE; }
void DrawComps(Handle hCCOM) { CCOM_handle hccom = (CCOM_handle) hCCOM; extern Handle hDrawComp; CCOM_comp * comp; for (comp = CCOM_GetFirst(hccom, NULL); comp; comp = CCOM_GetNext(comp, NULL)) DrawRect(MainWindowD, 117, RGB(255,0,0), comp->upper, comp->upper + comp->h - 1, comp->left, comp->left + comp->w - 1); LDPUMA_WaitUserInput(hDrawComp, MainWindowD); LDPUMA_DeleteRects(MainWindowD, 117); }
int GetMediumH(CCOM_handle hCCOM) { int sum_h = 0; int count = 0; for (CCOM_comp* comp = CCOM_GetFirst(hCCOM, NULL); comp; comp = CCOM_GetNext(comp, NULL)) { if (comp->h > inf_let_h_cut_comp && comp->h < sup_let_h) { sum_h += comp->h; count++; } } if (!count) return (inf_let_h_cut_comp * 3) / 2; else return sum_h / count; }
Bool32 CreateContainerBigComp( PRSPreProcessImage Image ) { CCOM_handle hCCOM_old=(CCOM_handle)(*(Image->phCCOM)); Handle hCPage=Image->hCPAGE; CCOM_handle hCCOM_new=0; BIG_IMAGE big_Image; PAGEINFO info = {0}; GetPageInfo(hCPage,&info); int i=0; for(i=0;i<CPAGE_MAXNAME;i++) big_Image.ImageName[i]=info.szImageName[i]; hCCOM_new = CCOM_CreateContainer(); if(!hCCOM_new) { big_Image.hCCOM=NULL; return TRUE; } CCOM_comp* comp=NULL; CCOM_comp* new_comp; comp=CCOM_GetFirst(hCCOM_old,FALSE); while(comp) { if( (comp->h>=MIN_BIG_H)&&(comp->w>=MIN_BIG_W) ) { new_comp=CCOM_New(hCCOM_new,comp->upper,comp->left,comp->w,comp->h); if(new_comp) { if(comp->size_linerep<0) ; else { if(!CCOM_Copy(new_comp,comp) ) CCOM_Delete(hCCOM_new,comp); } } } comp=CCOM_GetNext(comp,FALSE); } big_Image.hCCOM=hCCOM_new; CPAGE_CreateBlock(hCPage,TYPE_BIG_COMP,0,0,&big_Image,sizeof(BIG_IMAGE)); return TRUE; }
int GetMediumHeight(POLY_* pBlock) { CCOM_comp * comp; int sum_height = 0; int count = 0; cf::Point16 pLeftTop; cf::Point16 pRightTop; cf::Point16 pLeftBottom; cf::Point16 pRightBottom; PAGEINFO info; GetPageInfo(HCPAGE, &info); int nIncline = info.Incline2048; for (comp = CCOM_GetFirst((CCOM_handle) HCCOM, NULL); comp; comp = CCOM_GetNext(comp, NULL)) { if (comp->h < inf_let_h) continue; pLeftTop.rx() = comp->left; pLeftTop.ry() = comp->upper - 1; pRightTop.rx() = comp->left + comp->w - 1; pRightTop.ry() = comp->upper - 1; pLeftBottom.rx() = comp->left; pLeftBottom.ry() = comp->upper + comp->h - 2; pRightBottom.rx() = comp->left + comp->w - 1; pRightBottom.ry() = comp->upper + comp->h - 2; IDEAL_XY(pLeftTop.rx(), pLeftTop.ry()); IDEAL_XY(pRightTop.rx(), pRightTop.ry()); IDEAL_XY(pLeftBottom.rx(), pLeftBottom.ry()); IDEAL_XY(pRightBottom.rx(), pRightBottom.ry()); if (IsInPoly(pLeftTop, pBlock) || IsInPoly(pRightTop, pBlock) || IsInPoly(pLeftBottom, pBlock) || IsInPoly(pRightBottom, pBlock)) { sum_height += comp->h; count++; } } if (!count) return medium_statistics_h; return sum_height / count; }
Bool UnifCont(CCOM_handle to,CCOM_handle from) { if(!to||!from) return FALSE; CCOM_comp* comp; CCOM_comp* new_comp; for(comp=CCOM_GetFirst(from,NULL);comp;comp=CCOM_GetNext(comp,NULL)) { new_comp=CCOM_New(to,comp->upper,comp->left,comp->w,comp->h); if(!new_comp) return FALSE; if(!CCOM_Copy(new_comp,comp)) return FALSE; } return TRUE; }
int GetStatisticsH() { int sum = 0; int count = 0; CCOM_comp * comp; comp = CCOM_GetFirst((CCOM_handle) HCCOM, NULL); while (comp) { if (comp->h > inf_let_h) { count++; sum += comp->h; } comp = CCOM_GetNext(comp, NULL); } if (!count) return 15; return sum / count; }
Bool32 SearchRectanglePictures(CCOM_handle hCCOM, CCOM_handle hCCOM_big, Handle hCPAGE) { uint32_t i, j; CCOM_comp pic; CCOM_comp * comp; uint16_t pLocalHystogram[MaxHeightOfLetter]; uint32_t nLocalComps; uint32_t MaxLocal, nMaxLocal; uint32_t Result1, Result2, Result3, Result4, tmp1, tmp2; Rect32 rect; int32_t LengthTotal, LengthByIntervals; Handle BlockType; RecRaster rec; RecVersions vs; int16_t Language; RPIC_Comp_Rect CompRect; BlockType = CPAGE_GetInternalType("pic's to letters boxes"); for (i = 0; i < nPics; i++) { pic = pPics[i]; my_upper = pic.upper; my_left = pic.left; my_bottom = pic.upper + pic.h; my_right = pic.left + pic.w; //Additional parameter - local distribution of heights //in case of local fragment with different (from main) height nLocalComps = 0; for (j = 0; j < MaxHeightOfLetter; j++) { pLocalHystogram[j] = 0; } //stepa_am comp = CCOM_GetFirst(hCCOM_big, &MyFiltrateIn); while (comp) { if ((comp->h < MaxHeightOfLetter) && (comp->h > MinHeightOfLetter)) { pLocalHystogram[comp->h]++; nLocalComps++; } comp = CCOM_GetNext(comp, &MyFiltrateIn); } //end stepa_am comp = CCOM_GetFirst(hCCOM, &MyFiltrateIn); while (comp) { if ((comp->h < MaxHeightOfLetter) && (comp->h > MinHeightOfLetter)) { pLocalHystogram[comp->h]++; nLocalComps++; } comp = CCOM_GetNext(comp, &MyFiltrateIn); } if (nLocalComps != 0) { MaxLocal = pLocalHystogram[0]; for (j = 0; j < MaxHeightOfLetter; j++) { if (pLocalHystogram[j] > MaxLocal) { MaxLocal = pLocalHystogram[j]; nMaxLocal = j; } } Result1 = 0; Result2 = 0; sprintf(tmp_str, " %i Result1 (must be 0)\n", Result1); LDPUMA_FPuts(logFile_comp, tmp_str); sprintf(tmp_str, " %i Result2 (must be 0)\n", Result2); LDPUMA_FPuts(logFile_comp, tmp_str); sprintf(tmp_str, " %i (nComps)\n", nComps); LDPUMA_FPuts(logFile_comp, tmp_str); //stepa_am comp = CCOM_GetFirst(hCCOM_big, &MyFiltrateIn); while (comp) { //sprintf(tmp_str, " %i (comp)\n", comp); //LDPUMA_FPuts(hFile,tmp_str); if ((comp->h < MaxHeightOfLetter - 1) && (comp->h > MinHeightOfLetter)) { sprintf(tmp_str, " %i (comp->h)\n", comp->h); LDPUMA_FPuts(logFile_comp, tmp_str); sprintf(tmp_str, " %i (pHystogram[comp->h])\n", pHystogram[comp->h]); LDPUMA_FPuts(logFile_comp, tmp_str); //Result1 += OVERALL*pHystogram[comp->h]; Result1 += pHystogram[comp->h] / 20 + pHystogram[comp->h - 1] / 20 + pHystogram[comp->h + 1] / 20; if (comp->h - nMaxLocal < DIFFERENCE1) { //Result2 += LOCAL*pLocalHystogram[comp->h]; Result2 += pLocalHystogram[comp->h] + pLocalHystogram[comp->h - 1] + pLocalHystogram[comp->h + 1]; } } comp = CCOM_GetNext(comp, &MyFiltrateIn); } //end stepa_am comp = CCOM_GetFirst(hCCOM, &MyFiltrateIn); while (comp) { //sprintf(tmp_str, " %i (comp)\n", comp); //LDPUMA_FPuts(hFile,tmp_str); if ((comp->h < MaxHeightOfLetter - 1) && (comp->h > MinHeightOfLetter)) { sprintf(tmp_str, " %i (comp->h)\n", comp->h); LDPUMA_FPuts(logFile_comp, tmp_str); sprintf(tmp_str, " %i (pHystogram[comp->h])\n", pHystogram[comp->h]); LDPUMA_FPuts(logFile_comp, tmp_str); //Result1 += OVERALL*pHystogram[comp->h]; Result1 += pHystogram[comp->h] / 20 + pHystogram[comp->h - 1] / 20 + pHystogram[comp->h + 1] / 20; if (comp->h - nMaxLocal < DIFFERENCE1) { //Result2 += LOCAL*pLocalHystogram[comp->h]; Result2 += pLocalHystogram[comp->h] + pLocalHystogram[comp->h - 1] + pLocalHystogram[comp->h + 1]; } } comp = CCOM_GetNext(comp, &MyFiltrateIn); } //Result1 = Result1/nComps; Result1 = Result1 / 10; //Result2 = Result2/nLocalComps; Result2 = Result2 / 20; sprintf(tmp_str, " Picture %i (i)\n", i); LDPUMA_FPuts(logFile_comp, tmp_str); sprintf(tmp_str, " %i (Result1)\n", Result1); LDPUMA_FPuts(logFile_comp, tmp_str); sprintf(tmp_str, " %i (Result2)\n", Result2); LDPUMA_FPuts(logFile_comp, tmp_str); if (Result1 + Result2 > CONDITION1) { DeleteFromPics(i); //i--; continue; } } /**************************************************************************/ /* Analys by comp's count of begins&ends */ /**************************************************************************/ CCOM_USER_BLOCK uBlock; uBlock.code = CCOM_UB_BEGENDS; if (CCOM_GetUserBlock(&pPics[i], &uBlock)) { if (*(uchar*) uBlock.data > 100) { continue; } } /**************************************************************************/ /* Analys by comp's intervals */ /**************************************************************************/ //CCOM_USER_BLOCK uBlock; uBlock.code = CCOM_UB_DENSITY; if (CCOM_GetUserBlock(&pPics[i], &uBlock)) { LengthByIntervals = *(int32_t*) uBlock.data; LengthTotal = pPics[i].h * pPics[i].w; if (LengthByIntervals == 0) { return FALSE; } if (LengthTotal / LengthByIntervals > CONDITION2) { DeleteFromPics(i); //i--; } } } /************** final union all crossed and included pictures ******************/ CCOM_comp common; for (i = 0; i < nPics; i++) { if (pPics[i].large & CCOM_LR_KILLED) { continue; } for (j = 0; j < nPics; j++) { if (pPics[j].large & CCOM_LR_KILLED) { continue; } if ((pPics[i].upper < pPics[j].upper) && (pPics[i].left < pPics[j].left) && (pPics[i].left + pPics[i].w > pPics[j].left + pPics[j].w) && (pPics[i].upper + pPics[i].h > pPics[j].upper + pPics[j].h)) { if ((pPics[i].type != CCOM_CH_LETTER) || (pPics[j].type != CCOM_CH_LETTER)) { pPics[i].type = CCOM_CH_MERGE; } DeleteFromPics(j); //j--; } } } for (i = 0; i < nPics; i++) { if (pPics[i].large & CCOM_LR_KILLED) { continue; } for (j = 0; j < nPics; j++) { if (pPics[j].large & CCOM_LR_KILLED) { continue; } if (i == j) continue; if ((pPics[i].upper < pPics[j].upper + pPics[j].h) && (pPics[i].left < pPics[j].left + pPics[j].w) && (pPics[i].left + pPics[i].w > pPics[j].left) && (pPics[i].upper + pPics[i].h > pPics[j].upper)) { common = pPics[i]; if (pPics[i].upper >= pPics[j].upper) common.upper = pPics[j].upper; if (pPics[i].left >= pPics[j].left) common.left = pPics[j].left; if (pPics[i].upper + pPics[i].h < pPics[j].upper + pPics[j].h) common.h = pPics[j].upper + pPics[j].h - pPics[i].upper; if (pPics[i].left + pPics[i].w < pPics[j].left + pPics[j].w) common.w = pPics[j].left + pPics[j].w - pPics[i].left; common.h += pPics[i].upper - common.upper; common.w += pPics[i].left - common.left; pPics[i] = common; /* if((pPics[i].type!=CCOM_CH_LETTER)||(pPics[j].type!=CCOM_CH_LETTER)) { pPics[i].type = CCOM_CH_MERGE; } */ pPics[i].type = CCOM_CH_NOTLTR; DeleteFromPics(j); //j=0; //i=0; } } } for (i = 0; i < nPics; i++) { if (pPics[i].large & CCOM_LR_KILLED) { continue; } pic = pPics[i]; my_upper = pic.upper; my_left = pic.left; my_bottom = pic.upper + pic.h; my_right = pic.left + pic.w; /* Deleting from Pics, in case of Titles and "Bukvica", zero version, planing CHECK (by Oleg) for Letters in case of Bukvica, else check for comps with compatible heights in local area (horizontal). */ if (pPics[i].scale <= 3) { rect.top = pPics[i].upper; rect.left = pPics[i].left + pPics[i].w; rect.bottom = pPics[i].upper + pPics[i].h; rect.right = pPics[i].left + pPics[i].w + pPics[i].h; CheckAreaForComps(hCCOM, hCCOM_big, rect, nAverageHeight, &Result1, &Result2); if ((Result1 > 10) && (pPics[i].type != CCOM_CH_NOTLTR)) { if (CCOM_GetRaster(&pPics[i], &rec) && CCOM_GetLanguage(hCCOM, &Language) && RSTR_RecogOneLetter(&rec, (uchar)( Language), &vs)) { if ((vs.lnAltCnt > 0) && (vs.Alt[0].Prob > 240) && (vs.Alt[0].Code != 'i') && (vs.Alt[0].Code != '1') && (vs.Alt[0].Code != 'I') && (vs.Alt[0].Code != 'l')) { pPics[i].type = CCOM_CH_LETTER; CompRect.upper = pPics[i].upper; CompRect.left = pPics[i].left; CompRect.h = pPics[i].h; CompRect.w = pPics[i].w; CPAGE_CreateBlock(hCPAGE, BlockType, 0, 0, &CompRect, sizeof(CompRect)); DeleteFromPics(i); //i--; continue; } } } rect.top = pPics[i].upper - (int32_t)(0.3 * (double) (pPics[i].h)); rect.left = pPics[i].left - 12* pPics [i].h; rect.bottom = pPics[i].upper + (int32_t)(1.3 * (double) (pPics[i].h)); //rect.right = pPics[i].left + pPics[i].w; rect.right = pPics[i].left; CheckAreaForComps(hCCOM, hCCOM_big, rect, pPics[i].h, &Result1, &Result2); if (Result2 > 7) { rect.top = pPics[i].upper - (int32_t)(0.3 * (double) (pPics[i].h)); rect.left = pPics[i].left - (int32_t)(1.5 * (double) (pPics[i].h)); rect.bottom = pPics[i].upper + (int32_t)(1.3 * (double) (pPics[i].h)); rect.right = pPics[i].left; CheckAreaForComps(hCCOM, hCCOM_big, rect, pPics[i].h, &tmp1, &tmp2); if (tmp2 == 0) Result2 = 0; } if ((Result1 > 3) || (Result2 > 7)) { pPics[i].type = CCOM_CH_LETTER; CompRect.upper = pPics[i].upper; CompRect.left = pPics[i].left; CompRect.h = pPics[i].h; CompRect.w = pPics[i].w; CPAGE_CreateBlock(hCPAGE, BlockType, 0, 0, &CompRect, sizeof(CompRect)); DeleteFromPics(i); //i--; continue; } rect.top = pPics[i].upper - (int32_t)(0.3 * (double) (pPics[i].h)); rect.left = pPics[i].left + pPics[i].w; rect.bottom = pPics[i].upper + (int32_t)(1.3 * (double) (pPics[i].h)); rect.right = pPics[i].left + pPics[i].w + 12* pPics [i].h; CheckAreaForComps(hCCOM, hCCOM_big, rect, pPics[i].h, &Result3, &Result4); if (Result4 > 0) { rect.top = pPics[i].upper - (int32_t)(0.3 * (double) (pPics[i].h)); rect.left = pPics[i].left + pPics[i].w; rect.bottom = pPics[i].upper + (int32_t)(1.3 * (double) (pPics[i].h)); rect.right = pPics[i].left + pPics[i].w + (int32_t)(1.5 * (double) (pPics[i].h)); CheckAreaForComps(hCCOM, hCCOM_big, rect, pPics[i].h, &tmp1, &tmp2); if (tmp2 == 0) Result4 = 0; } if ((Result3 > 3) || (Result4 > 7) || (Result1 + Result3 > 3) || (Result2 + Result4 > 7)) { pPics[i].type = CCOM_CH_LETTER; CompRect.upper = pPics[i].upper; CompRect.left = pPics[i].left; CompRect.h = pPics[i].h; CompRect.w = pPics[i].w; CPAGE_CreateBlock(hCPAGE, BlockType, 0, 0, &CompRect, sizeof(CompRect)); DeleteFromPics(i); //i--; continue; } } } return TRUE; }
Bool32 ReadRoots(Handle hCCOM) { CCOM_comp * comp = NULL; Handle pPage; PAGEINFO pInfo; uint32_t i; int max_h=50; exthCCOM = hCCOM; RootsFreeData (); nRoots = 0; pPage = CPAGE_GetHandlePage(CPAGE_GetCurrentPage( )); CPAGE_GetPageData( pPage, PT_PAGEINFO, (void*)&pInfo, sizeof(pInfo)); max_h=(max_h*(pInfo.DPIY+1))/300; nBigLetters = 0; pBigLetters = NULL; FillBigLetters(hCCOM, pPage); FillPicsInTables(hCCOM, pPage); //************************************** for(i=0;i<MaxHeightOfLetter;i++) { pBlockHystogram[i] = 0; } comp = CCOM_GetFirst(hCCOM,NULL); int h; while (comp) { h=comp->h; if((h > MinHeightOfLetter) && (h < MaxHeightOfLetter)) { nComps++; pBlockHystogram[h]++; } if(comp->scale>1) { if(comp->scale>2||h>max_h) { if(IsNotBigLetter(comp)) goto lNextComp; } } AddRoot(comp, TRUE) ; lNextComp: comp = CCOM_GetNext(comp,NULL); } //*********** Rom 08-02-99 ************* nBigLetters = 0; if(pBigLetters!=NULL) { free(pBigLetters); pBigLetters = NULL; } //************************************** return (TRUE); }
Bool32 RPIC_SearchPictures(CCOM_handle hCCOM, CCOM_handle hCCOM_big, Handle hCPAGE) { CCOM_comp * comp = NULL; CCOM_comp common; PAGEINFO pInfo; POLY_ block; uint32_t i, j; Rect16 rect; uint32_t key; uint32_t color; uint32_t tmp_comp = 0; Handle MainWindowD = NULL; MainWindowD = LDPUMA_GetWindowHandle("Изображение после разворота"); if (!MainWindowD) MainWindowD = LDPUMA_GetWindowHandle("Main"); OpenLogRes(); file_name = (char*) LDPUMA_GetFileName(NULL); //color = 23650; color = 200; key = 111; nPics = 0; if (pPics) { free(pPics); pPics = NULL; } nComps = 0; CPAGE_GetPageData(hCPAGE, PT_PAGEINFO, (void*) &pInfo, sizeof(pInfo)); for (i = 0; i < MaxHeightOfLetter; i++) { pHystogram[i] = 0; } //LDPUMA_FPuts(hFile, (char*)&pInfo.szImageName); LDPUMA_FPuts(logFile_comp, "*******************************************************\n"); LDPUMA_FPuts(logFile_comp, "new_file \n"); if ((pInfo.Angle == 90) || (pInfo.Angle == 270)) { uint32_t tmp; tmp = pInfo.Width; pInfo.Width = pInfo.Height; pInfo.Height = tmp; } //stepa_am comp = CCOM_GetFirst(hCCOM_big, NULL); while (comp) { tmp_comp++; if ((comp->h > MinHeightOfLetter) && (comp->h < MaxHeightOfLetter)) { nComps++; pHystogram[comp->h]++; } if (comp->scale < 1) goto lNextComp_big; /* if( comp->cs == 255) { comp->type = CCOM_CH_LETTER; goto lNextComp; } */ if (IsNotGoodComp(pInfo, comp)) { if (!LDPUMA_Skip(hShowAllCancelledGreat)) { rect.left = comp->left; rect.top = comp->upper; rect.right = comp->left + comp->w; rect.bottom = comp->upper + comp->h; LDPUMA_DrawRect(MainWindowD, &rect, 0, color, 4, key); } goto lNextComp_big; } if (nPics % PICS_QUANTUM == 0) { pPics = (CCOM_comp *) realloc(pPics, (size_t) ((nPics / PICS_QUANTUM + 1) * PICS_QUANTUM * sizeof(CCOM_comp))); } pPics[nPics++] = *comp; lNextComp_big: comp = CCOM_GetNext(comp, NULL); } //end stepa_am comp = CCOM_GetFirst(hCCOM, NULL); while (comp) { tmp_comp++; if ((comp->h > MinHeightOfLetter) && (comp->h < MaxHeightOfLetter)) { nComps++; pHystogram[comp->h]++; } if ( /*comp->scale < */1) goto lNextComp; /* if( comp->cs == 255) { comp->type = CCOM_CH_LETTER; goto lNextComp; } */ if (IsNotGoodComp(pInfo, comp)) { if (!LDPUMA_Skip(hShowAllCancelledGreat)) { rect.left = comp->left; rect.top = comp->upper; rect.right = comp->left + comp->w; rect.bottom = comp->upper + comp->h; LDPUMA_DrawRect(MainWindowD, &rect, 0, color, 4, key); } goto lNextComp; } if (nPics % PICS_QUANTUM == 0) { pPics = (CCOM_comp *) realloc(pPics, (size_t) ((nPics / PICS_QUANTUM + 1) * PICS_QUANTUM * sizeof(CCOM_comp))); } pPics[nPics++] = *comp; lNextComp: comp = CCOM_GetNext(comp, NULL); } if (!LDPUMA_Skip(hShowAllCancelledGreat)) { LDPUMA_Console("RPIC_Отмененные большие компоненты \n"); LDPUMA_WaitUserInput(hShowAllCancelledGreat, MainWindowD); LDPUMA_DeleteRects(MainWindowD, key); } if (!nComps) // OLEG return TRUE; // STEPA_AM if (!nPics) return TRUE; /**************************************************/ for (i = 0; i < MaxHeightOfLetter; i++) { nAverageHeight += pHystogram[i] * i; /* sprintf(tmp_str, " %i (i)\n", i); LDPUMA_FPuts(logFile,tmp_str); sprintf(tmp_str, " %i (pHystogram[i])\n", pHystogram[i]); LDPUMA_FPuts(logFile,tmp_str); */ } nAverageHeight /= nComps; sprintf(tmp_str, "Average height %i (nAverageHeight)\n", nAverageHeight); LDPUMA_FPuts(logFile_comp, tmp_str); /**************************************************/ /************** first union all crossed and included pictures ******************/ /* for (i=0; i<nPics; i++) { for (j=0; j<nPics; j++) { if ( (pPics[i].upper < pPics[j].upper)&& (pPics[i].left < pPics[j].left)&& (pPics[i].left + pPics[i].w > pPics[j].left + pPics[j].w)&& (pPics[i].upper + pPics[i].h > pPics[j].upper + pPics[j].h) ) { DeleteFromPics (j); j--; } } } for (i=0; i<nPics; i++) { for (j=0; j<nPics; j++) { if (i==j) continue; if ( (pPics[i].upper - VER_BOUND_SIZE < pPics[j].upper + pPics[j].h)&& (pPics[i].left - HOR_BOUND_SIZE < pPics[j].left + pPics[j].w)&& (pPics[i].left + pPics[i].w + HOR_BOUND_SIZE > pPics[j].left)&& (pPics[i].upper + pPics[i].h + VER_BOUND_SIZE > pPics[j].upper) ) { common = pPics[i]; if (pPics[i].upper >= pPics[j].upper) common.upper = pPics[j].upper; if (pPics[i].left >= pPics[j].left) common.left = pPics[j].left; if (pPics[i].upper + pPics[i].h < pPics[j].upper + pPics[j].h) common.h = pPics[j].upper + pPics[j].h - pPics[i].upper; if (pPics[i].left + pPics[i].w < pPics[j].left + pPics[j].w) common.w = pPics[j].left + pPics[j].w - pPics[i].left; common.h += pPics[i].upper - common.upper; common.w += pPics[i].left - common.left; pPics[i] = common; DeleteFromPics (j); j=0; i=0; } } } */ /***********************************************************************************/ color = 200; key = 111; if ((!LDPUMA_Skip(hShowAllGreat)) && nPics) { for (i = 0; i < nPics; i++) { rect.left = pPics[i].left; rect.top = pPics[i].upper; rect.right = pPics[i].left + pPics[i].w; rect.bottom = pPics[i].upper + pPics[i].h; LDPUMA_DrawRect(MainWindowD, &rect, 0, color, 2, key); } LDPUMA_Console("RPIC_Рассматриваемые большие компоненты \n"); LDPUMA_WaitUserInput(hShowAllGreat, MainWindowD); LDPUMA_DeleteRects(MainWindowD, key); } //sprintf(tmp_str, "Amount of 'letters' on the first step %i (nComps)\n", nComps); //LDPUMA_FPuts(logFile_comp,tmp_str); //sprintf(tmp_str, " <2 Н Страница = %d \n", page_count++); //LDPUMA_FPuts(resFile_comp,tmp_str); //char* str; //str = LDPUMA_GetFileName(NULL); LDPUMA_FPuts(resFile_comp, " <2 Н Страница ="); LDPUMA_FPuts(resFile_comp, file_name); LDPUMA_FPuts(resFile_comp, " \n"); //LDPUMA_FPuts(resFile_comp, " <2 Н Страница \n"); LDPUMA_FPuts(resFile_comp, " <3 Н Компоненты \n"); sprintf(tmp_str, " <4 П Перед выделением линий \n", nComps); LDPUMA_FPuts(resFile_comp, tmp_str); sprintf(tmp_str, " <4 Р %d \n", nComps); LDPUMA_FPuts(resFile_comp, tmp_str); sprintf(tmp_str, "Amount of pictures on the before first step %i (nPics)\n", nPics); LDPUMA_FPuts(logFile_comp, tmp_str); /*******************************************************************/ if (LDPUMA_Skip(hRectanglePictures)) SearchRectanglePictures(hCCOM, hCCOM_big, hCPAGE); if (LDPUMA_Skip(hPolyPictures)) SearchPolyPictures(hCCOM, hCPAGE); /*******************************************************************/ /************** final union all crossed and included pictures ******************/ for (i = 0; i < nPics; i++) { if (pPics[i].large & CCOM_LR_KILLED) { continue; } for (j = 0; j < nPics; j++) { if ((pPics[i].upper < pPics[j].upper) && (pPics[i].left < pPics[j].left) && (pPics[i].left + pPics[i].w > pPics[j].left + pPics[j].w) && (pPics[i].upper + pPics[i].h > pPics[j].upper + pPics[j].h)) { /* if((pPics[i].type!=CCOM_CH_LETTER)||(pPics[j].type!=CCOM_CH_LETTER)) { pPics[i].type = CCOM_CH_MERGE; } */ if (pPics[j].large & CCOM_LR_KILLED) { // it's bad, but will work cause pPics[].large not initialised in RPIC pPics[i].large |= CCOM_LR_TAKEN; continue; } DeleteFromPics(j); //j--; } } } for (i = 0; i < nPics; i++) { if (pPics[i].large & CCOM_LR_KILLED) { continue; } for (j = 0; j < nPics; j++) { if (pPics[j].large & CCOM_LR_KILLED) { continue; } if (i == j) continue; if ((pPics[i].upper - VER_BOUND_SIZE < pPics[j].upper + pPics[j].h) && (pPics[i].left - HOR_BOUND_SIZE < pPics[j].left + pPics[j].w) && (pPics[i].left + pPics[i].w + HOR_BOUND_SIZE > pPics[j].left) && (pPics[i].upper + pPics[i].h + VER_BOUND_SIZE > pPics[j].upper)) { common = pPics[i]; if (pPics[i].upper >= pPics[j].upper) common.upper = pPics[j].upper; if (pPics[i].left >= pPics[j].left) common.left = pPics[j].left; if (pPics[i].upper + pPics[i].h < pPics[j].upper + pPics[j].h) common.h = pPics[j].upper + pPics[j].h - pPics[i].upper; if (pPics[i].left + pPics[i].w < pPics[j].left + pPics[j].w) common.w = pPics[j].left + pPics[j].w - pPics[i].left; common.h += pPics[i].upper - common.upper; common.w += pPics[i].left - common.left; pPics[i] = common; DeleteFromPics(j); } } } LastCheck(hCCOM, hCCOM_big, hCPAGE); LDPUMA_FPuts(resFile_pict, " <2 Н Страница ="); LDPUMA_FPuts(resFile_pict, file_name); LDPUMA_FPuts(resFile_pict, " \n"); LDPUMA_FPuts(resFile_pict, " <3 Н Картинки \n"); LDPUMA_FPuts(resFile_pict, " <4 Н После первого прохода \n"); sprintf(tmp_str, " <4 Р %d %d %d \n", nPics, 0, 0); LDPUMA_FPuts(resFile_pict, tmp_str); int32_t min_image_width = (int32_t)(100 * ((double) (pInfo.DPIX + 1) / 300)); int32_t min_image_height = (int32_t)(100 * ((double) (pInfo.DPIY + 1) / 300)); for (i = 0; i < nPics; i++) { if (pPics[i].large & CCOM_LR_KILLED && !(pPics[i].large & CCOM_LR_TAKEN)) { continue; } block.com.type = TYPE_TEXT;//Текст, Картинка, Таблица; block.com.number = 0;//порядковый номер block.com.count = 4; block.com.Flags = 0; block.com.Vertex[0].rx() = pPics[i].left; block.com.Vertex[0].ry() = pPics[i].upper; block.com.Vertex[1].rx() = pPics[i].left + pPics[i].w; block.com.Vertex[1].ry() = pPics[i].upper; block.com.Vertex[2].rx() = pPics[i].left + pPics[i].w; block.com.Vertex[2].ry() = pPics[i].upper + pPics[i].h; block.com.Vertex[3].rx() = pPics[i].left; block.com.Vertex[3].ry() = pPics[i].upper + pPics[i].h; block.alphabet = 0; sprintf(tmp_str, " <4 О 1 %4d %4d %4d %4d %d \n", pPics[i].left, pPics[i].upper, pPics[i].left + pPics[i].w, pPics[i].upper, pPics[i].h); LDPUMA_FPuts(resFile_pict, tmp_str); if (pPics[i].large & CCOM_LR_TAKEN || pPics[i].w < min_image_width && pPics[i].h < min_image_height) { CPAGE_CreateBlock(hCPAGE, POSSIBLE_PICTURES, 0, 0, &block, sizeof(POLY_)); } else { CPAGE_CreateBlock(hCPAGE, TYPE_IMAGE, 0, 0, &block, sizeof(POLY_)); } } LDPUMA_FPuts(resFile_pict, " <4 К После первого прохода \n"); sprintf(tmp_str, "Amount of comps on the first step %i (tmp_comp) \n", tmp_comp); LDPUMA_FPuts(logFile_comp, tmp_str); sprintf(tmp_str, "Amount of pictures on the first step %i (nPics) \n", nPics); LDPUMA_FPuts(logFile_comp, tmp_str); LDPUMA_FPuts(logFile_comp, "*******************************************************\n"); if (pPics != NULL) { free(pPics); pPics = NULL; } nPics = 0; CloseLogRes(); Handle h = NULL; if (!LDPUMA_Skip(hShowFirstAttempt)) { h = NULL; nPics = 0; for (h = CPAGE_GetBlockFirst(hCPAGE, TYPE_IMAGE); h != NULL; h = CPAGE_GetBlockNext(hCPAGE, h, TYPE_IMAGE)) { nPics++; CPAGE_GetBlockData(hCPAGE, h, TYPE_IMAGE, &block, sizeof(block)); rect.left = block.com.Vertex[0].x(); rect.top = block.com.Vertex[0].y(); rect.right = block.com.Vertex[1].x(); rect.bottom = block.com.Vertex[2].y(); LDPUMA_DrawRect(MainWindowD, &rect, 0, color, 2, key); } if (nPics) { LDPUMA_Console("RPIC_Картинки после первого прохода \n"); LDPUMA_WaitUserInput(hShowFirstAttempt, MainWindowD); LDPUMA_DeleteRects(MainWindowD, key); } } if (!LDPUMA_Skip(hShowPossiblePics)) { h = NULL; nPics = 0; for (h = CPAGE_GetBlockFirst(hCPAGE, POSSIBLE_PICTURES); h != NULL; h = CPAGE_GetBlockNext(hCPAGE, h, POSSIBLE_PICTURES)) { nPics++; CPAGE_GetBlockData(hCPAGE, h, POSSIBLE_PICTURES, &block, sizeof(block)); rect.left = block.com.Vertex[0].x(); rect.top = block.com.Vertex[0].y(); rect.right = block.com.Vertex[1].x(); rect.bottom = block.com.Vertex[2].y(); LDPUMA_DrawRect(MainWindowD, &rect, 0, color, 2, key); } if (nPics) { LDPUMA_Console("RPIC_Неуверенные картинки после первого прохода \n"); LDPUMA_WaitUserInput(hShowPossiblePics, MainWindowD); LDPUMA_DeleteRects(MainWindowD, key); } } Handle BlockType = CPAGE_GetInternalType("pic's to letters boxes"); RPIC_Comp_Rect CompRect; if (!LDPUMA_Skip(hShowBigLetters)) { h = NULL; nPics = 0; for (h = CPAGE_GetBlockFirst(hCPAGE, BlockType); h != NULL; h = CPAGE_GetBlockNext(hCPAGE, h, BlockType)) { nPics++; CPAGE_GetBlockData(hCPAGE, h, BlockType, &CompRect, sizeof(CompRect)); rect.left = CompRect.left; rect.top = CompRect.upper; rect.right = CompRect.left + CompRect.w - 1; rect.bottom = CompRect.upper + CompRect.h - 1; LDPUMA_DrawRect(MainWindowD, &rect, 0, color, 2, key); } if (nPics) { LDPUMA_Console("RPIC_Буквицы \n"); LDPUMA_WaitUserInput(hShowBigLetters, MainWindowD); LDPUMA_DeleteRects(MainWindowD, key); } } return TRUE; }
Bool32 LastCheck(CCOM_handle hCCOM, CCOM_handle hCCOM_big, Handle hCPAGE) { uint32_t i, j; CCOM_comp pic; CCOM_comp * comp; uint16_t pLocalHystogram[MaxHeightOfLetter]; uint32_t nLocalComps; uint32_t MaxLocal, nMaxLocal; uint32_t Result1, Result2; for (i = 0; i < nPics; i++) { if (pPics[i].large & CCOM_LR_KILLED) { continue; } pic = pPics[i]; //Rom if (pPics[i].h < 32 || pPics[i].w < 32) { DeleteFromPics(i); //i--; continue; } /* Filling "my_*" for function MyFiltrateIn */ my_upper = pic.upper; my_left = pic.left; my_bottom = pic.upper + pic.h; my_right = pic.left + pic.w; //Additional parameter - local distribution of heights //in case of local fragment with different (from main) height nLocalComps = 0; for (j = 0; j < MaxHeightOfLetter; j++) { pLocalHystogram[j] = 0; } /* Filling the hystogram of local letter's heights */ //stepa_am comp = CCOM_GetFirst(hCCOM_big, &MyFiltrateIn); while (comp) { if ((comp->h < MaxHeightOfLetter) && (comp->h > MinHeightOfLetter)) { pLocalHystogram[comp->h]++; nLocalComps++; } comp = CCOM_GetNext(comp, &MyFiltrateIn); } //end stepa_am comp = CCOM_GetFirst(hCCOM, &MyFiltrateIn); while (comp) { if ((comp->h < MaxHeightOfLetter) && (comp->h > MinHeightOfLetter)) { pLocalHystogram[comp->h]++; nLocalComps++; } comp = CCOM_GetNext(comp, &MyFiltrateIn); } /* if there is comonents in the picture, check picture for containing text blocks, if result is sucsessful, delete it from pictures */ if (nLocalComps != 0) { MaxLocal = pLocalHystogram[0]; for (j = 0; j < MaxHeightOfLetter; j++) { if (pLocalHystogram[j] > MaxLocal) { MaxLocal = pLocalHystogram[j]; nMaxLocal = j; } } Result1 = 0; Result2 = 0; //stepa_am comp = CCOM_GetFirst(hCCOM_big, &MyFiltrateIn); while (comp) { if ((comp->h < MaxHeightOfLetter - 1) && (comp->h > MinHeightOfLetter)) { Result1 += pHystogram[comp->h] / 20 + pHystogram[comp->h - 1] / 20 + pHystogram[comp->h + 1] / 20; if (comp->h - nMaxLocal < DIFFERENCE1) { Result2 += pLocalHystogram[comp->h] + pLocalHystogram[comp->h - 1] + pLocalHystogram[comp->h + 1]; } } comp = CCOM_GetNext(comp, &MyFiltrateIn); } //end stepa_am comp = CCOM_GetFirst(hCCOM, &MyFiltrateIn); while (comp) { if ((comp->h < MaxHeightOfLetter - 1) && (comp->h > MinHeightOfLetter)) { Result1 += pHystogram[comp->h] / 20 + pHystogram[comp->h - 1] / 20 + pHystogram[comp->h + 1] / 20; if (comp->h - nMaxLocal < DIFFERENCE1) { Result2 += pLocalHystogram[comp->h] + pLocalHystogram[comp->h - 1] + pLocalHystogram[comp->h + 1]; } } comp = CCOM_GetNext(comp, &MyFiltrateIn); } Result1 = Result1 / 10; Result2 = Result2 / 20; if (Result1 + Result2 > 2* CONDITION1 ) { DeleteFromPics(i); //i--; continue; } } } return TRUE; }
void NegRecog(Handle hCPage,NegList** proot,int& nRC,int skew) { uint32_t code_recd=512<<19; uint32_t code_resd=(512<<19)+(512<<16); CCOM_handle hNegCCOM; CCOM_comp * pcomp; Rect16* pN; Rect16* pRc; int i,j,r; int medium_w; int nN=0; int len_neg_mas=100; int add_len_mas=50; Bool vertical; char Alf[256]; Bool nomem=FALSE; NegList* root=(*proot); NegList* now=root; NegList* temp; uchar Prob[3]; double neg_str_control; int len_result; double prec; double prob0[2], prob1[2]; for(i=1;i<nRC;i++) now=now->next; NegSetAlf(Alf); while(now) { if((now->neg).rot.pmasp) { if((now->neg).nRc>10) { delete[] (now->neg).rot.hi; (now->neg).rot.hi= new int[(now->neg).nRc]; } RSELSTR_UnRotateRect(-skew,(now->neg).pRc,(now->neg).nRc,(now->neg).rot.Rc,(now->neg).rot.begx,(now->neg).rot.movey,(now->neg).rot.flmovey,(now->neg).rot.hi); } pRc=(now->neg).pRc; vertical=FALSE; if(!((pRc[(now->neg).nRc-1].bottom-pRc[0].top)*2<(pRc[0].right-pRc[0].left))) { vertical=TRUE; } for(i=(now->neg).nRc-1;i>=0;i--) { nomem=FALSE; len_neg_mas=100; nN=0; hNegCCOM=0; hNegCCOM=GetNegCCOM(hCPage,pRc,i); if(!hNegCCOM) continue; if(i<MAX_STR) now->neg.hCCOM[i]=hNegCCOM; pcomp = CCOM_GetFirst (hNegCCOM, NULL); if(pcomp==NULL) { NegMoveMas((now->neg).pRc,(now->neg).nRc,i); NegMoveMas(now->neg.hCCOM,now->neg.nRc,i); if(i==0) { (now->neg).p_rec/=(double)((now->neg).nRc); (now->neg).p_str/=(double)((now->neg).nRc); (now->neg).p=((now->neg).p_rec+(now->neg).p_str)/2.; if(dpPrintResConsole) { LDPUMA_ConsoleN(""); LDPUMA_Console("Ќегатив с веро¤тностью :"); LDPUMA_ConsoleN(""); LDPUMA_Console("по внутренней структуре "); NegPrintConsol((now->neg).p_str); LDPUMA_Console("по результатам распозновани¤ "); NegPrintConsol((now->neg).p_rec); LDPUMA_Console("итого "); NegPrintConsol((now->neg).p); LDPUMA_ConsoleN("площадь=%d",(int)((now->neg).pRc[0].right-(now->neg).pRc[0].left+1)*(int)((now->neg).pRc[0].bottom-(now->neg).pRc[(now->neg).nRc-1].top+1)); } if(dpNegResD ) { Rect16 Rect; Rect.bottom=(now->neg).pRc[0].bottom; Rect.left=(now->neg).pRc[0].left; Rect.right=(now->neg).pRc[0].right+1; Rect.top=(now->neg).pRc[(now->neg).nRc-1].top-1; LDPUMA_DrawRect (MainWindowD, &(Rect),0,RGB(0,0,255), 1,code_resd ); LDPUMA_WaitUserInput (NegResD,MainWindowD); LDPUMA_DeleteRects (MainWindowD,code_resd); } } } if(pcomp==NULL) continue; if(!(InitNegMas(&pN,len_neg_mas))) continue; InitRc(pN,nN,pcomp); nN++; for(;;) { pcomp = CCOM_GetNext (pcomp, NULL); if (pcomp==NULL) break; if (nN>=len_neg_mas) { AddLenNegMas(&pN,len_neg_mas,add_len_mas); } InitRc(pN,nN,pcomp); nN++; } if(i>=MAX_STR) CCOM_DeleteContainer(hNegCCOM); if((now->neg).rot.pmasp) { RSELSTR_CleanStr(pN,NULL,nN,pRc[i].top,pRc[i].left,(now->neg).rot.hi[i],pRc[i].right-pRc[i].left+1,skew,FALSE); } if(!nN) DelNegMas(&pN); if(!nN) continue; /*ѕрорисовка компонент в негативе*/ if(nN>0) { if(dpNegRecD) { for(j=0;j<nN;j++) NegDrawRect(MainWindowD,code_recd,RGB(0,0,255),pN[j]); LDPUMA_WaitUserInput (NegRecD,MainWindowD); if(LDPUMA_Skip (NegRecDC) ) LDPUMA_DeleteRects (MainWindowD,code_recd); } } SortLetter(pN,nN,vertical); neg_str_control=NegStrControl(pN,nN,vertical,&(now->neg.pRc[i])); (now->neg).p_str+=neg_str_control; RecVersions* vs; UniVersions* uvs; if(!(InitNegMas(&vs,nN))) { nomem=TRUE; DelNegMas(&pN); } if(nomem==TRUE) continue; if(!(InitNegMas(&uvs,nN))) { nomem=TRUE; DelNegMas(&pN); DelNegMas(vs); } if(nomem==TRUE) continue; RecRaster rec; int16_t Language; int turn; if(neg_str_control/2.>inf_prob-.5) { if( !(CCOM_GetLanguage(hNegCCOM, &Language)) ) Language=7; for(j=0; j<2; j++) { prob0[j] = 0; prob1[j] = 0; } Bool32 ShowNegByOne = !LDPUMA_Skip(hShowNegComps); Handle comp_window = NULL; for(j=0;j<nN;j++) { if( NegGetRaster(hCPage,pN[j],&rec,vertical) ) { if(!dpRecOneLetter) { // if (vertical) TurnOverNeg(&rec); for(turn=0; turn<2; turn++) { //----------------------------------------------------------- if (ShowNegByOne/* && vertical*/) { BITMAPINFOHEADER lpBI; // Pointer to DIB info structure RGBQUAD Palette1; RGBQUAD Palette2; uint32_t bfSize, dwDIBSize; HANDLE hDIB; uchar* pDIB; uchar* pTmpDIB; uchar* pTmpBuffer; uint16_t Height, Width, ByteWidth; CIMAGEBITMAPINFOHEADER image_info = {0}; Height = (uint16_t)rec.lnPixHeight; Width = (uint16_t)rec.lnPixWidth; ByteWidth = (Width+7)/8; dwDIBSize = 64 * Height; bfSize = dwDIBSize + sizeof(BITMAPINFOHEADER) + 2*sizeof(RGBQUAD); ///////////////// Bitmap information header ////////////////////////////////// lpBI.biSize = sizeof(BITMAPINFOHEADER); lpBI.biWidth = 64; lpBI.biHeight = Height; lpBI.biPlanes = 0x1; lpBI.biBitCount = 0x1; lpBI.biCompression = 0; lpBI.biSizeImage = dwDIBSize; CIMAGE_GetImageInfo((puchar)PUMA_IMAGE_USER, &image_info); lpBI.biXPelsPerMeter = image_info.biXPelsPerMeter; lpBI.biYPelsPerMeter = image_info.biYPelsPerMeter; lpBI.biClrUsed = 0; lpBI.biClrImportant = 0; /////////////// Palette /////////////////////////////////////////////////////////// Palette1.rgbBlue = 0xFF; Palette1.rgbGreen = 0xFF; Palette1.rgbRed = 0xFF; Palette1.rgbReserved = 0; Palette2.rgbBlue = 0; Palette2.rgbGreen = 0; Palette2.rgbRed = 0; Palette2.rgbReserved = 0; hDIB = calloc(1, bfSize); if (hDIB != 0) { pDIB = static_cast<uchar*> (hDIB); pTmpDIB = pDIB; ///////// filling Dib /////////////////////////////////////////////////////////// memcpy(pTmpDIB, &lpBI, sizeof(BITMAPINFOHEADER)); pTmpDIB += sizeof(BITMAPINFOHEADER); memcpy(pTmpDIB, &Palette1, sizeof(RGBQUAD)); pTmpDIB += sizeof(RGBQUAD); memcpy(pTmpDIB, &Palette2, sizeof(RGBQUAD)); pTmpDIB += sizeof(RGBQUAD); pTmpBuffer = rec.Raster; uchar* pTempDib = pTmpDIB; for(int i=0; i<Height; i++ ) { memcpy(pTmpDIB, pTmpBuffer, 8); pTmpDIB += 8; pTmpBuffer += 8; } TurnOverNeg(rec, pTempDib); const char *pText; pText = turn ? "Component up-down" : "Component down-up"; comp_window = LDPUMA_CreateWindow(pText, pDIB); // LDPUMA_WaitUserInput(hShowNegComps, comp_window); free(hDIB); } } //---------------------------------------------------------------------- if( !(RSTR_RecogOneLetter_all (&rec,Alf, &(vs[j]),(int32_t)(1)) ) ) Prob[1]=0; else { if (!turn) Prob[1]=vs[j].Alt[0].Prob; prob1[turn] += NegRecControl((int)vs[j].Alt[0].Prob); if (ShowNegByOne) LDPUMA_ConsoleN("handprint symbol: %c , probability = %d", (char)vs[j].Alt[0].Code, vs[j].Alt[0].Prob); } // if( !(RSTR_RecogOneLetter_all (&rec,Alf, &(vs[j]),(int32_t)(2)) ) ) // Prob[2]=0; // else // Prob[2]=vs[j].Alt[0].Prob; if( !(RSTR_RecogOneLetter_all (&rec,Alf, &(vs[j]),(int32_t)(0)) ) ) Prob[0]=0; else { if (!turn) Prob[0]=vs[j].Alt[0].Prob; prob0[turn] += NegRecControl((int)vs[j].Alt[0].Prob); if (ShowNegByOne) LDPUMA_ConsoleN("print symbol: %c , probability = %d", (char)vs[j].Alt[0].Code, vs[j].Alt[0].Prob); } if (ShowNegByOne) LDPUMA_WaitUserInput(hShowNegComps, comp_window); if (!vertical) break; if (!turn) TurnRaster(&rec); } vs[j].Alt[0].Prob=(uchar)( ((int)(Prob[0])+(int)(Prob[1])/*+(int)(Prob[2])*/)/2/*3*/); /*else { vs[j].lnAltMax =uvs[j].lnAltMax; vs[j].lnAltCnt=uvs[j].lnAltCnt; for(int alt=0;alt<uvs[j].lnAltCnt;alt++) { vs[j].Alt[alt].Code=uvs[j].Alt[alt].Code[0]; vs[j].Alt[alt].Prob=uvs[j].Alt[alt].Prob; } }*/ } else { if( !(RSTR_RecogOneLetter (&rec, (uchar)(Language), &(vs[j])) ) ) vs[j].Alt[0].Prob=0; } } else vs[j].Alt[0].Prob=0; } } if(vertical) ToHoriz(pN,nN); medium_w=GetMediumW(pN,nN); int medium_h=GetMediumH(pN,nN); uchar* result=NULL; if(!(result=new uchar[nN*2])) { nomem=TRUE; DelNegMas(&pN); DelNegMas(vs); DelNegMas(uvs); } if(nomem==TRUE) continue; len_result=0; NegPutLetter(result,len_result,vs[0].Alt[0],FALSE); if(neg_str_control/2.>inf_prob-.5) { prec=NegRecControl(vs[0].Alt[0].Prob); for(j=1;j<nN;j++) { prec+=NegRecControl(vs[j].Alt[0].Prob); /* if( (pN[j].left-pN[j-1].right)>(medium_w/2)*3+2) { NegPutLetter(result,len_result,vs[j].Alt[0],TRUE); if( (pN[j].right-pN[j].left+1>(pN[j].bottom-pN[j].top+1)*2) && (pN[j].bottom-pN[j].top+1<medium_h/2) ) result[len_result-1]='-'; if( (pN[j].top<pN[j-1].top) && (pN[j].bottom-pN[j].top+1<medium_h/2) ) { len_result--; if( IfExistI(vs[j-1]) ) result[len_result-1]=256+'…'; } if((pN[j].bottom-pN[j].top+1<(medium_h/3)*2)&&( (result[len_result-1]=='I')||(result[len_result-1]=='|')||((result[len_result-1]=='?') && (IfExistDef(vs[j]))) ) ) result[len_result-1]=','; } else { NegPutLetter(result,len_result,vs[j].Alt[0],FALSE); if( (pN[j].right-pN[j].left+1>(pN[j].bottom-pN[j].top+1)*2) && (pN[j].bottom-pN[j].top+1<medium_h/2) ) result[len_result-1]='-'; if( (pN[j].top<pN[j-1].top) && (pN[j].bottom-pN[j].top+1<medium_h/2) ) { len_result--; if( IfExistI(vs[j-1]) ) result[len_result-1]=256+'…'; } if((pN[j].bottom-pN[j].top+1<(medium_h/3)*2)&&( (result[len_result-1]=='I')||(result[len_result-1]=='|')||((result[len_result-1]=='?') && (IfExistDef(vs[j]))) ) ) result[len_result-1]=','; }*/ } r=1; (now->neg).p_rec+=prec/(double)(nN); } /* for(j=1;j<nN;j++) { if(result[r]!='?') { if(result[r]!=' ') { if(result[r]=='|') result[r]='I'; if(Language==7) { if( ((result[r-1]==256+'ь')||(result[r-1]==256+'№'))&&((result[r]=='I' )||(result[r]=='i')||(result[r]=='1')||(result[r]=='l')) ) { if(result[r-1]==256+'ь') result[r-1]=256+'ы'; else result[r-1]=256+'џ'; NegMoveResult(result,len_result,r); r--; } if( (result[r-1]!=' ')&&(result[r-1]!='?')&&(!(IfGl(result[r-1])))&&(result[r]==256+'ƒ') ) { if(IfExistA(vs[j])) { if(j<nN-1) { if(!(IfGl(result[r+1]))) result[r]=256+'ј'; } else result[r]=256+'ј'; } } } if( (pN[j].right-pN[j].left+1>pN[j].bottom-pN[j].top+1) && (result[r]=='I') ) result[r]='-'; r++; } else { j--; r++; } } else r++; } */ //Andrey (now->neg).Flags = 0; if (vertical) { if(dpPrintResConsole) { LDPUMA_Console("\n down-up print:"); NegPrintConsol((double)prob0[0]/nN); LDPUMA_Console("down-up handprint:"); NegPrintConsol((double)prob1[0]/nN); LDPUMA_Console("up-down print:"); NegPrintConsol((double)prob0[1]/nN); LDPUMA_Console("up-down handprint:"); NegPrintConsol((double)prob1[1]/nN); } double down_up = (prob0[0]+prob1[0])/2; double up_down = (prob0[1]+prob1[1])/2; (now->neg).Flags |= FlVert; if (down_up > up_down) (now->neg).Flags |= FlDown2Up; } if(i==(now->neg).nRc-1) { if(dpPrintResConsole) NegPrintConsol(pRc[0].left,pRc[(now->neg).nRc-1].top,pRc[0].right,pRc[0].bottom); } if(dpPrintResConsole) NegPrintConsol(result,len_result); if(i==0) { (now->neg).p_rec/=(double)((now->neg).nRc); (now->neg).p_str/=(double)((now->neg).nRc); (now->neg).p=((now->neg).p_rec+(now->neg).p_str)/2.; if(dpPrintResConsole) { LDPUMA_ConsoleN(""); LDPUMA_Console("Ќегатив с веро¤тностью :"); LDPUMA_ConsoleN(""); LDPUMA_Console("по внутренней структуре "); NegPrintConsol((now->neg).p_str); LDPUMA_Console("по результатам распозновани¤ "); NegPrintConsol((now->neg).p_rec); LDPUMA_Console("итого "); NegPrintConsol((now->neg).p); LDPUMA_ConsoleN("площадь=%d",(int)((now->neg).pRc[0].right-(now->neg).pRc[0].left+1)*(int)((now->neg).pRc[0].bottom-(now->neg).pRc[(now->neg).nRc-1].top+1)); } } if(i==0) { if(dpNegResD) { Rect16 Rect; Rect.bottom=(now->neg).pRc[0].bottom; Rect.left=(now->neg).pRc[0].left; Rect.right=(now->neg).pRc[0].right+1; Rect.top=(now->neg).pRc[(now->neg).nRc-1].top-1; LDPUMA_DrawRect (MainWindowD, &(Rect),0,RGB(0,0,255), 1,code_resd ); LDPUMA_WaitUserInput (NegResD,MainWindowD); LDPUMA_DeleteRects (MainWindowD,code_resd); } } DelNegMas(vs); DelNegMas(uvs); delete[] result; DelNegMas(&pN); } // if((now->neg).rot.pmasp) // DeleteRotateMas(&((now->neg).rot.pmasp),&((now->neg).rot.begx),&((now->neg).rot.movey),&((now->neg).rot.flmovey),&((now->neg).rot.hi)); if(!(now->neg).nRc) { temp=now; if(!temp->prev) root=temp->next; now=now->prev; delete temp; nRC--; } else now=now->prev; } (*proot)=root; }
void checkResolution(Handle hCCOM, Handle hCPAGE) { PAGEINFO page_info = {0}; const int min_res = 99; CCOM_comp* pcomp=NULL; unsigned int Masy[100], Masx[100], i, Jy_m = 0, My_m = 0, Jx_m = 0, Mx_m = 0, M_t; bool flag_set = false; if (!GetPageInfo(hCPAGE, &page_info)) return; if (page_info.DPIX > min_res && page_info.DPIY > min_res) return; for (i=0; i<100; i++) Masx[i] = Masy[i] = 0; pcomp = CCOM_GetFirst(hCCOM, NULL); while (pcomp) { if (pcomp->h > 9 && pcomp->h < 100) Masy[pcomp->h]++; if (pcomp->w > 9 && pcomp->w < 100) Masx[pcomp->w]++; pcomp = CCOM_GetNext(pcomp, NULL); } for (i=11; i < 99; i++) { M_t = Masy[i-1] + Masy[i] + Masy[i+1]; if (M_t > My_m) { Jy_m = i; My_m = M_t; } M_t = Masx[i-1] + Masx[i] + Masx[i+1]; if (M_t > Mx_m) { Jx_m = i; Mx_m = M_t; } } if (Jy_m > 10 && My_m > 100 && !(page_info.DPIY*22 < 2*300*Jy_m && 2*page_info.DPIY*22 > 300*Jy_m)) { page_info.DPIY = (300*Jy_m+11)/22; flag_set = true; } if (Jx_m > 10 && Mx_m > 100 && !(page_info.DPIX*22 < 2*300*Jx_m && 2*page_info.DPIX*22 > 300*Jx_m)) { page_info.DPIX = (300*Jx_m+11)/22; flag_set = true; } if (flag_set) { SetPageInfo(hCPAGE, page_info); if (!LDPUMA_Skip(hDebugPrintResolution)) LDPUMA_ConsoleN("новое разрешение: DPIX=%d, DPIY=%d", page_info.DPIX, page_info.DPIY); } }
Bool32 CheckAreaForComps(CCOM_handle hCCOM, CCOM_handle hCCOM_big, Rect32 rect, int32_t Height, uint32_t *Result1, uint32_t *Result2) { CCOM_comp * comp; uint32_t i; comp = NULL; Rect16 rect1; uint32_t key = 111; uint32_t color = 23000; Handle MainWindowD = NULL; MainWindowD = LDPUMA_GetWindowHandle("Изображение после разворота"); if (!MainWindowD) MainWindowD = LDPUMA_GetWindowHandle("Main"); *Result1 = 0; *Result2 = 0; if (!LDPUMA_Skip(hShowCheckLetters)) { rect1.top = (uint16_t) rect.top; rect1.left = (uint16_t) rect.left; rect1.bottom = (uint16_t) rect.bottom; rect1.right = (uint16_t) rect.right; LDPUMA_DrawRect(MainWindowD, &rect1, 0, 23635, 4, key); } //stepa_am comp = CCOM_GetFirst(hCCOM_big, NULL); while (comp) { if (comp->h < Height / 6) goto lNextComp_big; if (comp->h > Height * 1.5) goto lNextComp_big; if (comp->upper < rect.top) goto lNextComp_big; if (comp->left < rect.left) goto lNextComp_big; if (comp->upper + comp->h > rect.bottom) goto lNextComp_big; if (comp->left + comp->w > rect.right) goto lNextComp_big; if ((comp->h < Height / 3) && (comp->upper < rect.top)) goto lNextComp_big; for (i = 0; i < nPics; i++) { if ((comp->upper >= pPics[i].upper) && (comp->left >= pPics[i].left) && (comp->upper + comp->h < pPics[i].upper + pPics[i].h) && (comp->left + comp->w <= pPics[i].left + pPics[i].w)) { goto lNextComp_big; } } if ((comp->h > Height * 0.5) && (comp->h < Height * 1.5)) { (*Result1)++; if (!LDPUMA_Skip(hShowCheckLetters)) { rect1.left = comp->left; rect1.top = comp->upper; rect1.right = comp->left + comp->w; rect1.bottom = comp->upper + comp->h; LDPUMA_DrawRect(MainWindowD, &rect1, 0, color, 8, key); } goto lNextComp_big; } if ((comp->h > Height / 3 * 0.5) && (comp->h < Height / 3* 1.5 )) { (*Result2)++; if (!LDPUMA_Skip(hShowCheckLetters)) { rect1.left = comp->left; rect1.top = comp->upper; rect1.right = comp->left + comp->w; rect1.bottom = comp->upper + comp->h; LDPUMA_DrawRect(MainWindowD, &rect1, 0, color, 2, key); } goto lNextComp_big; } lNextComp_big: comp = CCOM_GetNext(comp, NULL); } //end stepa_am comp = CCOM_GetFirst(hCCOM, NULL); while (comp) { if (comp->h < Height / 6) goto lNextComp; if (comp->h > Height * 1.5) goto lNextComp; if (comp->upper < rect.top) goto lNextComp; if (comp->left < rect.left) goto lNextComp; if (comp->upper + comp->h > rect.bottom) goto lNextComp; if (comp->left + comp->w > rect.right) goto lNextComp; if ((comp->h < Height / 3) && (comp->upper < rect.top)) goto lNextComp; for (i = 0; i < nPics; i++) { if ((comp->upper >= pPics[i].upper) && (comp->left >= pPics[i].left) && (comp->upper + comp->h < pPics[i].upper + pPics[i].h) && (comp->left + comp->w <= pPics[i].left + pPics[i].w)) { goto lNextComp; } } if ((comp->h > Height * 0.5) && (comp->h < Height * 1.5)) { (*Result1)++; if (!LDPUMA_Skip(hShowCheckLetters)) { rect1.left = comp->left; rect1.top = comp->upper; rect1.right = comp->left + comp->w; rect1.bottom = comp->upper + comp->h; LDPUMA_DrawRect(MainWindowD, &rect1, 0, color, 8, key); } goto lNextComp; } if ((comp->h > Height / 3* 0.5 )&&(comp->h < Height/3*1.5)) { (*Result2)++; if(!LDPUMA_Skip(hShowCheckLetters)) { rect1.left = comp->left; rect1.top = comp->upper; rect1.right = comp->left + comp->w; rect1.bottom = comp->upper + comp->h; LDPUMA_DrawRect(MainWindowD, &rect1, 0, color, 2, key); } goto lNextComp; } lNextComp: comp = CCOM_GetNext(comp,NULL); } if(!LDPUMA_Skip(hShowCheckLetters)) { LDPUMA_Console("RPIC_Анализ на заголовки \n"); LDPUMA_WaitUserInput(hShowCheckLetters, MainWindowD); LDPUMA_DeleteRects(MainWindowD, key); } return TRUE; }
int CutStrings(POLY_* pBlock) { medium_h = GetMediumHeight(pBlock); int cut_h = (int) ((double) (medium_h) * k_cut); CCOM_comp * comp; CCOM_comp* prev_comp = NULL; PAGEINFO info; GetPageInfo(HCPAGE, &info); int nIncline = info.Incline2048; cf::Point16 pLeftTop; cf::Point16 pRightTop; cf::Point16 pLeftBottom; cf::Point16 pRightBottom; Bool fl_cont = FALSE; comp = CCOM_GetFirst((CCOM_handle) HCCOM, NULL); prev_comp = comp; //Andrey: устанавливаем переменные для метода определения точек разрезания, перемещенного в RCUTP if (!RCUTP_RSelStr_SetEnv(/*(char*)info.szImageName, */medium_h, inf_let_w, inf_dust_h, inf_let_h, HCCOM, sup_dust_w, min_cut_down_let_w, sup_prob_w, info.BitPerPixel)) return 0; while (comp) { fl_cont = FALSE; if (comp->h < inf_let_h) { prev_comp = comp; comp = CCOM_GetNext(comp, NULL); fl_cont = TRUE; } if (fl_cont) continue; pLeftTop.rx() = comp->left; pLeftTop.ry() = comp->upper - 1; pRightTop.rx() = comp->left + comp->w - 1; pRightTop.ry() = comp->upper - 1; pLeftBottom.rx() = comp->left; pLeftBottom.ry() = comp->upper + comp->h - 2; pRightBottom.rx() = comp->left + comp->w - 1; pRightBottom.ry() = comp->upper + comp->h - 2; IDEAL_XY(pLeftTop.rx(), pLeftTop.ry()); IDEAL_XY(pRightTop.rx(), pRightTop.ry()); IDEAL_XY(pLeftBottom.rx(), pLeftBottom.ry()); IDEAL_XY(pRightBottom.rx(), pRightBottom.ry()); if (IsInPoly(pLeftTop, pBlock) || IsInPoly(pRightTop, pBlock) || IsInPoly(pLeftBottom, pBlock) || IsInPoly(pRightBottom, pBlock)) { if (comp->h >= cut_h && comp->h <= medium_h * 5 && comp->w >= inf_let_w - 1) { uchar Data[1000]; memset(Data, 0, sizeof(Data)); uchar* pmasp = Data; Rect16 Rc; Rc.top = comp->upper; Rc.bottom = comp->upper + comp->h - 1; Rc.left = comp->left; Rc.right = comp->left + comp->w - 1; int bound = GetMasP(HCPAGE, Rc, &pmasp) ? RCUTP_RSelStr_CP( comp, &type_let, pmasp) : comp->h / medium_h; if (bound > 0) { if (CutComp(HCPAGE, (CCOM_handle) HCCOM, comp, bound, 1)) { comp = prev_comp; fl_cont = TRUE; } } if (!fl_cont) comp = CCOM_GetNext(comp, NULL); } else comp = CCOM_GetNext(comp, NULL); } else comp = CCOM_GetNext(comp, NULL); } //Andrey: снятие действия установки переменных в RCUTP RCUTP_RSelStr_UnsetEnv(); return 1; }
Bool CutComp(Handle hCPAGE, CCOM_handle hCCOM, CCOM_comp* comp, int bound, Bool fl_cut) { RecRaster rast; int ii; if (!CCOM_GetRaster(comp, &rast)) return FALSE; RecRaster rast2; for (ii = REC_MAX_RASTER_SIZE - 1; ii; ii--) rast2.Raster[ii] = 0; int rast_bound = (bound - comp->upper + 1) >> (comp->scale); int nowbyte = 0; int j = rast.lnPixHeight * 8 * ((rast.lnPixWidth + 63) / 64); Rect16 rect1; Rect16 rect2; CCOM_comp* comp1; CCOM_comp* comp2; uchar* lp = NULL; // uchar* old; // int16_t lp_size; // int16_t numcomp; for (ii = rast_bound * 8 * ((rast.lnPixWidth + 63) / 64); ii < j; ii++) { rast2.Raster[nowbyte] = rast.Raster[ii]; rast.Raster[ii] = 0; nowbyte++; } rast2.lnPixHeight = rast.lnPixHeight - rast_bound; rast2.lnPixWidth = rast.lnPixWidth; rast2.lnRasterBufSize = REC_MAX_RASTER_SIZE; rast.lnPixHeight = rast_bound; rect1.top = comp->upper; rect1.bottom = bound; rect1.left = comp->left; rect1.right = rect1.left + comp->w - 1; rect2.top = bound + 1; rect2.bottom = comp->upper + comp->h - 1; rect2.left = comp->left; rect2.right = comp->left + comp->w - 1; // CleanRaster(&rast,&rect1,comp->scale); // CleanRaster(&rast2,&rect2,comp->scale); comp1 = CCOM_New(hCCOM, rect1.top, rect1.left, rect1.right - rect1.left + 1, rect1.bottom - rect1.top + 1); if (!comp1) return FALSE; comp2 = CCOM_New(hCCOM, rect2.top, rect2.left, rect2.right - rect2.left + 1, rect2.bottom - rect2.top + 1); if (!comp2) { CCOM_Delete(hCCOM, comp1); return FALSE; } comp1->scale = comp2->scale = comp->scale; while (comp1->scale) { if (!Increase2(&rast, comp1)) break; } while (comp2->scale) { if (!Increase2(&rast2, comp2)) break; } CCOM_Delete(hCCOM, comp1); CCOM_Delete(hCCOM, comp2); CCOM_cont * hCutCCOM1 = 0; CCOM_handle hCutCCOM2 = 0; Rect16 Rc; Rc.left = comp->left; Rc.right = comp->left + comp->w - 1; Rc.top = comp->upper; Rc.bottom = bound; int min_h_1 = inf_let_h; int min_h_2 = inf_let_h; if (type_let == 1) min_h_1 = inf_dust_h; if (type_let == 2) min_h_2 = inf_dust_h; hCutCCOM1 = GetStrCCOM(hCPAGE, NULL, Rc, FALSE, FALSE, &rast, min_h_1); if (!hCutCCOM1) return FALSE; Rc.left = comp->left; Rc.right = comp->left + comp->w - 1; Rc.top = bound + 1; Rc.bottom = comp->upper + comp->h - 1; hCutCCOM2 = GetStrCCOM(hCPAGE, NULL, Rc, FALSE, FALSE, &rast2, min_h_2); if (!hCutCCOM2) { CCOM_DeleteContainer(hCutCCOM1); return FALSE; } comp1 = CCOM_GetFirst(hCutCCOM1, NULL); if (comp1 == NULL) { CCOM_DeleteContainer(hCutCCOM1); CCOM_DeleteContainer(hCutCCOM2); return FALSE; } CCOM_comp* newcomp; CCOM_comp* prev_comp = comp1; while (comp1) { newcomp = CCOM_New(hCCOM, comp1->upper + comp->upper - 1, comp1->left + comp->left, comp1->w, comp1->h); if (newcomp) { CCOM_Copy(newcomp, comp1); MyCreateComp(newcomp); } prev_comp = comp1; comp1 = CCOM_GetNext(comp1, NULL); } comp1 = prev_comp; comp2 = CCOM_GetFirst(hCutCCOM2, NULL); if (comp2) prev_comp = comp2; else prev_comp = comp1; while (comp2) { newcomp = CCOM_New(hCCOM, comp2->upper + bound, comp2->left + comp->left, comp2->w, comp2->h); if (newcomp) { CCOM_Copy(newcomp, comp2); MyCreateComp(newcomp); } prev_comp = comp2; comp2 = CCOM_GetNext(comp2, NULL); } comp2 = prev_comp; comp1->upper += comp->upper - 1; comp1->left += comp->left; if (comp2 != comp1) { comp2->upper += bound; comp2->left += comp->left; } FILE* f = NULL; if (fl_cut == 0) f = f_cut_comp; if (fl_cut == 1) f = f_cut_str; if (f) { int max_count = 6; int i; // if(oldRoot.top>comp->upper||oldRoot.bottom<comp->upper+comp->h-1||oldRoot.left>comp->left||oldRoot.right<comp->left+comp->w-1) // { fprintf(f, "Top:%d", comp1->upper); for (i = GetCountNumbers(comp1->upper); i <= max_count; i++) fprintf(f, " "); fprintf(f, "Bottom:%d", comp1->upper + comp1->h - 1); for (i = GetCountNumbers(comp1->upper + comp1->h - 1); i <= max_count; i++) fprintf(f, " "); fprintf(f, "Left:%d", comp1->left); for (i = GetCountNumbers(comp1->left); i <= max_count; i++) fprintf(f, " "); fprintf(f, "Right:%d", comp1->left + comp1->w - 1); for (i = GetCountNumbers(comp1->left + comp1->w - 1); i <= max_count; i++) fprintf(f, " "); fprintf(f, "\n"); fprintf(f, "Top:%d", comp2->upper); for (i = GetCountNumbers(comp2->upper); i <= max_count; i++) fprintf(f, " "); fprintf(f, "Bottom:%d", comp2->upper + comp2->h - 1); for (i = GetCountNumbers(comp2->upper + comp2->h - 1); i <= max_count; i++) fprintf(f, " "); fprintf(f, "Left:%d", comp2->left); for (i = GetCountNumbers(comp2->left); i <= max_count; i++) fprintf(f, " "); fprintf(f, "Right:%d", comp2->left + comp2->w - 1); for (i = GetCountNumbers(comp2->left + comp2->w - 1); i <= max_count; i++) fprintf(f, " "); fprintf(f, "\n"); /* oldRoot.top=comp->upper; oldRoot.bottom=comp->upper+comp->h-1; oldRoot.left=comp->left; oldRoot.right=comp->left+comp->w-1; } */ } FILE* f_temp = NULL; if (fl_cut == 0) f_temp = f_temp_cut_comp; if (fl_cut == 1) f_temp = f_temp_cut; if (f_temp) { int max_count = 6; int i; // if(oldRoot.top>comp->upper||oldRoot.bottom<comp->upper+comp->h-1||oldRoot.left>comp->left||oldRoot.right<comp->left+comp->w-1) // { fprintf(f_temp, "Top:%d", comp1->upper); for (i = GetCountNumbers(comp1->upper); i <= max_count; i++) fprintf(f_temp, " "); fprintf(f_temp, "Bottom:%d", comp1->upper + comp1->h - 1); for (i = GetCountNumbers(comp1->upper + comp1->h - 1); i <= max_count; i++) fprintf(f_temp, " "); fprintf(f_temp, "Left:%d", comp1->left); for (i = GetCountNumbers(comp1->left); i <= max_count; i++) fprintf(f_temp, " "); fprintf(f_temp, "Right:%d", comp1->left + comp1->w - 1); for (i = GetCountNumbers(comp1->left + comp1->w - 1); i <= max_count; i++) fprintf(f_temp, " "); fprintf(f_temp, "\n"); fprintf(f_temp, "Top:%d", comp2->upper); for (i = GetCountNumbers(comp2->upper); i <= max_count; i++) fprintf(f_temp, " "); fprintf(f_temp, "Bottom:%d", comp2->upper + comp2->h - 1); for (i = GetCountNumbers(comp2->upper + comp2->h - 1); i <= max_count; i++) fprintf(f_temp, " "); fprintf(f_temp, "Left:%d", comp2->left); for (i = GetCountNumbers(comp2->left); i <= max_count; i++) fprintf(f_temp, " "); fprintf(f_temp, "Right:%d", comp2->left + comp2->w - 1); for (i = GetCountNumbers(comp2->left + comp2->w - 1); i <= max_count; i++) fprintf(f_temp, " "); fprintf(f_temp, "\n"); /* oldRoot.top=comp->upper; oldRoot.bottom=comp->upper+comp->h-1; oldRoot.left=comp->left; oldRoot.right=comp->left+comp->w-1; } */ } if ((!LDPUMA_Skip(CutCompD) && fl_cut == 0) || (!LDPUMA_Skip(CutStrD) && fl_cut == 1)) { if (!WasCutComp && fl_cut == 0) WasCutComp = TRUE; if (!WasCut && fl_cut == 1) WasCut = TRUE; DrawRect(MainWindowD, code_comp_cut_d, RGB(255,0,0), comp1->upper, comp1->upper + comp1->h - 1, comp1->left, comp1->left + comp1->w - 1); DrawRect(MainWindowD, code_comp_cut_d, RGB(255,0,0), comp2->upper, comp2->upper + comp2->h - 1, comp2->left, comp2->left + comp2->w - 1); } CCOM_DeleteContainer(hCutCCOM1); CCOM_DeleteContainer(hCutCCOM2); MyKillComp(comp); return TRUE; // delete[] lp; }