![](https://img-blog.csdnimg.cn/direct/1d19f50da9eb4170ab3adfe708a6620d.png)
int main(int argc, const char *argv[])
{
FILE* fp = fopen("./6I96.bmp","r");
int bmp_size=0;
int kuan=0;
int gao=0;
fseek(fp,2,SEEK_SET);
fread(&bmp_size,4,1,fp);
fseek(fp,18,SEEK_SET);
fread(&kuan,4,1,fp);
fread(&gao,4,1,fp);
printf("图片大小%d 宽%d 高%d\n",bmp_size,kuan,gao);
fclose(fp);
unsigned char red[3] = {0,0,225};
unsigned char blu[3] = {225,0,0};
unsigned char gre[3] = {0,255,0};
unsigned char bla[3] = {0,0,0};
unsigned char wit[3] = {225,225,225};
unsigned char yel[3] = {0,225,225};
int er=+(gao/3);
int san=54+((gao/3)*2);
fp = fopen("6I96.bmp","r+");
fseek(fp,54,SEEK_SET);
for(int i=0;i<kuan;i++)
{
for(int j=0;j<er;j++)
{
fwrite(red,3,1,fp);
}
}
for(int i=0;i<kuan;i++)
{
for(int j=0;j<er;j++)
{
fwrite(yel,3,1,fp);
}
}
for(int i=0;i<kuan;i++)
{
for(int j=0;j<er;j++)
{
fwrite(bla,3,1,fp);
}
}
fclose(fp);
return 0;
}
int main(int argc, const char *argv[])
{
struct stat buf={0};
stat(argv[1],&buf);
mode_t mode=buf.st_mode;
if((mode|S_IWUSR)==mode)
{chmod(argv[1],mode&~S_IWUSR);
system("ls -l");}
else
{chmod(argv[1],mode|S_IWUSR);
system("ls -l");}
return 0;
}