int main(int argc, const char *argv[])
{
FILE* fp = fopen("/home/ubuntu/图片/233333.bmp","r+");
if(fp == NULL)
{
perror("fopen");
return 1;
}
int a,b,c;
fseek(fp,2,SEEK_SET);
fread(&a,4,1,fp);
printf("图片大小%d\n",a);
fseek(fp,18,SEEK_SET);
fread(&b,4,1,fp);
fread(&c,4,1,fp);
printf("像素点信息%d * %d = %d\n",b,c,b*c);
unsigned char s[3] = {0,0,0};
fseek(fp,54,SEEK_SET);
for(int i=0;i<b;i++)
{
for(int j=0;j<c;j++)
{
fwrite(s,3,1,fp);
}
}
unsigned char s1[3] = {0,0,255};
fseek(fp,54,SEEK_SET);
for(int i=0;i<b;i++)
{
for(int j=0;j<c*2/3;j++)
{
fwrite(s1,3,1,fp);
}
}
unsigned char s2[3] = {0,255,255};
fseek(fp,54,SEEK_SET);
for(int i=0;i<b;i++)
{
for(int j=0;j<c/3;j++)
{
fwrite(s2,3,1,fp);
}
}
fclose(fp);
return 0;
}
02-06
5526
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-26
9万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-30
8850
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-17
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交