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); }
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; }
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; }