右键吸管工具组,选择颜色取样器工具,在你需要知道RGB值的位置单击。
打开信息面板,快捷键F8。即可看到颜色信息。win api 函数 :getwindowpixel()别忘加分呢。
#include<stdioh>
int main()
{
int width,height,x,y;
unsigned short bitCount;
int offbits;
int bitPerLine;
unsigned char data;
FILE bmpfp = fopen("E:\\风景\\风景1bmp","rb");
fseek(bmpfp,18,SEEK_SET);
fread(&width,sizeof(int),1,bmpfp);
fread(&height,sizeof(int),1,bmpfp);
printf("width : %d , height : %d\n",width,height);
fseek(bmpfp,2,SEEK_CUR);
fread(&bitCount,sizeof(bitCount),1,bmpfp);
fseek(bmpfp,10,SEEK_SET);
fread(&offbits,sizeof(int),1,bmpfp);
if(bitCount==24){
bitPerLine = ( (width3)%4==0 ) width3 : ( (width3)/4 )4 + 4;
while(1){
printf("请输出坐标:");
scanf("%d%d",&x,&y);
if(x>width||y>height) return 0;
fseek(bmpfp, 18 + offbits + bitPerLine y + 3x , SEEK_SET);
fread(&data,sizeof(data),1,bmpfp);
printf("该点蓝色分量:%d",data);
fread(&data,sizeof(data),1,bmpfp);
printf("该点绿色分量:%d",data);
fread(&data,sizeof(data),1,bmpfp);
printf("该点红色分量:%d\n",data);
}
}else{
printf("不是真彩位图!");
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)