• 大小: 349KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: C/C++
  • 标签: c++  验证码  源代码  

资源简介

用c++编写的获取验证码的程序,验证码是通过bmp位图来获取的 含源程序及bmp图片

资源截图

代码片段和文件信息

HGLOBAL WINAPI MergeDIB(LPSTR lpDIB1LPSTR lpDib2)
{
long lWidth1;
long lHeight1;
long lWidth2;
long lHeight2;
long lNewWidth;
long lNewHeight;
    long lNewLineBytes;
LPSTR lpDIBBits1;
LPSTR lpDIBBits2;
LPSTR lpSrc;
HDIB hDIB;
LPSTR lpDst;
LPSTR lpNewDIB;
LPSTR lpNewDIBBits;
LPBITMAPINFIHEADER lpbmi;
LPBITMAPINFIHEADER lpbmc;
long i;
long j;
long i0_1;
long j0_1;
long i0_2;
long j0_2;

long lLineBytes1;
long lLineBytes2;
lpDIBBits1=::FindDIBBits(lpDIB1);
lpDIBBits2=::FindDIBBits(lpDIB2);
lWidth1=::DIBWidth(lpDIB1);
lWidth2=::DIBWidth(lpDIB2);
lLineBytes1=WIDTHBYTES(lWidth1*8);
lLineBytes2=WIDTHBYTES(lWidth2*8);
lHeight1=::DIBHeight(lpDIB1);
lHeight2=::DIBHeight(lpDIB2);

lNewWidth=(long)(::DIBWidth(lpDIB1)+::DIBWidth(lpDIB2));
lNewLineBytes=WIDTHBYTES(lNewWidth*8);
if(lHeight>lHeight2)
{
lNewHeight=(long)(lHeight1);
}
else{
lNewHeight=(long)(lHeight2);
}

hDIB=(HDIB)::GlobalAlloc(GHNDlNewLineBytes*lNewHeight+
*(LPDWORD)lpDIB1+::PaletteSize(lpDIB1));
if(hDIB==NULL)
{
return NULL;
}
lpNewDIB=(char*)::GlobalLock((HGLOBAL)hDIB);
memcpy(lpNewDIBlpDIB1*(LPDWORD)lpDIB1+::PaletteSize(lpDIB1));
lpNewDIBBits=::FindDIBBits(lpNewDIB);
lpbmi=(LPITMAPINFOHEADER)lpNewDIB;
lpbmc=(LPITMAPINFOHEADER)lpNewDIB;
if(IS_WIN30_DIB(lpNewDIB))
{
lpbmi->biWidth=lNewWidth;
lpbmc->biHeight=lNewHeight;
}
else
{
lpbmc->bcWidth=(unsigned short)lNewWidth;
lpbmc->bcHeight=(unsigned short)lNewHeight;
}
for(i=0;i {
for(j=0;j {
lpDst=(char*)lpNewDIBBits+lNewLineBytes*(lNewHeight-1-i)+j;
if(j {
i0_1=(long)(i);
j0_1=(long)(j);
if((j0_1>=0)&&j0_1=0)&&(i0_1 {
lpSrc=(char*)lpDIBBits1+lLineBytes1*(lHeight-1-i0_1)+j0_1;
*lpDst=*lpSrc;
}
else
{
*((unsigned char*)lpDst)=255;
}
}
else
{
i0_2=(long)(i);
j0_2=(long)(j-lWidth1);
if((j0_2>=0)&&(j0_2=0)&&(i0_2 {
lpSrc=(char*)lpDIBBits2+lLineBytes2*(lHeight2-1-i0_2)+j0_2;
*lpDst=*lpSrc;
}
else
{
*((unsigned char*)lpDst)=255;
}
}
}
}
return hDIB;
}






HDIB WINAPI LoadDIBFromResource(CString cImage)
{
//获取实例句柄
HINSTANCE hInst=AfxGetInstanceHandle();
    //装入资源
HRSRC hRes=FindResource(hInstcImage“BINARY“);
if(hRes==NULL)
return NULL;
HGLOBAL hGlob;
CMemFile file;
DWORD dwResSize=SizeofResource(hInsthRes);
file.Attach(LPBYTE)LockResource(hGlob=LoadResource(hInsthRes))dwResSize);
HDIB hDIB=::ReadDIBFile(file);
file.Detach();
Deleteobject(hGlob);
return hDIB;
}


BOOL WINAPI HDIB2BByteArray(HDIB hDibCByteArray* pByteArray)
{
BITMAPFILEHEADER bmfHdr;
LPBITMAPINFOHEADER lpBI;

DWORD dwDIBSize;
if(hDib==NULL)
{
return false;
}
lpBI=(LPBITMAPINFOHEADER)::GlobalLock((HGLOBAL)hDib);
if(lpBI==NULL)
{

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2010-01-18 23:52  200731500212 陈彬 计科7班 c++\
     文件      297984  2010-01-18 23:52  200731500212 陈彬 计科7班 c++\C++.doc
     目录           0  2010-01-13 19:55  200731500212 陈彬 计科7班 c++\ImaConfirmCode\
     文件        3382  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\0.bmp
     文件        4066  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\1.bmp
     文件        6118  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\2.bmp
     文件        5894  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\3.bmp
     文件        6790  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\4.bmp
     文件        6238  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\5.bmp
     文件        6178  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\6.bmp
     文件        6118  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\7.bmp
     文件        6238  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\8.bmp
     文件        6178  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\9.bmp
     文件        4066  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\bin00001.bin
     文件        3382  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\binary1.bin
     文件        6118  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\binary2.bin
     文件        5894  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\binary3.bin
     文件        6790  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\binary4.bin
     文件        6238  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\binary5.bin
     文件        6178  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\binary6.bin
     文件        6118  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\binary7.bin
     文件        6238  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\binary8.bin
     文件        6178  2010-01-11 13:25  200731500212 陈彬 计科7班 c++\ImaConfirmCode\binary9.bin
     目录           0  2010-01-13 19:45  200731500212 陈彬 计科7班 c++\ImaConfirmCode\Debug\
     文件         352  2010-01-12 00:31  200731500212 陈彬 计科7班 c++\ImaConfirmCode\Debug\1.txt
     文件         286  2010-01-12 00:39  200731500212 陈彬 计科7班 c++\ImaConfirmCode\Debug\2.txt
     文件         655  2010-01-12 00:50  200731500212 陈彬 计科7班 c++\ImaConfirmCode\Debug\3.txt
     文件          57  2010-01-13 19:40  200731500212 陈彬 计科7班 c++\ImaConfirmCode\Debug\4.asp
     文件          76  2010-01-13 19:43  200731500212 陈彬 计科7班 c++\ImaConfirmCode\Debug\4.html
     文件          57  2010-01-13 19:40  200731500212 陈彬 计科7班 c++\ImaConfirmCode\Debug\4.txt
     文件          72  2010-01-13 19:45  200731500212 陈彬 计科7班 c++\ImaConfirmCode\Debug\5.html
............此处省略22个文件信息

评论

共有 条评论