快讯

在BMP文件中隐藏信息

2004-02-14 09:34  出处:PConline  作者:网上收集  责任编辑:zwg 

/*********************************************************************/ /******************************BMP HANDLER ROUTINES*******************/ int readBitmapFile(FILE* bmpfile, BITMAP* datazone) { unsigned char tmpchar; int dataread; int i; long offsetToRaster=0; /* Get Signature */ datazone- >signature=(char*)calloc(3,sizeof(char)); datazone- >signature[2]='\0'; dataread=fscanf(bmpfile,"%c",&tmpchar); if (dataread==1) datazone- >signature[0]=tmpchar; dataread=fscanf(bmpfile,"%c",&tmpchar); if (dataread==1) datazone- >signature[1]=tmpchar; /* Get Filesize */ datazone- >filesize=streamToLong(bmpfile); /* Skip reserved section */ for (i=0; i< 4; i++) dataread=fscanf(bmpfile,"%c",&tmpchar); /* Get Raster Offset */ offsetToRaster=streamToLong(bmpfile); /* Skip size of infoheader (always=40 anyway) */ for (i=0; i< 4; i++) dataread=fscanf(bmpfile,"%c",&tmpchar); /* Get Bitmap width (x_size) */ datazone- >x_size=streamToLong(bmpfile); /* Get Bitmap height (y_size) */ datazone- >y_size=streamToLong(bmpfile); /* Get number bitplanes */ dataread=fscanf(bmpfile,"%c",&tmpchar); if (dataread==1) datazone- >bitplanes=((unsigned int)tmpchar*1); dataread=fscanf(bmpfile,"%c",&tmpchar); if (dataread==1) datazone- >bitplanes+=((unsigned int)tmpchar*256); /* Get bits per pixel */ dataread=fscanf(bmpfile,"%c",&tmpchar); if (dataread==1) datazone- >bpp=((unsigned int)tmpchar*1); dataread=fscanf(bmpfile,"%c",&tmpchar); if (dataread==1) datazone- >bpp+=((unsigned int)tmpchar*256); /* Get Compression */ datazone- >compression=streamToLong(bmpfile); /* Get Compressed Image Size */ datazone- >compresssize=streamToLong(bmpfile); /* Get X pix per metre */ datazone- >x_pix_per_metre=streamToLong(bmpfile); /* Get Y pix per metre */ datazone- >y_pix_per_metre=streamToLong(bmpfile); /* Get Colours Used */ datazone- >colours=streamToLong(bmpfile); /* Get num important colours*/ datazone- >cols_important=streamToLong(bmpfile); if (datazone- >bpp< =8) { int numcolors=0; switch(datazone- >bpp) { case 1: numcolors=1; case 4: numcolors=16; case 8: numcolors=256; } for (i=0; i< numcolors; i++) { unsigned char readchar; /* RED */ if (fscanf(bmpfile,"%c",&readchar) >0) { if (!putToHeap(readchar,datazone- >palette)) return FALSE; } /* GREEN */ if (fscanf(bmpfile,"%c",&readchar) >0) { if (!putToHeap(readchar,datazone- >palette)) return FALSE; } /* BLUE */ if (fscanf(bmpfile,"%c",&readchar) >0) { if (!putToHeap(readchar,datazone- >palette)) return FALSE; } /* RESERVED */ if (fscanf(bmpfile,"%c",&readchar) >0) { if (!putToHeap(readchar,datazone- >palette)) return FALSE; } } } if (fseek(bmpfile,offsetToRaster,SEEK_SET)==0) if(!streamFileToHeap(bmpfile,datazone- >raster)) return FALSE; return TRUE;}
键盘也能翻页,试试“← →”键
IT热词搜索 来源:360新闻
相关文章

相关软件:

腾讯QQ2012
大小:52.93 MB 授权:免费
腾讯QQ2012
立即下载
腾讯QQ2013
大小:49.32 MB 授权:免费
腾讯QQ2013
立即下载