位图像素的颜色
1 2 0 0 2 3 127 196 200 1 2 3 0 2 3 8 16 32 64 0 255 128 8 48 32 64 255 0 0 12 47 13 48 14 64 0 0
127 196 200 255 255 255 0 255 128 255 0 0 255 0 0
1 #include <iostream>
2 using namespace std; 3 struct Point{ 4 double x,y; 5 }; 6 struct Plg{ 7 Point p1,p2; 8 int r,g,b; 9 }; 10 int main() 11 { 12 int n,m; 13 while(scanf("%d%d",&n,&m)!=EOF){ 14 if(n==0 && m==0) break; 15 Plg pl[1010]; //多边形
16 int i,j; 17 for(i=1;i<=n;i++) //输入多边形及颜色
18 scanf("%lf%lf%lf%lf%d%d%d",&pl[i].p1.x,&pl[i].p1.y,&pl[i].p2.x,&pl[i].p2.y,&pl[i].r,&pl[i].g,&pl[i].b); 19 for(i=1;i<=m;i++){ 20 Point t; 21 scanf("%lf%lf",&t.x,&t.y); 22 int r=255,b=255,g=255; 23 for(j=1;j<=n;j++){ 24 if(pl[j].p1.x<=t.x && t.x<=pl[j].p2.x &&
25 pl[j].p1.y<=t.y && t.y<=pl[j].p2.y){ //在多边形内,刷新颜色
26 r = pl[j].r; 27 b = pl[j].b; 28 g = pl[j].g; 29 } 30 } 31 printf("%d %d %d\n",r,g,b); 32 } 33 } 34 return 0; 35 }
Freecode : www.cnblogs.com/yym2013