int main(int argc, const char *argv[])
{
FILE* fp=fopen("./zuoye.bmp","r");
int bmp_size=0;
int width=0;
int heigth=0;
fseek(fp,2,SEEK_SET);
fread(&bmp_size,4,1,fp);
printf("图片大小为:%d\n",bmp_size);
fseek(fp,18,SEEK_SET);
fread(&width,4,1,fp);
fread(&heigth,4,1,fp);
printf("图片信息宽度为:%d长度为:%d\n",width,heigth);
unsigned char bgr1[3]={0,0,255};//hong
unsigned char bgr2[3]={0,203,255};//huang
unsigned char bgr3[3]={0,0,0};//hei
fclose(fp);
FILE* wfp=fopen("./zuoye.bmp","r+");
fseek(wfp,54,SEEK_SET);
for(int i=0;i<(width/3);i++)
{
for(int j=0;j<heigth;j++)
{
fwrite(bgr2,3,1,wfp);
}
}
for(int i=(width/3);i<((width/3)*2);i++)
{
for(int j=0;j<heigth;j++)
{
fwrite(bgr1,3,1,wfp);
}
}
for(int i=((width/3)*2);i<width;i++)
{
for(int j=0;j<heigth;j++)
{
fwrite(bgr3,3,1,wfp);
}
}
fclose(wfp);
return 0;
}
5.7啊啊啊啊啊
最新推荐文章于 2024-08-28 09:29:32 发布