diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-04-09 18:12:59 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-04-09 18:12:59 +0400 |
commit | efbc9d9043ff8ff92716ddd00a5f61412d535593 (patch) | |
tree | 8f3e621f756cf1f5b4d64d97964c7e7abd8aaf08 /src/apps/mplayerc/CGdiPlusBitmap.h | |
parent | df6b139a6d9027156f614b68687e039e3a5854db (diff) |
revert r1783
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1785 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/apps/mplayerc/CGdiPlusBitmap.h')
-rw-r--r-- | src/apps/mplayerc/CGdiPlusBitmap.h | 198 |
1 files changed, 81 insertions, 117 deletions
diff --git a/src/apps/mplayerc/CGdiPlusBitmap.h b/src/apps/mplayerc/CGdiPlusBitmap.h index ec561629e..dd46ac2d0 100644 --- a/src/apps/mplayerc/CGdiPlusBitmap.h +++ b/src/apps/mplayerc/CGdiPlusBitmap.h @@ -3,141 +3,105 @@ class CGdiPlusBitmap
{
public:
- Gdiplus::Bitmap* m_pBitmap;
+ Gdiplus::Bitmap* m_pBitmap;
public:
- CGdiPlusBitmap()
- {
- m_pBitmap = NULL;
- }
- CGdiPlusBitmap(LPCWSTR pFile)
- {
- m_pBitmap = NULL;
- Load(pFile);
- }
- virtual ~CGdiPlusBitmap()
- {
- Empty();
- }
-
- void Empty()
- {
- delete m_pBitmap;
- m_pBitmap = NULL;
- }
-
- bool Load(LPCWSTR pFile)
- {
- Empty();
- m_pBitmap = Gdiplus::Bitmap::FromFile(pFile);
- return m_pBitmap->GetLastStatus() == Gdiplus::Ok;
- }
-
- operator Gdiplus::Bitmap*() const
- {
- return m_pBitmap;
- }
+ CGdiPlusBitmap() { m_pBitmap = NULL; }
+ CGdiPlusBitmap(LPCWSTR pFile) { m_pBitmap = NULL; Load(pFile); }
+ virtual ~CGdiPlusBitmap() { Empty(); }
+
+ void Empty() { delete m_pBitmap; m_pBitmap = NULL; }
+
+ bool Load(LPCWSTR pFile)
+ {
+ Empty();
+ m_pBitmap = Gdiplus::Bitmap::FromFile(pFile);
+ return m_pBitmap->GetLastStatus() == Gdiplus::Ok;
+ }
+
+ operator Gdiplus::Bitmap*() const { return m_pBitmap; }
};
class CGdiPlusBitmapResource : public CGdiPlusBitmap
{
protected:
- HGLOBAL m_hBuffer;
+ HGLOBAL m_hBuffer;
public:
- CGdiPlusBitmapResource()
- {
- m_hBuffer = NULL;
- }
- CGdiPlusBitmapResource(LPCTSTR pName, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
- {
- m_hBuffer = NULL;
- Load(pName, pType, hInst);
- }
- CGdiPlusBitmapResource(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
- {
- m_hBuffer = NULL;
- Load(id, pType, hInst);
- }
- CGdiPlusBitmapResource(UINT id, UINT type, HMODULE hInst = NULL)
- {
- m_hBuffer = NULL;
- Load(id, type, hInst);
- }
- virtual ~CGdiPlusBitmapResource()
- {
- Empty();
- }
-
- void Empty();
-
- bool Load(LPCTSTR pName, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL);
- bool Load(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
- {
- return Load(MAKEINTRESOURCE(id), pType, hInst);
- }
- bool Load(UINT id, UINT type, HMODULE hInst = NULL)
- {
- return Load(MAKEINTRESOURCE(id), MAKEINTRESOURCE(type), hInst);
- }
+ CGdiPlusBitmapResource() { m_hBuffer = NULL; }
+ CGdiPlusBitmapResource(LPCTSTR pName, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
+ { m_hBuffer = NULL; Load(pName, pType, hInst); }
+ CGdiPlusBitmapResource(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
+ { m_hBuffer = NULL; Load(id, pType, hInst); }
+ CGdiPlusBitmapResource(UINT id, UINT type, HMODULE hInst = NULL)
+ { m_hBuffer = NULL; Load(id, type, hInst); }
+ virtual ~CGdiPlusBitmapResource() { Empty(); }
+
+ void Empty();
+
+ bool Load(LPCTSTR pName, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL);
+ bool Load(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
+ { return Load(MAKEINTRESOURCE(id), pType, hInst); }
+ bool Load(UINT id, UINT type, HMODULE hInst = NULL)
+ { return Load(MAKEINTRESOURCE(id), MAKEINTRESOURCE(type), hInst); }
};
inline
void CGdiPlusBitmapResource::Empty()
{
- CGdiPlusBitmap::Empty();
- if(m_hBuffer)
- {
- ::GlobalUnlock(m_hBuffer);
- ::GlobalFree(m_hBuffer);
- m_hBuffer = NULL;
- }
+ CGdiPlusBitmap::Empty();
+ if (m_hBuffer)
+ {
+ ::GlobalUnlock(m_hBuffer);
+ ::GlobalFree(m_hBuffer);
+ m_hBuffer = NULL;
+ }
}
inline
bool CGdiPlusBitmapResource::Load(LPCTSTR pName, LPCTSTR pType, HMODULE hInst)
{
- Empty();
-
- HRSRC hResource = ::FindResource(hInst, pName, pType);
- if(!hResource)
- return false;
-
- DWORD imageSize = ::SizeofResource(hInst, hResource);
- if(!imageSize)
- return false;
-
- const void* pResourceData = ::LockResource(::LoadResource(hInst, hResource));
- if(!pResourceData)
- return false;
-
- m_hBuffer = ::GlobalAlloc(GMEM_MOVEABLE, imageSize);
- if(m_hBuffer)
- {
- void* pBuffer = ::GlobalLock(m_hBuffer);
- if(pBuffer)
- {
- CopyMemory(pBuffer, pResourceData, imageSize);
-
- IStream* pStream = NULL;
- if(::CreateStreamOnHGlobal(m_hBuffer, FALSE, &pStream) == S_OK)
- {
- m_pBitmap = Gdiplus::Bitmap::FromStream(pStream);
- pStream->Release();
- if(m_pBitmap)
- {
- if(m_pBitmap->GetLastStatus() == Gdiplus::Ok)
- return true;
-
- delete m_pBitmap;
- m_pBitmap = NULL;
- }
- }
- ::GlobalUnlock(m_hBuffer);
- }
- ::GlobalFree(m_hBuffer);
- m_hBuffer = NULL;
- }
- return false;
+ Empty();
+
+ HRSRC hResource = ::FindResource(hInst, pName, pType);
+ if (!hResource)
+ return false;
+
+ DWORD imageSize = ::SizeofResource(hInst, hResource);
+ if (!imageSize)
+ return false;
+
+ const void* pResourceData = ::LockResource(::LoadResource(hInst, hResource));
+ if (!pResourceData)
+ return false;
+
+ m_hBuffer = ::GlobalAlloc(GMEM_MOVEABLE, imageSize);
+ if (m_hBuffer)
+ {
+ void* pBuffer = ::GlobalLock(m_hBuffer);
+ if (pBuffer)
+ {
+ CopyMemory(pBuffer, pResourceData, imageSize);
+
+ IStream* pStream = NULL;
+ if (::CreateStreamOnHGlobal(m_hBuffer, FALSE, &pStream) == S_OK)
+ {
+ m_pBitmap = Gdiplus::Bitmap::FromStream(pStream);
+ pStream->Release();
+ if (m_pBitmap)
+ {
+ if (m_pBitmap->GetLastStatus() == Gdiplus::Ok)
+ return true;
+
+ delete m_pBitmap;
+ m_pBitmap = NULL;
+ }
+ }
+ ::GlobalUnlock(m_hBuffer);
+ }
+ ::GlobalFree(m_hBuffer);
+ m_hBuffer = NULL;
+ }
+ return false;
}
|