资源简介

对图片的数字水印,可以将文本文件嵌入其中

资源截图

代码片段和文件信息

// Dib.cpp: implementation of the CDib class.
//
//////////////////////////////////////////////////////////////////////

#include “StdAfx.h“
#include “Dib.h“

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CDib::CDib()
{
m_hDrawDib=NULL;
m_pDib=NULL;

}

CDib::~CDib()
{
Close();
}

CSize CDib::GetSize()
{
return CSize(((BITMAPINFOHEADER *)m_pDib)->biWidth
 ((BITMAPINFOHEADER *)m_pDib)->biHeight);
}

LONG CDib::GetWidth()
{
return ((BITMAPINFOHEADER *)m_pDib)->biWidth;
}

LONG CDib::GetHeight()
{
return ((BITMAPINFOHEADER *)m_pDib)->biHeight;
}

void CDib::Close()
{
if(m_hDrawDib!=NULL)
{
DrawDibClose(m_hDrawDib);
m_hDrawDib=NULL;
}

if(m_pDib!=NULL)
{
delete m_pDib;
m_pDib=NULL;
}
}

BOOL CDib::Open(const char * pzFileName)
{
// BITMAPFILEHEADER bmpFileHeader;
CFile file;
int nBmpFileHeaderSize;

Close();

//drawdibopen initialize the diradib library and 
//returns a handle for all drawdib operations

if(!(m_hDrawDib=DrawDibOpen()))
goto exit;

  //open and read the DIB file header
nBmpFileHeaderSize=sizeof(BITMAPFILEHEADER);

if(!file.Open(pzFileNameCFile::modeRead | CFile::typeBinary))
goto exit;

if(file.Read((void *)&bmpFileHeadernBmpFileHeaderSize)!=(UINT)nBmpFileHeaderSize)
goto failure;

//validate the DIB file header by checking the first
//two characters for the signature “BM“
if(bmpFileHeader.bfType!=*((WORD *)“BM“))
goto failure;

//allocate a big chuck of global memory to store the DIB
m_pDib=(BYTE *)new char [bmpFileHeader.bfSize-nBmpFileHeaderSize];

//allocate memory fail
if(!m_pDib)
goto failure;

//read the dib into the buffer at a time using ReadHuge
file.ReadHuge(m_pDibbmpFileHeader.bfSize-nBmpFileHeaderSize);

if(((BITMAPINFOHEADER *)m_pDib)->biSizeImage==0)
{
//the application that create this bitmap didn‘t fill
//in the biSizeImage field. Let‘s fill it
//in even though the DrawDib * functions don‘t need it.
BITMAPINFOHEADER *pDib=(BITMAPINFOHEADER *)m_pDib;

//scan lines must be DWord aligned hence the strange bit stuff
pDib->biSizeImage=((((pDib->biWidth*pDib->biBitCount)+31)&~31)>>3)*pDib->biHeight;
}
    if (m_pDibBits!=NULL)
m_pDibBits=NULL;
m_pDibBits=GetBits();

file.Close();
return TRUE;

failure:
file.Close();
exit:
Close();
return FALSE;
}

BOOL CDib::Save(const char * pzFileName)
{
// BITMAPFILEHEADER bmpFileHeader;
CFile file;
int nBmpFileHeaderSize;

  //open and read the DIB file header
nBmpFileHeaderSize=sizeof(BITMAPFILEHEADER);

if(!file.Open(pzFileNameCFile::modeCreate | CFile::modeWrite | CFile::typeBinary))
goto exit;

file.Write(&bmpFileHeadernBmpFileHeaderSize); 

//

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

     文件        211  2006-03-20 22:23  WaterMark0\StdAfx.cpp

     文件       1054  2006-03-20 22:23  WaterMark0\StdAfx.h

     文件       3772  2007-05-18 20:12  WaterMark0\WaterMark.clw

     文件       2105  2006-03-20 22:23  WaterMark0\WaterMark.cpp

     文件        541  2006-03-20 22:23  WaterMark0\WaterMark.dsw

     文件       1357  2006-03-20 22:23  WaterMark0\WaterMark.h

     文件     205824  2007-05-18 20:12  WaterMark0\WaterMark.ncb

     文件       1170  2007-05-18 20:01  WaterMark0\WaterMark.plg

     文件        171  2007-04-10 17:51  WaterMark0\resource.hm

     文件     177356  2003-04-28 09:46  WaterMark0\backimage.bmp

     文件       2196  2007-05-07 10:38  WaterMark0\Extracted.h

     文件       1650  2007-05-08 11:57  WaterMark0\Resource.h

     文件        596  2007-04-11 09:40  WaterMark0\embed_h.txt

     文件       8303  2007-05-07 11:37  WaterMark0\Extracted.cpp

     文件       6791  2007-04-14 15:48  WaterMark0\WaterMarkDlg.cpp

     文件       4809  2007-05-08 12:03  WaterMark0\WaterMark.dsp

     文件       1229  2007-05-08 11:43  WaterMark0\Encrypt.h

     文件       1000  2007-05-08 11:43  WaterMark0\Encrypt.cpp

     文件       1294  2007-05-08 13:34  WaterMark0\EncryptImage.h

     文件        966  2007-05-08 15:04  WaterMark0\Dib.h

     文件       3983  2007-05-08 15:05  WaterMark0\Dib.cpp

     文件       1582  2007-05-08 15:21  WaterMark0\EncryptImage.cpp

     文件       2064  2007-05-08 15:21  WaterMark0\WaterMarkDlg.h

     文件       2484  2007-05-09 13:37  WaterMark0\embed.h

     文件      23876  2007-05-18 19:09  WaterMark0\WaterMark.aps

     文件       9113  2007-05-09 13:38  WaterMark0\WaterMark.rc

     文件       1078  2006-04-01 12:48  WaterMark0\res\FACE.ICO

     文件       1078  2006-03-20 22:23  WaterMark0\res\WaterMark.ico

     文件        401  2006-03-20 22:23  WaterMark0\res\WaterMark.rc2

    ..A.SH.     78336  2007-05-23 10:39  WaterMark0\Pic\Thumbs.db

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

评论

共有 条评论