构造方法1:Color::Color(BYTE r, BYTE g, BYTE b)
构造方法中三个参数分别为RGB值,取值范围(0-255),下面代码呈现在RGB取值下进行线的绘制:
1 Graphics graphics(dc); 2 3 Color clr(255, 0, 0); 4 Color clg(0, 255, 0); 5 Color clb(0, 0, 255); 6 7 Pen pr(clr, 2.0); 8 Pen pg(clg, 2.0); 9 Pen pb(clb, 2.0); 10 11 graphics.DrawLine(&pr, 0, 0, 100, 100); 12 graphics.DrawLine(&pg, 100, 100, 200, 0); 13 graphics.DrawLine(&pb, 200, 0, 300, 100);
构造方法2:Color::Color(BYTE a, BYTE r, BYTE g, BYTE b)
构造方法中四个参数分别为颜色透明度A及RGB值,取值范围(0-255),下面代码呈现在RGB取值下进行线绘制及ARGB取值下进行线绘制的对比:
1 Color clra(100, 255, 0, 0); 2 Color clga(100, 0, 255, 0); 3 Color clba(100, 0, 0, 255); 4 5 Pen pra(clra, 2.0); 6 Pen pga(clga, 2.0); 7 Pen pba(clba, 2.0); 8 9 graphics.DrawLine(&pra, 0, 100, 100, 200); 10 graphics.DrawLine(&pga, 100, 200, 200, 100); 11 graphics.DrawLine(&pba, 200, 100, 300, 200);
标签:200,颜色,Color,graphics,GDI,100,BYTE,255 From: https://www.cnblogs.com/missyou0813/p/17559335.html