|
/**************************************************************
LCD屏幕显示垂直翻转
// LCD display is flipped vertically
// But, think the algorithm by mathematics point.
// 3I2
// 4 I 1
// --+-- <-8 octants mathematical cordinate
// 5 I 8
// 6I7
**************************************************************/
void Glib_Line(int x1,int y1,int x2,int y2,int color)
{
int dx,dy,e;
dx=x2-x1;
dy=y2-y1;
if(dx>=0)
{
if(dy >= 0) // dy>=0 //dx dy 都大于零,可以确定直线斜率大于零
{
if(dx>=dy) // 1/8 octant 斜率小于1
{
e=dy-dx/2;
while(x1<=x2)
{
PutPixel(x1,y1,color);
if(e>0)
{y1+=1;e-=dx;}
x1+=1;
e+=dy;
}
}
这是TQ2440开发板LCD裸机程序画直线程序的一部分,其中e=dy-dx/2;
怎么去理解呢,请大神?
还有无看了三个常用算法:
数值微分法(DDA)
中点画线法
Bresenham算法。那天嵌用的是Bresenham算法吗,不太像 |
|