www.pudn.com > SDKSkin.rar > RNHBitmap.cpp
// RNHBitmap.cpp
#include "stdafx.h"
#include "RNHBitmap.h"
RNHBitmap::RNHBitmap()
{
m_bDel = false;
Release();
}
RNHBitmap::RNHBitmap(HBITMAP hBitmap_,bool bDel)
{
m_bDel = bDel;
Attach(hBitmap_,bDel);
}
RNHBitmap::RNHBitmap(LPCTSTR bmpFilename,bool bDel)
{
m_bDel = bDel;
Attach(bmpFilename,bDel);
}
HBITMAP RNHBitmap::Detach()
{
HBITMAP tmBmp = m_hBitmap;
m_hBitmap = 0;
return tmBmp;
}
RNHBitmap& RNHBitmap::Attach(HBITMAP hBitmap_,bool bDel)
{
Release();
m_bDel = bDel;
m_hBitmap = hBitmap_;
AttachBitmap();
return *this;
}
RNHBitmap& RNHBitmap::Attach(LPCTSTR bmpFilename,bool bDel)
{
Release();
m_bDel = bDel;
m_hBitmap = (HBITMAP)LoadImage(NULL,
bmpFilename,
IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
AttachBitmap();
return *this;
}
RNHBitmap::~RNHBitmap()
{
Release();
}
int RNHBitmap::Width()
{
return m_bitmap.bmWidth;
}
int RNHBitmap::Height()
{
return m_bitmap.bmHeight;
}
DWORD RNHBitmap::Length()
{
return m_bitmap.bmWidthBytes * m_bitmap.bmHeight;
}
void RNHBitmap::AttachBitmap()
{
ZeroMemory(&m_bitmap,sizeof(BITMAP));
if(0 != m_hBitmap)
{
GetObject(m_hBitmap,sizeof(BITMAP),&m_bitmap);
}
}