下面是一段用c语言获得bmp图片给定坐标点的rgb值的一部分语句,求解释最后一句的含义?
#include<stdio.h>intmain(){intwidth,height,x,y;unsignedshortbitCount;intoffbits;intbi...
#include<stdio.h>
int main()
{
int width,height,x,y;
unsigned short bitCount;
int offbits;
int bitPerLine;
unsigned char data;
FILE* bmpfp = fopen("C:\\Users\\Administrator\\Desktop\\蜡烛图片.bmp","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 = ( (width*3)%4==0 ) ? width*3 : ( (width*3)/4 )*4 + 4;
while(1)
{
printf("请输出坐标:");
scanf("%d%d",&x,&y);
if(x>width||y>height)
return 0;
fseek(bmpfp, 18 + offbits + bitPerLine * y + 3*x , SEEK_SET); 展开
int main()
{
int width,height,x,y;
unsigned short bitCount;
int offbits;
int bitPerLine;
unsigned char data;
FILE* bmpfp = fopen("C:\\Users\\Administrator\\Desktop\\蜡烛图片.bmp","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 = ( (width*3)%4==0 ) ? width*3 : ( (width*3)/4 )*4 + 4;
while(1)
{
printf("请输出坐标:");
scanf("%d%d",&x,&y);
if(x>width||y>height)
return 0;
fseek(bmpfp, 18 + offbits + bitPerLine * y + 3*x , SEEK_SET); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询