⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graphic24.cpp

📁 一个GNU的开源软件,基于linux下X-Window的flash播放器,工作稳定,方便移植和修改
💻 CPP
📖 第 1 页 / 共 2 页
字号:
                    v = r>>16;                    mix_alpha(point, ramp[v], end_alpha);		}#endif /* FULL_AA */            } else {                while (n--) {                    v = r>>16;                    cp = &ramp[v];                    mix_alpha(point, *cp, cp->alpha);                    point+=BPP;                    r += dr;                }            }        } else {            if (!grad->has_alpha) {#ifdef FULL_AA		if (start_alpha < 255) {                    v = r>>16;                    if (v < 0) v = 0;                    else if (v > 255) v = 255;                    mix_alpha(point, ramp[v], start_alpha);                    point+=BPP;                    r += dr;		    n--;		}#endif /* FULL_AA */                while (n>0) {                    v = r>>16;                    if (v < 0) v = 0;                    else if (v > 255) v = 255;                    *point++ = ramp[v].blue;                    *point++ = ramp[v].green;                    *point++ = ramp[v].red;                    r += dr;						    n--;                }#ifdef FULL_AA		if (end_alpha > 0) {                    v = r>>16;                    if (v < 0) v = 0;                    else if (v > 255) v = 255;                    mix_alpha(point, ramp[v], end_alpha);		}#endif /* FULL_AA */            } else {                while (n--) {                    v = r>>16;                    if (v < 0) v = 0;                    else if (v > 255) v = 255;                    cp = &ramp[v];                    mix_alpha(point, *cp, cp->alpha);                    point+=BPP;                    r += dr;                }            }        }}voidGraphicDevice24::fillLineRG(Gradient *grad, long y, long start, long end){	long X,dx,r,Y,dy;	long dist2;	register long   n;        Color *cp,*ramp;	TYPE *line;								TYPE *point;							        Matrix *m = &grad->imat;        unsigned int start_alpha,end_alpha;	if (clip(y,start,end)) return;        start_alpha = 255 - ((start & (FRAC-1)) << (8-FRAC_BITS));        end_alpha = (end & (FRAC-1)) << (8-FRAC_BITS);        	start /= FRAC;	end /= FRAC;	n = end-start;                X = (long) (m->a * start + m->b * y + m->tx);        Y = (long) (m->c * start + m->d * y + m->ty);        dx = (long) (m->a);        dy = (long) (m->c);        ramp = grad->ramp;										line = (TYPE *)(canvasBuffer + bpl*y);	point = &line[start*BPP];			             if (!grad->has_alpha) {#ifdef FULL_AA		if (start == end) {			dist2 = ((X>>16)*(X>>16))+((Y>>16)*(Y>>16));			if ((unsigned long)dist2 >= 65536) {			    r = 255;								} else {									    r= SQRT[dist2];				}			mix_alpha(point, ramp[r], start_alpha + end_alpha - 255);		} else {		    if (start_alpha < 255) {			dist2 = ((X>>16)*(X>>16))+((Y>>16)*(Y>>16));			if ((unsigned long)dist2 >= 65536) {			    r = 255;								} else {									    r= SQRT[dist2];				}			mix_alpha(point, ramp[r], start_alpha);			point+=BPP;			X += dx;									Y += dy;									n--;		    }#endif /* FULL_AA */		    while (n>0) {								dist2 = ((X>>16)*(X>>16))+((Y>>16)*(Y>>16));			if ((unsigned long)dist2 >= 65536) {			    r = 255;								} else {									    r= SQRT[dist2];				}			*point++ = ramp[r].blue;			*point++ = ramp[r].green;			*point++ = ramp[r].red;			X += dx;									Y += dy;									n--;		    }		#ifdef FULL_AA		    if (end_alpha > 0) {			dist2 = ((X>>16)*(X>>16))+((Y>>16)*(Y>>16));			if ((unsigned long)dist2 >= 65536) {			    r = 255;								} else {									    r= SQRT[dist2];				}			mix_alpha(point, ramp[r], end_alpha);		    }		}#endif /* FULL_AA */        } else {            while (n--) {							dist2 = ((X>>16)*(X>>16))+((Y>>16)*(Y>>16));		if ((unsigned long)dist2 >= 65536) {                    r = 255;							} else {						                    r= SQRT[dist2];			}                cp = &ramp[r];		mix_alpha(point, *cp, cp->alpha);		point+=BPP;		X += dx;								Y += dy;						            }		        }}voidGraphicDevice24::drawLine(long x1, long y1, long x2, long y2, long width){    int n,adr,dx,dy,sx;    Color color;    register int a;    register TYPE *pp;    int alpha;    x1 = (x1) >> FRAC_BITS;    y1 = (y1) >> FRAC_BITS;    x2 = (x2) >> FRAC_BITS;    y2 = (y2) >> FRAC_BITS;        if (y1 > y2 || (y1 == y2 && x1 > x2)) {        long tmp;        tmp=x1;        x1=x2;        x2=tmp;        tmp=y1;        y1=y2;        y2=tmp;    }    if (y1 == y2 && (y1 < clip_rect.ymin || y1 > clip_rect.ymax)) return;    if (x1 == x2 && (x1 < clip_rect.xmin || x1 > clip_rect.xmax)) return;    if (x1 == x2 && y1 == y2) return;	// Bad !!!    if (y1 < clip_rect.ymin && y1 != y2) {	x1 += (x2-x1)*(clip_rect.ymin-y1)/(y2-y1);	y1 = clip_rect.ymin;    }    if (y2 > clip_rect.ymax && y1 != y2) {	x2 -= (x2-x1)*(y2-clip_rect.ymax)/(y2-y1);	y2 = clip_rect.ymax;    }    if (x1 < x2) {	    if (x1 < clip_rect.xmin && x1 != x2) {		y1 += (y2-y1)*(clip_rect.xmin-x1)/(x2-x1);		x1 = clip_rect.xmin;	    }	    if (x2 > clip_rect.xmax && x1 != x2) {		y2 -= (y2-y1)*(x2-clip_rect.xmax)/(x2-x1);		x2 = clip_rect.xmax;	    }    }    if (x1 > x2) {	    if (x2 < clip_rect.xmin && x2 != x1) {		y2 -= (y2-y1)*(clip_rect.xmin-x2)/(x1-x2);		x2 = clip_rect.xmin;	    }	    if (x1 > clip_rect.xmax && x2 != x1) {		y1 += (y2-y1)*(x1-clip_rect.xmax)/(x1-x2);		x1 = clip_rect.xmax;	    }    }    // Check again    if (x1 == x2 && y1 == y2) return;    if (x1 < clip_rect.xmin || x2 < clip_rect.xmin) return;    if (y1 < clip_rect.ymin || y2 < clip_rect.ymin) return;    if (x1 > clip_rect.xmax || x2 > clip_rect.xmax) return;    if (y1 > clip_rect.ymax || y2 > clip_rect.ymax) return;    sx=bpl >> 1;    adr=(y1 * sx + x1);    pp = (TYPE *)canvasBuffer + adr;        dx = x2 - x1;    dy = y2 - y1;    color = foregroundColor;    alpha = foregroundColor.alpha;    if (alpha == ALPHA_OPAQUE) {#define PUTPIXEL() 				\  {						\      *pp++=color.red;		                \      *pp++=color.green;	                \      *pp++=color.blue;		                \  }#define DRAWLINE(dx,dy,inc_1,inc_2) \    n=dx;\    a=2*dy-dx;\    dy=2*dy;\    dx=2*dx-dy;\	 do {\      PUTPIXEL();\			if (a>0) { pp+=(inc_1); a-=dx; }\			else { pp+=(inc_2); a+=dy; }\	 } while (--n >= 0);/* fin macro */  if (dx == 0 && dy == 0) {    PUTPIXEL();  } else if (dx > 0) {    if (dx >= dy) {      DRAWLINE(dx, dy, sx + 1, 1);    } else {      DRAWLINE(dy, dx, sx + 1, sx);    }  } else {    dx = -dx;    if (dx >= dy) {      DRAWLINE(dx, dy, sx - 1, -1);    } else {      DRAWLINE(dy, dx, sx - 1, sx);    }  }#undef DRAWLINE#undef PUTPIXEL    } else {#define PUTPIXEL() 				\  {						\      mix_alpha(pp,color,alpha);	        \  }#define DRAWLINE(dx,dy,inc_1,inc_2) \    n=dx;\    a=2*dy-dx;\    dy=2*dy;\    dx=2*dx-dy;\	 do {\      PUTPIXEL();\		if (a>0) { pp+=(inc_1*BPP); a-=dx; }\		else { pp+=(inc_2*BPP); a+=dy; }\	 } while (--n >= 0);/* fin macro */  if (dx == 0 && dy == 0) {    PUTPIXEL();  } else if (dx > 0) {    if (dx >= dy) {      DRAWLINE(dx, dy, sx + 1, 1);    } else {      DRAWLINE(dy, dx, sx + 1, sx);    }  } else {    dx = -dx;    if (dx >= dy) {      DRAWLINE(dx, dy, sx - 1, -1);    } else {      DRAWLINE(dy, dx, sx - 1, sx);    }  }#undef DRAWLINE#undef PUTPIXEL    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -