eGospodarka.pl
eGospodarka.pl poleca

eGospodarka.plGrupypl.comp.programmingprzyjemna zagadkaRe: przyjemna zagadka
  • Path: news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!news.cyf-kr.edu.pl!news.nask
    .pl!news.nask.org.pl!newsfeed.pionier.net.pl!news.dialog.net.pl!not-for-mail
    From: Adam Majewski <a...@o...pl>
    Newsgroups: pl.comp.programming
    Subject: Re: przyjemna zagadka
    Date: Sun, 30 Jun 2013 12:27:58 +0200
    Organization: Dialog Net
    Lines: 107
    Message-ID: <kqp17e$72p$1@news.dialog.net.pl>
    References: <2...@g...com>
    NNTP-Posting-Host: dynamic-78-8-66-14.ssp.dialog.net.pl
    Mime-Version: 1.0
    Content-Type: text/plain; charset=ISO-8859-2; format=flowed
    Content-Transfer-Encoding: 8bit
    X-Trace: news.dialog.net.pl 1372588078 7257 78.8.66.14 (30 Jun 2013 10:27:58 GMT)
    X-Complaints-To: a...@d...net.pl
    NNTP-Posting-Date: Sun, 30 Jun 2013 10:27:58 +0000 (UTC)
    User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011
    Thunderbird/16.0.1
    In-Reply-To: <2...@g...com>
    Xref: news-archive.icm.edu.pl pl.comp.programming:203912
    [ ukryj 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: