please! help me about antialiasing!!!
-
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.:((
-
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.:((
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 routinevoid 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)
-
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 routinevoid 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)
thanks a lot. I'll try...:)