示例#1
0
static void StringsDownOrderUpdate (int xLeft, int yTop, int nScaling)
{
    STRING *p;
    int nString;

    struct textsettings ts;
    int x, y;
    char szTextBuffer [128];

    LT_GraphicsClearScreen ();

    _gettextsettings (&ts);
    _setcharsize (ts.height / 2, ts.width / 2);
    _settextalign (_CENTER, _HALF);

    for (nString = 1, p = pStringsDownList; p != NULL; p = p -> pUp, nString++)
    {
        _setcolor (p -> uFlags & SF_NEED_DELETE ? 15 : NUMBER_TO_COLOR (nString));
        _rectangle (_GBORDER,
                    (p -> xLeft   - xLeft) / nScaling,
                    (p -> yTop    - yTop)  / nScaling,
                    (p -> xRight  - xLeft) / nScaling,
                    (p -> yBottom - yTop)  / nScaling);

        x = ((p -> xLeft + p -> xRight)  / 2 - xLeft) / nScaling;
        y = ((p -> yTop  + p -> yBottom) / 2 - yTop)  / nScaling;

        _setcolor (15);
        sprintf (szTextBuffer, "%d", nString);
        _grtext (x, y, szTextBuffer);
    }

    _setcharsize (ts.height, ts.width);
}
示例#2
0
static void RootsUpdate (int xLeft, int yTop, int nScaling)
{
    ROOT *pRoot;

    LT_GraphicsClearScreen ();

    for (pRoot = cf::Roots::first(); pRoot < pAfterRoots; pRoot++)
    {
        int nColor = 8;

        if (pRoot -> bType & ROOT_LETTER)       nColor |= 1;
        if (pRoot -> bType & ROOT_RECOGNIZED)   nColor |= 2;
        if (pRoot->isLayoutDust())              nColor |= 4;

        if (pRoot -> bType & ROOT_DEBUG)        nColor = 14;

        _setcolor (nColor);

        _rectangle (_GFILLINTERIOR,
            (pRoot -> xColumn - xLeft) / nScaling,
            (pRoot -> yRow    - yTop)  / nScaling,
            (pRoot -> xColumn + pRoot ->nWidth  - 1 - xLeft) / nScaling,
            (pRoot -> yRow    + pRoot ->nHeight - 1 - yTop)  / nScaling);
    }

    SeparatorsOutput (xLeft, yTop, nScaling);
}
示例#3
0
static void RasterUpdate (int xLeft, int yTop, int nScaling)
{
    int x, y;
    int nStep;

    LT_GraphicsClearScreen ();

    nStep = MIN (FIELD_WIDTH / nRasterWidth, FIELD_HEIGHT / nRasterHeight);

    if (nStep == 0) nStep = 1;

    _setcolor (15);
    _rectangle (_GFILLINTERIOR,
                (0                     - xLeft) / nScaling,
                (0                     - yTop)  / nScaling,
                (nRasterWidth  * nStep - xLeft) / nScaling,
                (nRasterHeight * nStep - yTop)  / nScaling);

    _setcolor (0);

    for (x = 0; x < nRasterWidth; x++)
    {
        for (y = 0; y < nRasterHeight; y++)
        {
            if ((pRaster [y * nRasterByteWidth + x / 8] << x % 8) & 0x80)
            {
                _rectangle (_GFILLINTERIOR,
                    (x       * nStep - xLeft) / nScaling,
                    (y       * nStep - yTop)  / nScaling,
                    ((x + 1) * nStep - xLeft) / nScaling,
                    ((y + 1) * nStep - yTop)  / nScaling);
            }
        }
    }

    _setcolor (7);

    for (x = 0; x <= nRasterWidth; x++)
    {
        _moveto ((x * nStep             - xLeft) / nScaling,
                 (0                     - yTop)  / nScaling);
        _lineto ((x * nStep             - xLeft) / nScaling,
                 (nRasterHeight * nStep - yTop)  / nScaling);
    }

    for (y = 0; y <= nRasterHeight; y++)
    {
        _moveto ((0                    - xLeft) / nScaling,
                 (y * nStep            - yTop)  / nScaling);
        _lineto ((nRasterWidth * nStep - xLeft) / nScaling,
                 (y * nStep            - yTop)  / nScaling);
    }
}
示例#4
0
static void BlocksUpdate (int xLeft, int yTop, int nScaling)
{
    BLOCK *p;
    ROOT *pRoot;
    int  nColor;

    LT_GraphicsClearScreen ();

    for (p = pBlocksList; p != NULL; p = p -> pNext)
    {
        nColor = NUMBER_TO_COLOR (p -> nNumber) |
                 (((p -> uFlags & BF_NOT_BREAK_BLOCK) != 0) << 3);

        _setcolor (nColor);
        BlockRectangle (p, _GBORDER, xLeft, yTop, nScaling);

        SeparatorOutput (p -> pUpSep,    nColor, SEPOUT_DASH_1, xLeft, yTop, nScaling);
        SeparatorOutput (p -> pDownSep,  nColor, SEPOUT_DASH_2, xLeft, yTop, nScaling);
        SeparatorOutput (p -> pLeftSep,  nColor, SEPOUT_DASH_1, xLeft, yTop, nScaling);
        SeparatorOutput (p -> pRightSep, nColor, SEPOUT_DASH_2, xLeft, yTop, nScaling);
    }

    for (pRoot = cf::Roots::first(); pRoot < pAfterRoots; pRoot++)
    {
        if (pRoot -> nBlock == REMOVED_BLOCK_NUMBER)
        {

        }
        else
        {
            if (pRoot -> nBlock == DUST_BLOCK_NUMBER)
                _setcolor (15);
            else
                _setcolor (NUMBER_TO_COLOR (pRoot -> nBlock));

            _rectangle (_GFILLINTERIOR,
                (pRoot -> xColumn - xLeft) / nScaling,
                (pRoot -> yRow    - yTop)  / nScaling,
                (pRoot -> xColumn + pRoot ->nWidth  - 1
                                        - xLeft) / nScaling,
                (pRoot -> yRow    + pRoot ->nHeight - 1
                                        - yTop)  / nScaling);
        }
    }
}
示例#5
0
static void BreakingUpdate (int xLeft, int yTop, int nScaling)
{
    int x, y;
    int nStep;

    LT_GraphicsClearScreen ();

    nStep = MIN (FIELD_WIDTH / nRasterWidth, FIELD_HEIGHT / nRasterHeight);

    if (nStep == 0)
        nStep = 1;

    _setcolor (15);
    _rectangle (_GFILLINTERIOR,
                (0                     - xLeft) / nScaling,
                (0                     - yTop)  / nScaling,
                (nRasterWidth  * nStep - xLeft) / nScaling,
                (nRasterHeight * nStep - yTop)  / nScaling);

    for (x = 0; x < nRasterWidth; x++)
    {
        for (y = 0; y < nRasterHeight; y++)
        {
            if ((pRaster [y * nRasterByteWidth + x / 8] << x % 8) & 0x80)
                _setcolor (0);
            else if (y == yRasterBreakLine)
                _setcolor (12);
            else if (y >= yRasterUpBreakLimit && y <= yRasterDownBreakLimit)
                _setcolor (14);
            else
                continue;

            _rectangle (_GFILLINTERIOR,
                (x       * nStep - xLeft) / nScaling,
                (y       * nStep - yTop)  / nScaling,
                ((x + 1) * nStep - xLeft) / nScaling,
                ((y + 1) * nStep - yTop)  / nScaling);
        }
    }

    _setcolor (7);

    for (x = 0; x <= nRasterWidth; x++)
    {
        _moveto ((x * nStep             - xLeft) / nScaling,
                 (0                     - yTop)  / nScaling);
        _lineto ((x * nStep             - xLeft) / nScaling,
                 (nRasterHeight * nStep - yTop)  / nScaling);
    }

    for (y = 0; y <= nRasterHeight; y++)
    {
        _moveto ((0                    - xLeft) / nScaling,
                 (y * nStep            - yTop)  / nScaling);
        _lineto ((nRasterWidth * nStep - xLeft) / nScaling,
                 (y * nStep            - yTop)  / nScaling);
    }

    _setcolor (9);

    for (y = 0; y <= nRasterHeight; y++)
    {
        _rectangle (_GFILLINTERIOR,
            ((nRasterWidth + 1) * nStep - xLeft) / nScaling,
            (y                  * nStep - yTop)  / nScaling,
            ((aRasterHystogram [y] + nRasterWidth + 1)
                                * nStep - xLeft) / nScaling,
            ((y + 1)            * nStep - yTop)  / nScaling);
    }
}
示例#6
0
static void StringsUpdate (int xLeft, int yTop, int nScaling)
{
    STRING *pString;
    ROOT        *pRoot;
    int nString;
    int nColor;
    int nDustShift;
    int i;
    unsigned old_style;

    LT_GraphicsClearScreen ();

    for (pString = pStringsUpList, nString = 0;
             pString != NULL;
                 pString = pString -> pDown, nString++)
    {
        nColor     = NUMBER_TO_COLOR (nString);
        nDustShift = 2 * (nString % 6 + 1);

        _setcolor (nColor + 8);
        _rectangle (_GBORDER,
                    (pString -> xLeft   - xLeft) / nScaling,
                    (pString -> yTop    - yTop)  / nScaling,
                    (pString -> xRight  - xLeft) / nScaling,
                    (pString -> yBottom - yTop)  / nScaling);

        for (i = 0; i < pString -> nLetters; i++)
        {
            pRoot = cf::Roots::at(pString -> pLettersList [i]);
            _setcolor ((pRoot -> bType & ROOT_SPECIAL_LETTER) ? 15 : nColor);
            _rectangle (_GFILLINTERIOR,
                (pRoot -> xColumn - xLeft) / nScaling + nDustShift,
                (pRoot -> yRow    - yTop)  / nScaling,
                (pRoot -> xColumn + pRoot ->nWidth  - 1
                                        - xLeft) / nScaling + nDustShift,
                (pRoot -> yRow    + pRoot ->nHeight - 1
                                        - yTop)  / nScaling);
        }

        _setcolor (nColor + 8);

        for (i = 0; i < pString -> nDust; i++)
        {
            pRoot = cf::Roots::at(pString -> pDustList [i]);

            if (pRoot -> bType & ROOT_USED)
                continue;

            _rectangle (_GBORDER,
                (pRoot -> xColumn - xLeft) / nScaling + nDustShift,
                (pRoot -> yRow    - yTop)  / nScaling,
                (pRoot -> xColumn + pRoot ->nWidth - 1
                                        - xLeft) / nScaling + nDustShift,
                (pRoot -> yRow    + pRoot ->nHeight - 1
                                        - yTop)  / nScaling);
        }

        _setcolor (15);

        for (i = 0; i < pString -> nDust; i++)
        {
            pRoot = cf::Roots::at(pString -> pDustList [i]);

            if (pRoot -> bType & ROOT_USED)
                continue;

            _rectangle (_GBORDER,
                (pRoot -> xColumn - xLeft) / nScaling,
                (pRoot -> yRow    - yTop)  / nScaling,
                (pRoot -> xColumn + pRoot ->nWidth - 1
                                        - xLeft) / nScaling,
                (pRoot -> yRow    + pRoot ->nHeight - 1
                                        - yTop)  / nScaling);
        }

        _setcolor (nColor + 8);

        old_style = _getlinestyle ();
        _setlinestyle (0xcccc);

        _moveto ((pString -> xLeft  - xLeft) / nScaling,
                 (pString -> yMin   - yTop)  / nScaling);
        _lineto ((pString -> xRight - xLeft) / nScaling,
                 (pString -> yMin   - yTop)  / nScaling);

        _moveto ((pString -> xLeft  - xLeft) / nScaling,
                 (pString -> yMax   - yTop)  / nScaling);
        _lineto ((pString -> xRight - xLeft) / nScaling,
                 (pString -> yMax   - yTop)  / nScaling);
        _setlinestyle (old_style);

        _setcolor (12);
        _rectangle (_GBORDER,
                    (pString -> xLeft   - xLeft) / nScaling,
                    (pString -> yTop    - yTop)  / nScaling,
                    (pString -> xRight  - xLeft) / nScaling,
                    (pString -> yBottom - yTop)  / nScaling);

        _setcolor (15);
        _moveto ((pString -> xLeft         - xLeft) / nScaling,
                 (pString -> yMiddleTop    - yTop)  / nScaling);
        _lineto ((pString -> xRight        - xLeft) / nScaling,
                 (pString -> yMiddleTop    - yTop)  / nScaling);

        _moveto ((pString -> xLeft         - xLeft) / nScaling,
                 (pString -> yMiddleBottom - yTop)  / nScaling);
        _lineto ((pString -> xRight        - xLeft) / nScaling,
                 (pString -> yMiddleBottom - yTop)  / nScaling);
    }

    SeparatorsOutput (xLeft, yTop, nScaling);
}
示例#7
0
static void CurrentStringUpdate (int xLeft, int yTop, int nScaling)
{
    ROOT *pRoot;
    int i;
    unsigned old_style;

    LT_GraphicsClearScreen ();

    for (i = 0; i < String.nLetters; i++)
    {
        pRoot = cf::Roots::at(String.pLettersList[i]);

        _setcolor ((pRoot -> bType & ROOT_SPECIAL_LETTER) ? 15 : 10);
        _rectangle (_GFILLINTERIOR,
            (pRoot -> xColumn                       - xLeft) / nScaling,
            (pRoot -> yRow                          - yTop)  / nScaling,
            (pRoot -> xColumn + pRoot ->nWidth  - 1 - xLeft) / nScaling,
            (pRoot -> yRow    + pRoot ->nHeight - 1 - yTop)  / nScaling);
    }

    _setcolor (10);

    for (i = 0; i < String.nDust; i++)
    {
        pRoot = cf::Roots::at(String.pDustList[i]);

        _rectangle (_GBORDER,
            (pRoot -> xColumn                        - xLeft) / nScaling - 1,
            (pRoot -> yRow                           - yTop)  / nScaling - 1,
            (pRoot -> xColumn + pRoot -> nWidth  - 1 - xLeft) / nScaling + 1,
            (pRoot -> yRow    + pRoot -> nHeight - 1 - yTop)  / nScaling + 1);
    }

    old_style = _getlinestyle ();
    _setlinestyle (0xcccc);

    _moveto ((String.xLeft  - xLeft) / nScaling,
             (String.yMin   - yTop)  / nScaling);
    _lineto ((String.xRight - xLeft) / nScaling,
             (String.yMin   - yTop)  / nScaling);

    _moveto ((String.xLeft  - xLeft) / nScaling,
             (String.yMax   - yTop)  / nScaling);
    _lineto ((String.xRight - xLeft) / nScaling,
             (String.yMax   - yTop)  / nScaling);
    _setlinestyle (old_style);

    _setcolor (12);
    _rectangle (_GBORDER,
                (String.xLeft   - xLeft) / nScaling,
                (String.yTop    - yTop)  / nScaling,
                (String.xRight  - xLeft) / nScaling,
                (String.yBottom - yTop)  / nScaling);

    _setcolor (15);
    _moveto ((String.xLeft         - xLeft) / nScaling,
             (String.yMiddleTop    - yTop)  / nScaling);
    _lineto ((String.xRight        - xLeft) / nScaling,
             (String.yMiddleTop    - yTop)  / nScaling);

    _moveto ((String.xLeft         - xLeft) / nScaling,
             (String.yMiddleBottom - yTop)  / nScaling);
    _lineto ((String.xRight        - xLeft) / nScaling,
             (String.yMiddleBottom - yTop)  / nScaling);
}
示例#8
0
static void HystogramUpdate (int xLeft, int yTop, int nScaling)
{
    char szBuffer [32];
    int i;
    int nMaxValue;
    int iMaxColumn;
    struct textsettings ts;
    int nCharHeight;
	ROOT *pRoot;//Rom

    LT_GraphicsClearScreen ();

    nMaxValue  = 0;
    iMaxColumn = 0;

	/**/
    for (pRoot = cf::Roots::first(); pRoot < pAfterRoots; pRoot++)
    {
		if(pRoot->nBlock == pDebugBlock->nNumber)
		{
			int nColor = 8;

			if (pRoot -> bType & ROOT_LETTER)       nColor |= 1;
			if (pRoot -> bType & ROOT_RECOGNIZED)   nColor |= 2;
                        if (pRoot->isLayoutDust())              nColor |= 4;

			if (pRoot -> bType & ROOT_DEBUG)        nColor = 14;

			_setcolor (nColor);

			_rectangle (_GFILLINTERIOR,
				(pRoot -> xColumn - xLeft) / nScaling,
				(pRoot -> yRow    - yTop)  / nScaling,
				(pRoot -> xColumn + pRoot ->nWidth  - 1 - xLeft) / nScaling,
				(pRoot -> yRow    + pRoot ->nHeight - 1 - yTop)  / nScaling);
		}
    }
	/**/

    for (i = 0; i < nHystColumns; i++)
    {
        if (nMaxValue < pHystogram [i])
        {
            nMaxValue  = pHystogram [i];
            iMaxColumn = i;
        }
    }

    if (nMaxValue < 10)
        nMaxValue = 10;

    _gettextsettings (&ts);

    for (i = 0; i < nHystColumns; i++)
    {
        if (pHystogram [i] == 0)
        {

        }
        else
        {
            _setcolor (9);

            _rectangle (_GFILLINTERIOR,
                (i * VIEW_WIDTH / nHystColumns + VIEW_LEFT
                                                     - xLeft) / nScaling,
                (VIEW_BOTTOM - pHystogram [i] * VIEW_HEIGHT / nMaxValue
                                                     - yTop)  / nScaling,
                ((i + 1) * VIEW_WIDTH / nHystColumns + VIEW_LEFT
                                                     - xLeft) / nScaling,
                (VIEW_BOTTOM
                                                     - yTop)  / nScaling);
        }
    }

    _setcolor (12);

    _moveto (((xDebugVertLine - pDebugBlock -> Rect.xLeft)
                  * VIEW_WIDTH / nHystColumns
                        + VIEW_WIDTH / nHystColumns / 2
                        + VIEW_LEFT
                        - xLeft) / nScaling, 0);
    _lineto (((xDebugVertLine - pDebugBlock -> Rect.xLeft)
                  * VIEW_WIDTH / nHystColumns
                        + VIEW_WIDTH / nHystColumns / 2
                        + VIEW_LEFT
                        - xLeft) / nScaling, SCREEN_HEIGHT);

    _setcolor (15);
    _settextalign (_RIGHT, _TOP);
    nCharHeight = VIEW_HEIGHT / 10 / nScaling / 2;
    _setcharsize (nCharHeight, nCharHeight / 2);

    for (i = 0; i < nMaxValue - nMaxValue / 20; i += MAX (nMaxValue / 10, 1))
    {
        _moveto ((VIEW_LEFT                                 - xLeft)/ nScaling,
                 (VIEW_BOTTOM - i * VIEW_HEIGHT / nMaxValue - yTop) / nScaling);
        _lineto ((VIEW_RIGHT                                - xLeft)/ nScaling,
                 (VIEW_BOTTOM - i * VIEW_HEIGHT / nMaxValue - yTop) / nScaling);

        if (i != 0)
        {
            sprintf (szBuffer, "%d\n", i);
            _grtext ((VIEW_LEFT - xLeft) / nScaling,
                (VIEW_BOTTOM - i * VIEW_HEIGHT / nMaxValue - yTop) / nScaling,
                 szBuffer);
        }
    }

    sprintf (szBuffer, "%d\n", nMaxValue);
    _grtext ((VIEW_LEFT - xLeft) / nScaling,
             (VIEW_TOP  - yTop)  / nScaling,
             szBuffer);

    _rectangle (_GBORDER,
                (VIEW_LEFT   - xLeft) / nScaling,
                (VIEW_TOP    - yTop)  / nScaling,
                (VIEW_RIGHT  - xLeft) / nScaling,
                (VIEW_BOTTOM - yTop)  / nScaling);

    _setcharsize (ts.height, ts.width);
}
示例#9
0
Bool TryCutBlockOnHorizontal (BLOCK *p)
{
    int iColumn;
    int iZeroEnd;
    Bool bNotSpace;

    int  iBestPointSizeBreakingColumn;
    int  nPointSizeDifference;
    int  nBestPointSizeDifference = 0; /* To avoid warning on MPW C/C++ */

    BLOCK *q, *r;

# ifdef LT_DEBUG
    if (p -> pHorzHystogram == NULL)
        ErrorInternal ("pHorzHystogram not builded in TryCutBlockOnHorizontal");
# endif

    nHystColumnWidth = 1;
    nHystColumns     = p -> Rect.yBottom - p -> Rect.yTop + 1;

    memcpy (pHystogram, p -> pHorzHystogram, nHystColumns * sizeof (int));

# ifdef LT_DEBUG
    //if (LT_DebugGraphicsLevel >= 4)
	if(!LDPUMA_Skip(hBlocksBreaking))
        LT_GraphicsHystogramOutput ("Hystogram for horizontal breaking");
# endif

    bNotSpace = FALSE;
    for (iColumn = 0; iColumn < nHystColumns; iColumn++)
    {
        if (pHystogram [iColumn] != 0)
        {
            bNotSpace = TRUE;
            continue;
        }

        if (! bNotSpace)
            continue;

        for (iZeroEnd = iColumn + 1;
                    iZeroEnd < nHystColumns && pHystogram [iZeroEnd] == 0;
                        iZeroEnd++)
        {
        }

        if (iZeroEnd == nHystColumns)
            break;

        if (HorizontalBreakingCondition (p, iColumn, iZeroEnd - 1) &&
            BlockBreakOnHorizontal (p, NULL, NULL, iColumn + p -> Rect.yTop))
        {
            return (TRUE);
        }

        iColumn = iZeroEnd;
    }

    /*
     *  Analysis with font accounting
     */

    if (! bOptionPointSizeAnalysis)
        return (FALSE);

    BlockBuild_HystHorzHeightesSum (p);

    HystogramMakeIntegral (pHystInt1,
                           pHystogram,
                           nHystColumns);

    HystogramMakeIntegral (pHystInt2,
                           pHystHorzHeightesSum,
                           nHystColumns);

    iBestPointSizeBreakingColumn = 0;

    for (iColumn = 0; iColumn < nHystColumns; iColumn++)
    {
        int nAverageHeightBefore;
        int nAverageHeightAfter;

        if (pHystogram [iColumn] != 0)
            continue;

        if (pHystInt1 [iColumn] == 0 ||
            pHystInt1 [nHystColumns - 1] - pHystInt1 [iColumn] <= 20)
        {
            continue;
        }

        nAverageHeightBefore = pHystInt2 [iColumn] / pHystInt1 [iColumn];
        nAverageHeightAfter  =
            (pHystInt2 [nHystColumns - 1] - pHystInt2 [iColumn]) /
            (pHystInt1 [nHystColumns - 1] - pHystInt1 [iColumn]);

        if (nAverageHeightBefore == 0 || nAverageHeightAfter == 0)
            continue;

        if (! ((nAverageHeightBefore-1)*2 >= nAverageHeightAfter  * ZagolovokBreakingCoeff ||
               (nAverageHeightAfter-1)*2  >= nAverageHeightBefore * ZagolovokBreakingCoeff))
        {
            continue;
        }

        nPointSizeDifference =
            MAX (nAverageHeightBefore * 1000 / nAverageHeightAfter,
                 nAverageHeightAfter  * 1000 / nAverageHeightBefore);

        if (iBestPointSizeBreakingColumn == 0 ||
            nPointSizeDifference > nBestPointSizeDifference)
        {
            iBestPointSizeBreakingColumn = iColumn;
            nBestPointSizeDifference     = nPointSizeDifference;
        }
    }

    iColumn = iBestPointSizeBreakingColumn;

    if (pHystInt1 [nHystColumns - 1] - pHystInt1 [iColumn] > 0 &&
        iColumn <=
            (pHystInt2 [nHystColumns - 1] - pHystInt2 [iColumn]) /
            (pHystInt1 [nHystColumns - 1] - pHystInt1 [iColumn]) / 2)
    {
        /* Strange case: its possibly dots above letters */
        return (FALSE);
    }

    if (BlockBreakOnHorizontal
          (p, &q, &r, iBestPointSizeBreakingColumn + p -> Rect.yTop))
    {
# ifdef LT_DEBUG
        //if (LT_DebugGraphicsLevel >= 3)
		if(!LDPUMA_Skip(hBlocksBreaking))
        {
            pDebugBlock = q;
            LT_GraphicsBlockOutput2 ("Block was breaked using "
                                         "Horz PointSizeAnalysis");
            pDebugBlock = r;
            LT_GraphicsBlockOutput2 ("Block was breaked using "
                                         "Horz PointSizeAnalysis");
            LT_Getch ();
            LT_GraphicsClearScreen ();
        }
# endif
        return (TRUE);
    }

    return (FALSE);
}
示例#10
0
Bool TryCutBlockOnVertical (BLOCK *p, int bcr_cut, Bool32 SecondStage)
{
    ROOT *pRoot;

    int  iLeftColumn, iRightColumn;
    int  iColumn;

    int  nMaximum;
    int  nLowLevel;

    int  nSpaceWidth;
    int  iSpace;
    int  nHystSum;
    Bool bNotSpace;

    int  iLeftLimit;
    int  iRightLimit;
    int  iBestPointSizeBreakingColumn;
    int  nPointSizeDifference;
    int  nBestPointSizeDifference = 0; /* To avoid warning on MPW C/C++ */

	int nSum;
	int nAverage;
	int nColumns;

    BLOCK *q, *r;

# ifdef LT_DEBUG
    if (p -> pHorzHystogram == NULL)
        ErrorInternal ("pHorzHystogram not builded in TryCutBlockOnVertical");
# endif

    nHystColumnWidth = p -> nStartColumnWidth;

    while (nHystColumnWidth >= p -> nConditionalMinColumnWidth)
    {
        /* Build vertical hystogram */

        nHystColumns = (p -> Rect.xRight - p -> Rect.xLeft + 1)
                       / nHystColumnWidth + 1;

        //memset (pHystogram, 0, nHystColumns * sizeof (int));
		memset (pHystogram, 0, (nHystColumns + 1) * sizeof (int));// Piter 08.07.99

        for (pRoot = p -> pRoots; pRoot != NULL; pRoot = pRoot -> u1.pNext)
        {
            iLeftColumn  = (pRoot -> xColumn
                            - p -> Rect.xLeft) / nHystColumnWidth;
            iRightColumn = (pRoot -> xColumn + pRoot -> nWidth - 1
                            - p -> Rect.xLeft) / nHystColumnWidth;

            pHystogram [iLeftColumn]      ++;
            pHystogram [iRightColumn + 1] --;
        }

        nMaximum = 0;
        nHystSum = 0;

        for (iColumn = 0; iColumn < nHystColumns; iColumn++)
        {
            nHystSum += pHystogram [iColumn];
            pHystogram [iColumn] = nHystSum;

            if (pHystogram [iColumn] > nMaximum)
                nMaximum = pHystogram [iColumn];
        }

        nLowLevel = VERT_HYST_LOW_LEVEL (nMaximum);

		/* Rom */
		if (SecondStage)
		{
			nSum = 0;
			for (iColumn = 0; iColumn < nHystColumns; iColumn++)
			{
				nSum += pHystogram [iColumn];
			}

			if(nHystColumns!= 0)
			{
				nAverage = nSum/nHystColumns;
			}

			nSum = 0;
			nColumns = 0;
			for (iColumn = 0; iColumn < nHystColumns; iColumn++)
			{
				if(pHystogram [iColumn] > nAverage)
				{
					nSum += pHystogram [iColumn];
					nColumns++;
				}
			}

			if(nColumns!= 0)
			{
				nAverage = nSum/nColumns;
			}

			for (iColumn = 0; iColumn < nHystColumns; iColumn++)
			{
				if(pHystogram [iColumn] < nAverage / 10)
				{
					pHystogram [iColumn] = 0;
				}
			}
		}
		/* Rom */

# ifdef LT_DEBUG
        //if (LT_DebugGraphicsLevel >= 4)
		if(!LDPUMA_Skip(hBlocksBreaking))
		{
			pDebugBlock = p; // Piter 02-10-98
            LT_GraphicsHystogramOutput ("Hystogram for vertical breaking");
		}
# endif

        bNotSpace = FALSE;

        for (iColumn = 0; iColumn < nHystColumns; iColumn++)
        {
            if (pHystogram [iColumn] == 0)
            {
                if (! bNotSpace)
                    continue;

                if (nHystColumnWidth < p -> nUnconditionalMinColumnWidth &&
                    ! CorrectCondition (iColumn))
                {
                    continue;
                }

                nSpaceWidth = 0;

                for (iSpace = iColumn;
                         iSpace < nHystColumns && pHystogram [iSpace] == 0;
                             iSpace++)
                {
                    nSpaceWidth += nHystColumnWidth;
                }

                if (iSpace == nHystColumns)
                    break;

                if (BlockBreakOnVertical (p, NULL, NULL,
                        iColumn * nHystColumnWidth + p -> Rect.xLeft,
                        nSpaceWidth))
                {
                    return (TRUE);
                }

                iColumn += nSpaceWidth;
            }
            else
            {
                bNotSpace = TRUE;
            }
        }

        for (iColumn = 0; iColumn < nHystColumns; iColumn++)
        {
            if (pHystogram [iColumn] < nLowLevel)
            {
                nHystColumnWidth /= 2;
                break;
            }
        }

        if (iColumn == nHystColumns)
            break;
    }

    /*
     *  Analysis with font accounting
     */

    if (! (bOptionPointSizeAnalysis && bOptionBusinessCardsLayout))
        return (FALSE);
    if (!bcr_cut)
       return (FALSE);    // 940228
        /* Build vertical hystogram */

    if (nHystColumnWidth != 1)
    {
        nHystColumns = p -> Rect.xRight - p -> Rect.xLeft + 1;

        memset (pHystogram, 0, nHystColumns * sizeof (int));

        for (pRoot = p -> pRoots; pRoot != NULL; pRoot = pRoot -> u1.pNext)
        {
            iLeftColumn  = pRoot -> xColumn - p -> Rect.xLeft;
            iRightColumn = pRoot -> xColumn + pRoot -> nWidth - 1
                            - p -> Rect.xLeft;

            pHystogram [iLeftColumn]      ++;
            pHystogram [iRightColumn + 1] --;
        }

        nHystSum = 0;

        for (iColumn = 0; iColumn < nHystColumns; iColumn++)
        {
            nHystSum += pHystogram [iColumn];
            pHystogram [iColumn] = nHystSum;
        }
    }

    BlockBuild_HystVertHeightesSum (p);

    HystogramMakeIntegral (pHystInt1,
                           pHystogram,
                           nHystColumns);

    HystogramMakeIntegral (pHystInt2,
                           pHystVertHeightesSum,
                           nHystColumns);

    iLeftLimit  = nHystColumns / 10;
    iRightLimit = nHystColumns - nHystColumns / 10;

    iBestPointSizeBreakingColumn = 0;

    for (iColumn = iLeftLimit; iColumn < iRightLimit; iColumn++)
    {
        int nAverageHeightBefore;
        int nAverageHeightAfter;

        if (pHystogram [iColumn] != 0)
            continue;

        if (pHystInt1 [iColumn] == 0 ||
            pHystInt1 [nHystColumns - 1] - pHystInt1 [iColumn] == 0)
        {
            continue;
        }

        nAverageHeightBefore = pHystInt2 [iColumn] / pHystInt1 [iColumn];
        nAverageHeightAfter  =
            (pHystInt2 [nHystColumns - 1] - pHystInt2 [iColumn]) /
            (pHystInt1 [nHystColumns - 1] - pHystInt1 [iColumn]);

        if (nAverageHeightBefore == 0 || nAverageHeightAfter == 0)
            continue;

        if (! (nAverageHeightBefore >= nAverageHeightAfter  * 2 ||
               nAverageHeightAfter  >= nAverageHeightBefore * 3))
        {
            continue;
        }

        nPointSizeDifference =
            MAX (nAverageHeightBefore * 1000 / nAverageHeightAfter,
                 nAverageHeightAfter  * 1000 / nAverageHeightBefore);

        if (iBestPointSizeBreakingColumn == 0 ||
            nPointSizeDifference > nBestPointSizeDifference)
        {
            iBestPointSizeBreakingColumn = iColumn;
            nBestPointSizeDifference     = nPointSizeDifference;
        }
    }

    if (iBestPointSizeBreakingColumn != 0 &&
        BlockBreakOnVertical
          (p, &q, &r, iBestPointSizeBreakingColumn + p -> Rect.xLeft, 0))
    {
# ifdef LT_DEBUG
        //if (LT_DebugGraphicsLevel >= 3)
		if(!LDPUMA_Skip(hBlocksBreaking))
        {
            pDebugBlock = q;
            LT_GraphicsBlockOutput2 ("Block was breaked using "
                                         "Vert PointSizeAnalysis");
            pDebugBlock = r;
            LT_GraphicsBlockOutput2 ("Block was breaked using "
                                         "Vert PointSizeAnalysis");
            LT_Getch ();
            LT_GraphicsClearScreen ();
        }
# endif
        return (TRUE);
    }

    return (FALSE);
}