eGospodarka.pl
eGospodarka.pl poleca

eGospodarka.plGrupypl.comp.programmingprzyjemna zagadkaRe: przyjemna zagadka
  • Data: 2013-06-30 12:27:58
    Temat: Re: przyjemna zagadka
    Od: Adam Majewski <a...@o...pl> szukaj wiadomości tego autora
    [ pokaż wszystkie nagłówki ]


    Może przez wypełnienie konturu ?

    int FillContour(double dXseed, double dYseed, unsigned char color,
    unsigned char _data[])
    {
    /*
    fills contour with black border using seed point inside contour
    and horizontal lines
    it starts from seed point, saves max right( iXmaxLocal) and max
    left ( iXminLocal) interior points of horizontal line,
    in new line ( iY+1 or iY-1) it computes new interior point :
    iXmidLocal=iXminLocal + (iXmaxLocal-iXminLocal)/2;
    result is stored in _data array : 1D array of 1-bit colors (
    shades of gray)
    it does not check if index of _data array is good so memory error
    is possible
    */

    int iXseed = (int)((dXseed - ZxMin)/PixelWidth);
    int iYseed = (int)((dYseed - ZyMin)/PixelHeight);

    int iX, /* seed integer coordinate */
    iY=iYseed,
    /* most interior point of line iY */
    iXmidLocal=iXseed,
    /* min and max of interior points of horizontal line iY */
    iXminLocal,
    iXmaxLocal;
    int i ; /* index of _data array */;


    /* --------- move up --------------- */
    do{
    iX=iXmidLocal;
    i =f(iX,iY); /* index of _data array */;

    /* move to right */
    while (_data[i]==iInterior)
    { _data[i]=color;
    iX+=1;
    i=f(iX,iY);
    }
    iXmaxLocal=iX-1;

    /* move to left */
    iX=iXmidLocal-1;
    i=f(iX,iY);
    while (_data[i]==iInterior)
    { _data[i]=color;
    iX-=1;
    i=f(iX,iY);
    }
    iXminLocal=iX+1;


    iY+=1; /* move up */
    iXmidLocal=iXminLocal + (iXmaxLocal-iXminLocal)/2; /* new iX inside
    contour */
    i=f(iXmidLocal,iY); /* index of _data array */;
    if ( _data[i]==iJulia) break; /* it should not cross the border */

    } while (iY<iYmax);


    /* ------ move down ----------------- */
    iXmidLocal=iXseed;
    iY=iYseed-1;


    do{
    iX=iXmidLocal;
    i =f(iX,iY); /* index of _data array */;

    /* move to right */
    while (_data[i]==iInterior) /* */
    { _data[i]=color;
    iX+=1;
    i=f(iX,iY);
    }
    iXmaxLocal=iX-1;

    /* move to left */
    iX=iXmidLocal-1;
    i=f(iX,iY);
    while (_data[i]==iInterior) /* */
    { _data[i]=color;
    iX-=1; /* move to right */
    i=f(iX,iY);
    }
    iXminLocal=iX+1;

    iY-=1; /* move down */
    iXmidLocal=iXminLocal + (iXmaxLocal-iXminLocal)/2; /* new iX inside
    contour */
    i=f(iXmidLocal,iY); /* index of _data array */;
    if ( _data[i]==iJulia) break; /* it should not cross the border */
    } while (0<iY);



    return 0;
    }

    HTH

    Adam

Podziel się

Poleć ten post znajomemu poleć

Wydrukuj ten post drukuj


Następne wpisy z tego wątku

Najnowsze wątki z tej grupy


Najnowsze wątki

Szukaj w grupach

Eksperci egospodarka.pl

1 1 1

Wpisz nazwę miasta, dla którego chcesz znaleźć jednostkę ZUS.

Wzory dokumentów

Bezpłatne wzory dokumentów i formularzy.
Wyszukaj i pobierz za darmo: