Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. please! help me about antialiasing!!!

please! help me about antialiasing!!!

Scheduled Pinned Locked Moved C / C++ / MFC
graphicshelpwinformsperformance
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shiwan Sung
    wrote on last edited by
    #1

    I am under developing graphic programing. I already completed main parts. But there is problem. I used gdi implementing graphics, and so there is aliasing. It looks all figures nasty. I searched all the articles here, but I could not find any articles about antialiasing. Is there any good argorithm to apply antialiasing to my graphics without using gdi+. I also used gdi+, but the performance is not good for my graphics. please help me. thanks in advance.:((

    Y 1 Reply Last reply
    0
    • S Shiwan Sung

      I am under developing graphic programing. I already completed main parts. But there is problem. I used gdi implementing graphics, and so there is aliasing. It looks all figures nasty. I searched all the articles here, but I could not find any articles about antialiasing. Is there any good argorithm to apply antialiasing to my graphics without using gdi+. I also used gdi+, but the performance is not good for my graphics. please help me. thanks in advance.:((

      Y Offline
      Y Offline
      YoSilver
      wrote on last edited by
      #2

      The link: http://alglib.manual.ru/translate.php?location=/graphics/wuline&target=cpp[^] It is a Russian resource, I guess you don't speak Russian. So, here you are:

      #include "ap.h"

      /*-----------------------------------------------
      User-defined routine

      void setpixel(int x, int y, double c);
      -----------------------------------------------*/

      void drawwuline(double x1, double y1, double x2, double y2);
      double myfrac(double x);

      /*************************************************************************

      Wu Xiaolin algorithm with fractional coordinates (a-la DX90)

      *************************************************************************/
      void drawwuline(double x1, double y1, double x2, double y2)
      {
      double grad;
      double xd;
      double yd;
      double length;
      double xm;
      double ym;
      double xgap;
      double ygap;
      double xend;
      double yend;
      double xf;
      double yf;
      double brightness1;
      double brightness2;
      int x;
      int y;
      int ix1;
      int ix2;
      int iy1;
      int iy2;
      bool wasexchange;
      int tmpint;
      double tmpreal;

      xd = x2-x1;
      yd = y2-y1;
      if( xd==0&&yd==0 )
      {
          return;
      }
      if( fabs(xd)>fabs(yd) )
      {
          wasexchange = false;
      }
      else
      {
          wasexchange = true;
          tmpreal = x1;
          x1 = y1;
          y1 = tmpreal;
          tmpreal = x2;
          x2 = y2;
          y2 = tmpreal;
          tmpreal = xd;
          xd = yd;
          yd = tmpreal;
      }
      if( x1>x2 )
      {
          tmpreal = x1;
          x1 = x2;
          x2 = tmpreal;
          tmpreal = y1;
          y1 = y2;
          y2 = tmpreal;
          xd = x2-x1;
          yd = y2-y1;
      }
      grad = yd/xd;
      xend = floor(x1+0.5);
      yend = y1+grad\*(xend-x1);
      xgap = 1-myfrac(x1+0.5);
      ix1 = floor(x1+0.5);
      iy1 = floor(yend);
      brightness1 = (1-myfrac(yend))\*xgap;
      brightness2 = myfrac(yend)\*xgap;
      if( wasexchange )
      {
          setpixel(iy1, ix1, brightness1);
          setpixel(iy1+1, ix1, brightness2);
      }
      else
      {
          setpixel(ix1, iy1, brightness1);
          setpixel(ix1, iy1+1, brightness2);
      }
      yf = yend+grad;
      xend = floor(x2+0.5);
      yend = y2+grad\*(xend-x2);
      xgap = 1-myfrac(x2-0.5);
      ix2 = floor(x2+0.5)
      
      S 1 Reply Last reply
      0
      • Y YoSilver

        The link: http://alglib.manual.ru/translate.php?location=/graphics/wuline&target=cpp[^] It is a Russian resource, I guess you don't speak Russian. So, here you are:

        #include "ap.h"

        /*-----------------------------------------------
        User-defined routine

        void setpixel(int x, int y, double c);
        -----------------------------------------------*/

        void drawwuline(double x1, double y1, double x2, double y2);
        double myfrac(double x);

        /*************************************************************************

        Wu Xiaolin algorithm with fractional coordinates (a-la DX90)

        *************************************************************************/
        void drawwuline(double x1, double y1, double x2, double y2)
        {
        double grad;
        double xd;
        double yd;
        double length;
        double xm;
        double ym;
        double xgap;
        double ygap;
        double xend;
        double yend;
        double xf;
        double yf;
        double brightness1;
        double brightness2;
        int x;
        int y;
        int ix1;
        int ix2;
        int iy1;
        int iy2;
        bool wasexchange;
        int tmpint;
        double tmpreal;

        xd = x2-x1;
        yd = y2-y1;
        if( xd==0&&yd==0 )
        {
            return;
        }
        if( fabs(xd)>fabs(yd) )
        {
            wasexchange = false;
        }
        else
        {
            wasexchange = true;
            tmpreal = x1;
            x1 = y1;
            y1 = tmpreal;
            tmpreal = x2;
            x2 = y2;
            y2 = tmpreal;
            tmpreal = xd;
            xd = yd;
            yd = tmpreal;
        }
        if( x1>x2 )
        {
            tmpreal = x1;
            x1 = x2;
            x2 = tmpreal;
            tmpreal = y1;
            y1 = y2;
            y2 = tmpreal;
            xd = x2-x1;
            yd = y2-y1;
        }
        grad = yd/xd;
        xend = floor(x1+0.5);
        yend = y1+grad\*(xend-x1);
        xgap = 1-myfrac(x1+0.5);
        ix1 = floor(x1+0.5);
        iy1 = floor(yend);
        brightness1 = (1-myfrac(yend))\*xgap;
        brightness2 = myfrac(yend)\*xgap;
        if( wasexchange )
        {
            setpixel(iy1, ix1, brightness1);
            setpixel(iy1+1, ix1, brightness2);
        }
        else
        {
            setpixel(ix1, iy1, brightness1);
            setpixel(ix1, iy1+1, brightness2);
        }
        yf = yend+grad;
        xend = floor(x2+0.5);
        yend = y2+grad\*(xend-x2);
        xgap = 1-myfrac(x2-0.5);
        ix2 = floor(x2+0.5)
        
        S Offline
        S Offline
        Shiwan Sung
        wrote on last edited by
        #3

        thanks a lot. I'll try...:)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups