BMP图像的信息隐藏


BMP图像的信息隐藏BMP图像的信息隐藏BMP图像的信息隐藏BMP图像的信息隐藏
资源截图
代码片段和文件信息
#include
#include
#include“math.h“
#include“lsb.h“
#include“windows.h“

using namespace std;

//定义构造函数
LSB::LSB()
{
m_bitmapfileheader=new BITMAPFILEHEADER;
m_bitmapinfoheader=new BITMAPINFOHEADER;
m_colortable=NULL;
m_data=NULL;
max_bitmaplength=0;

char *strByteBuffer=NULL;
int hidelength=0;
}
//定义析构函数
LSB::~LSB()
{
delete m_bitmapfileheader;
delete m_bitmapinfoheader;
delete m_colortable;
delete m_data;
delete strByteBuffer;
}

//读取BMP图像到内存
void LSB::readBMP(char *bmpname)
{
ifstream file;
char m_bmpname[255];
strcpy(m_bmpnamebmpname);
int biBitCount; //BMP图像的深度

file.open(m_bmpname ios::out | ios::in | ios::binary);
file.read((char *)m_bitmapfileheadersizeof(BITMAPFILEHEADER));
file.read((char *)m_bitmapinfoheadersizeof(BITMAPINFOHEADER));
    biBitCount=m_bitmapinfoheader->biBitCount;
if(biBitCount==2||biBitCount==4||biBitCount==8)
{
m_colortable=new RGBQUAD[pow(2biBitCount)];
file.read((char *)m_colortablepow(2biBitCount)*sizeof(RGBQUAD));
}
m_data=new char[(m_bitmapinfoheader->biSizeImage+1)];
file.read((char *)m_datam_bitmapinfoheader->biSizeImage);
max_bitmaplength=(m_bitmapinfoheader->biSizeImage)/8;
cout<<“该BMP图像最大能隐藏的信息量为: “<}

//读取隐藏文件到缓冲区
void LSB::readHide(char *hidename)
{
ifstream hidefile;
hidefile.open(hidename ios::binary | ios::in);
hidefile.seekg(0hidefile.end);
hidelength=hidefile.tellg();
cout<<“该隐藏文件信息量为: “<
//判断是否能完成信息隐藏,若不能退出程序
if(max_bitmaplength {
cout<<“隐藏的文件信息量过大“< return;
}

//将隐藏文件信息读入缓冲区
strByteBuffer=new char[hidelength];
hidefile.seekg(0hidefile.beg);
hidefile.read((char *)strByteBufferhidelength);
hidefile.close();
}
//创建已经隐藏了信息的BMP图像
void LSB::createBMP(char *createbmp)
{
ofstream dibFile;
int biBitCount;
dibFile.open(createbmp ios::out | ios::binary);

dibFile.write((char*)m_bitmapfileheadersizeof(BITMAPFILEHEADER));
dibFile.write((char*)m_bitmapinfoheadersizeof(BITMAPINFOHEADER));
    biBitCount=m_bitmapinfoheader->biBitCount;
if(biBitCount==2||biBitCount==4||biBitCount==8)
{
dibFile.write((char *)m_colortablepow(2biBitCount)*sizeof(RGBQUAD));
}
dibFile.write((char *)m_datam_bitmapinfoheader->biSizeImage);
dibFile.close();
cout<<“隐藏信息完毕“<}

//创建提取信息的文件
void LSB::createFile(char *getfilechar *strByteBufferint HideLength)
{
ofstream outfile;
outfile.open(getfile ios::out | ios::binary);
outfile.write((char *)strByteBufferHideLength);
outfile.close();
delete strByteBuffer;
cout<<“信息已提取“<}

//用LSB算法隐藏文件
void LSB::LSBhide(char *bmpnamechar *hidename)
{
    int ij;
char createbmp[255];

readBMP(bmpname);
readHide(hidename);

//BMP图像数据区的前32个字节用来记录隐藏文件数据长度
for(i=0;i<32;i++)
{
m_data[i]= ((hidelength>>(31-i)) & 0x00000001)+(m_data[i]&0xfe);
}

//基于LSB算法隐藏文件信息
for(i=0;i {

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        985  2010-04-18 23:06  单张BMP图像的信息隐藏lsb.h

     文件        533  2010-04-18 18:22  单张BMP图像的信息隐藏 ao.txt

     文件       3974  2010-04-18 23:06  单张BMP图像的信息隐藏lsb.cpp

     文件        916  2010-04-18 23:10  单张BMP图像的信息隐藏main.cpp

     文件      48640  2010-04-18 23:10  单张BMP图像的信息隐藏单张BMP图像的信息隐藏.opt

     文件        550  2010-04-17 21:52  单张BMP图像的信息隐藏单张BMP图像的信息隐藏.dsw

     文件      50176  2010-04-18 23:10  单张BMP图像的信息隐藏单张BMP图像的信息隐藏.ncb

     文件        966  2010-04-18 23:10  单张BMP图像的信息隐藏单张BMP图像的信息隐藏.plg

     文件       4565  2010-04-17 23:23  单张BMP图像的信息隐藏单张BMP图像的信息隐藏.dsp

     文件      41984  2010-04-18 12:43  单张BMP图像的信息隐藏lsb.ncb

     文件       1498  2010-04-18 12:43  单张BMP图像的信息隐藏lsb.plg

     文件       3365  2010-04-18 12:43  单张BMP图像的信息隐藏lsb.dsp

     文件      48640  2010-04-18 12:43  单张BMP图像的信息隐藏lsb.opt

     文件        514  2010-04-18 12:43  单张BMP图像的信息隐藏lsb.dsw

     文件     462654  2010-04-10 18:40  单张BMP图像的信息隐藏1.bmp

     文件      25600  2009-11-07 10:54  单张BMP图像的信息隐藏 ao.doc

     文件      25600  2010-04-18 16:37  单张BMP图像的信息隐藏createbmp

     文件     205824  2010-04-18 23:10  单张BMP图像的信息隐藏Debugvc60.idb

     文件     151552  2010-04-18 23:10  单张BMP图像的信息隐藏Debugvc60.pdb

     文件    1997944  2010-04-17 22:14  单张BMP图像的信息隐藏Debug单张BMP图像的信息隐藏.pch

     文件     916072  2010-04-18 23:10  单张BMP图像的信息隐藏Debug单张BMP图像的信息隐藏.ilk

     文件     310900  2010-04-18 23:06  单张BMP图像的信息隐藏Debuglsb.obj

     文件     208689  2010-04-18 23:10  单张BMP图像的信息隐藏Debugmain.obj

     文件    1451008  2010-04-18 23:10  单张BMP图像的信息隐藏Debug单张BMP图像的信息隐藏.pdb

     文件    5473304  2010-04-18 12:40  单张BMP图像的信息隐藏Debuglsb.pch

     文件     626810  2010-04-18 23:10  单张BMP图像的信息隐藏Debug单张BMP图像的信息隐藏.exe

     目录          0  2010-04-19 16:26  单张BMP图像的信息隐藏Debug

     目录          0  2010-04-19 16:26  单张BMP图像的信息隐藏

----------- ---------  ---------- -----  ----

             12063263                    28

............此处省略1个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)