示例#1
0
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);

}
示例#2
0
void SeparatorsGet (void)
{
#define ABS1 10
#define ABS2 40

	//int nl;
	PAGEINFO			  pInfo;
//	LineInfo			  lInfo;
//	LinesTotalInfo        lti;
//	Handle                pBlock;
	Handle                pPage;
//	uint32_t				  HorType;
//	uint32_t				  VerType;
	uint32_t				  ResolutionCoeff;
	uint32_t i,j;

	Handle hPage = CPAGE_GetHandlePage(CPAGE_GetCurrentPage( ));
	Handle hBlock;
//	Point16 p_start, p_end;
	uint32_t key;
	uint32_t color;

	int32_t nPics;
	POLY_  *pPics;
//	extern Handle hUseCLine;
    uint32_t size_line_com=sizeof(LINE_COM);
	CLINE_handle hline;
	extern CLINE_handle HCLINE;


	pPage = CPAGE_GetHandlePage(CPAGE_GetCurrentPage( ));
	CPAGE_GetPageData( pPage, PT_PAGEINFO, (void*)&pInfo, sizeof(pInfo));
	ResolutionCoeff = pInfo.DPIY/2;

    SeparatorsFreeData ();


//	 if(!LDPUMA_Skip(hUseCLine))
//	 {
	  hline = CLINE_GetFirstLine(HCLINE);
	  if(!hline)
		 return;
      while(hline)
	  {
	   CPDLine cpdata=CLINE_GetLineData(hline);
       if(!cpdata)
          hline=CLINE_GetNextLine(hline);
       else
	   {
        nSeps++;
		pSeps = realloc (pSeps, nSeps*sizeof(SEPARATOR));

		pSeps [nSeps-1].xBegin = cpdata->Line.Beg_X;
        pSeps [nSeps-1].yBegin = cpdata->Line.Beg_Y;
        pSeps [nSeps-1].xEnd   = cpdata->Line.End_X;
        pSeps [nSeps-1].yEnd   = cpdata->Line.End_Y;
        pSeps [nSeps-1].nWidth = cpdata->Line.Wid10/10;
		if(cpdata->Dir==LD_Horiz)
     		pSeps [nSeps-1].Type   = SEP_HORZ;
		else
            pSeps [nSeps-1].Type   = SEP_VERT;
		hline=CLINE_GetNextLine(hline);
	   }
	  }
//	 }
/*	 else
	 {
	  pBlock = CPAGE_GetBlockFirst ( pPage, RLINE_BLOCK_TYPE );
	  if(pBlock == NULL) return;
	  CPAGE_GetBlockData( pPage, pBlock, RLINE_BLOCK_TYPE, &lti, sizeof(LinesTotalInfo));
	  HorType = (uint32_t)lti.Hor.Lns;
	  VerType = (uint32_t)lti.Ver.Lns;


	  pBlock = CPAGE_GetBlockFirst ( pPage, HorType );
	  while ( pBlock )
	  {
		CPAGE_GetBlockData( pPage, pBlock, HorType, &lInfo, sizeof(LineInfo));
		nSeps++;
		pSeps = realloc (pSeps, nSeps*sizeof(SEPARATOR));

		pSeps [nSeps-1].xBegin = lInfo.A.x;
        pSeps [nSeps-1].yBegin = lInfo.A.y;
        pSeps [nSeps-1].xEnd   = lInfo.B.x;
        pSeps [nSeps-1].yEnd   = lInfo.B.y;
        pSeps [nSeps-1].nWidth = lInfo.Thickness;
		pSeps [nSeps-1].Type   = SEP_HORZ;
		pBlock = CPAGE_GetBlockNext( pPage, pBlock, HorType );
	  }



	  pBlock = CPAGE_GetBlockFirst ( pPage, VerType );
	  while ( pBlock )
	  {
		CPAGE_GetBlockData( pPage, pBlock, VerType, &lInfo, sizeof(LineInfo));
		nSeps++;
		pSeps = realloc (pSeps, nSeps*sizeof(SEPARATOR));

		pSeps [nSeps-1].xBegin = lInfo.A.x;
        pSeps [nSeps-1].yBegin = lInfo.A.y;
        pSeps [nSeps-1].xEnd   = lInfo.B.x;
        pSeps [nSeps-1].yEnd   = lInfo.B.y;
        pSeps [nSeps-1].nWidth = lInfo.Thickness;
		pSeps [nSeps-1].Type   = SEP_VERT;
		pBlock = CPAGE_GetBlockNext( pPage, pBlock, VerType );
	  }
	 }
*/
	color = 200;
	key = 111;

	/* Deleting short separators */
	for(i = 0; i < nSeps; i++)
	{
		if(pSeps [i].Type == SEP_VERT)
		{
			if(pSeps[i].yEnd - pSeps[i].yBegin < ResolutionCoeff)
			{
				DeleteSeps(i);
				i--;
			}
			else
			{
				/*
				p_start.x = pSeps[i].xBegin;
				p_start.y = pSeps[i].yBegin;
				p_end.x   = pSeps[i].xEnd;
				p_end.y   = pSeps[i].yEnd;

				LDPUMA_DrawLine(NULL, &p_start, &p_end, 0, color, 4, key);
				*/
			}
		}
		else
		{
			if(pSeps[i].xEnd - pSeps[i].xBegin < ResolutionCoeff)
			{
				DeleteSeps(i);
				i--;
			}
			else
			{
				/*
				p_start.x = pSeps[i].xBegin;
				p_start.y = pSeps[i].yBegin;
				p_end.x   = pSeps[i].xEnd;
				p_end.y   = pSeps[i].yEnd;

				LDPUMA_DrawLine(NULL, &p_start, &p_end, 0, color, 4, key);
				*/
			}
		}
	}

	//LDPUMA_WaitUserInput(NULL, NULL);
	//LDPUMA_DeleteLines(NULL, key);

	/* Deleting separators from pictures */
	nPics = 0;
	pPics = NULL;

# define PICS_QUANTUM			128

	for(hBlock = CPAGE_GetBlockFirst(hPage,TYPE_IMAGE);
	hBlock!=NULL;
	hBlock = CPAGE_GetBlockNext(hPage,hBlock,TYPE_IMAGE))
	{
		if (nPics % PICS_QUANTUM == 0)
		{
			pPics = realloc (pPics,
				(size_t) ((nPics / PICS_QUANTUM + 1)
				* PICS_QUANTUM * sizeof (POLY_)));
		}
		CPAGE_GetBlockData(hPage,hBlock,TYPE_IMAGE, &pPics[nPics++], sizeof(POLY_));
	}

	for (i = 0; i < nPics; i++)
	{
		for (j = 0; j < nSeps; j++)
		{
			if( (pSeps[j].xBegin > pPics[i].com.Vertex[0].x-10)	&&
				(pSeps[j].yBegin > pPics[i].com.Vertex[0].y-10)	&&
				(pSeps[j].xEnd   < pPics[i].com.Vertex[1].x+10)	&&
				(pSeps[j].yEnd   < pPics[i].com.Vertex[2].y+10))
			{
				DeleteSeps(j);
				j--;
			}
		}
	}

	if (pPics != NULL)
	{
		free (pPics);
		pPics = NULL;
	}
	nPics = 0;


	/* Удаление близколежащих сепараторов */
	for (i = 0; i < nSeps; i++)
	{
		for (j = 0; j < nSeps; j++)
		{
			if(pSeps [i].Type == SEP_VERT && pSeps [j].Type == SEP_VERT)
			{
				if((uint32_t)(abs(pSeps[i].xBegin - pSeps[j].xEnd  ) < ResolutionCoeff/2) &&
				   (uint32_t)(abs(pSeps[i].xEnd   - pSeps[j].xBegin) < ResolutionCoeff/2) &&
				   (pSeps[i].yBegin < pSeps[j].yBegin)	           &&
				   (pSeps[i].yEnd   > pSeps[j].yEnd))
				{
					DeleteSeps(j);
					j--;
				}
			}
		}
	}


	/* Объединение сепараторов */
	for (i = 0; i < nSeps; i++)
	{
		for (j = 0; j < nSeps; j++)
		{
			if(pSeps [i].Type == SEP_VERT && pSeps [j].Type == SEP_VERT)
			{
				if((abs(pSeps[i].xBegin - pSeps[j].xEnd) < ABS1) &&
				   (pSeps[i].yBegin > pSeps[j].yEnd)			 &&
				   (uint32_t)(pSeps[i].yBegin - pSeps[j].yEnd) < ResolutionCoeff/2)
				{
					pSeps[i].xBegin = MIN(pSeps[i].xBegin, pSeps[j].xBegin);
					pSeps[i].xEnd = MAX(pSeps[i].xEnd, pSeps[j].xEnd);
					pSeps[i].yBegin = pSeps[j].yBegin;
					DeleteSeps(j);
					j--;
				}
			}

			if(pSeps [i].Type == SEP_HORZ && pSeps [j].Type == SEP_HORZ)
			{
				if((abs(pSeps[i].yBegin - pSeps[j].yEnd) < ABS1) &&
				   (pSeps[i].xBegin > pSeps[j].xEnd)			 &&
				   (pSeps[i].xBegin - pSeps[j].xEnd) < ABS2)
				{
					pSeps[i].yBegin = MIN(pSeps[i].yBegin, pSeps[j].yBegin);
					pSeps[i].yEnd = MAX(pSeps[i].yEnd, pSeps[j].yEnd);
					pSeps[i].xBegin = pSeps[j].xBegin;
					DeleteSeps(j);
					j--;
				}
			}
		}
	}


	/*
	for(i = 0; i < nSeps; i++)
	{
		color = 200;
		key = 111;
		p_start.x = pSeps[i].xBegin;
		p_start.y = pSeps[i].yBegin;
		p_end.x   = pSeps[i].xEnd;
		p_end.y   = pSeps[i].yEnd;

		LDPUMA_DrawLine(NULL, &p_start, &p_end, 0, color, 4, key);
	}
	*/

		//LDPUMA_WaitUserInput(NULL, NULL);

}
示例#3
0
文件: rpic.cpp 项目: nctan/quneiform
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;
}