Usenet.com

www.Usenet.com

Group Index

Sci Thread Archive from Usenet.com

<-- __Chronological__ --> <-- __Thread__ -->

'Rectangle' 2D image to circle/elipse/cone or tube



Hi,

I found the code bellow to transforme a 2D image into an elipse.
It works fine but would a kind sould point to some code to create a
circle/cone or tube.

int ComputePixel(float x, float y, float &x1, float &y1)
{
    double r, nn;
    if (x==0 && y==0) {
    x1 = x;
    y1 = y;
    return 1;
    }
    nn = sqrt(x*x + y*y);
    r = (fabs(x) > fabs(y)) ? fabs(nn/x): fabs(nn/y);
    x1 = (float)(r*x);
    y1 = (float)(r*y);
    return 1;
}

void test()
{
    DWORD x, y, x1, y1;
    float fx, fy, xmid, ymid, ar;
    C_ANY_Image *image = new C_ANY_Image()//    a new image created here
    exmid = (float) (image->Width()/2.0);
    ymid = (float) (image->Height()/2.0);
    ar = (float)(image->Height())/(float)(image->Width());
    for (y=0; y<image->Height(); y++) {
    for (x=0; x<image->Width(); x++)
    {
        ComputePixel(ar*(x-xmid), y-ymid, fx, fy);
        x1 = (int)(xmid+fx/ar);
        y1 = (int)(ymid+fy);
        image2->SetPixelColor(x, y, image->GetPixelColor(x1, y1));
    }
}

Many thanks

Regards
Sims







<-- __Chronological__ --> <-- __Thread__ -->


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.