c语言bmp加马赛克,[求助]C语言 bmp文件加上水印

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

给一张图片加水印后存起来然后显示出来

有部分源码 求高手帮忙完成~!

#include

#include

/* structure defiens bitmap header */

struct BITMAPFILEHEADER{

unsigned short type;/* type of file (bit map) */

unsigned long size;/* size of file */

unsigned short reserved1;/* */

unsigned short reserved2;/* */

unsigned long offsetbits;/* off set bits */

};

struct BITMAPINFOHEADER{

unsigned long size;/* bitmap size */

unsigned long width;/* width of bitmap */

unsigned long height;/* hight of bitmap */

unsigned short planes;

unsigned short bitcount;

unsigned long compression;/* compression ratio (zero for no compression) */

unsigned long sizeimage;/* size of image */

long xpelspermeter;

long ypelspermeter;

unsigned long colorsused;

unsigned long colorsimportant;

};

struct SINGLE_PIXEL{

unsigned char blue; /* Blue level 0-255 */

unsigned char green;/* Green level 0-255 */

unsigned char red; /* Red level 0-255 */

};

int main()

{

unsigned long int i=0;/* to count pixels readed */

unsigned long int S=0;/* number of pixcels to read */

struct BITMAPFILEHEADER source_head;/* to store file header */

struct BITMAPINFOHEADER source_info;/* to store bitmap info header */

struct SINGLE_PIXEL source_pix;/* to store pixcels */

FILE *fp;/* file pointer for source file */

FILE *Dfp;/* file ponter for distenation file */

if(!(fp=fopen("E:\\c_prac\\WK_canD\\rt.bmp","rb")))/* open in binery read mode */

{

printf("\can not open file");/* prind and exit if file open error */

getch();

exit(-1);

}

Dfp=fopen("dist.bmp","wb");/* opne in binery write mode */

/* read the headers to souirce file */

fread(&source_head,sizeof(struct BITMAPFILEHEADER),1,fp);

fread(&source_info,sizeof(struct BITMAPINFOHEADER),1,fp);

/* write the headers to distenation file */

fwrite(&source_head,sizeof(struct BITMAPFILEHEADER),1,Dfp);

fwrite(&source_info,sizeof(struct BITMAPINFOHEADER),1,Dfp);

/* calucate the number of pix to read */

S=source_info.width*source_info.height;

/* read, modefy and write pixcels */

for(i=1;i<=S;i++)

{

/* read pixcel form source file */

fread(&source_pix,sizeof(struct SINGLE_PIXEL),1,fp);

/*modefy

/* source_pix.green; */

/* source_pix.blue; */

/* source_pix.blue; */

*/

/* write pixcels to distenation file */

fwrite(&source_pix,sizeof(struct SINGLE_PIXEL),1,Dfp);

}

/* close all fiels */

fclose(fp);

fclose(Dfp);

return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值