forked from metin2/client
Solution refactoring and restructuring, removed Boost dependency, removed unused tools
This commit is contained in:
92
src/EterLib/GrpImage.cpp
Normal file
92
src/EterLib/GrpImage.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
#include "StdAfx.h"
|
||||
#include "GrpImage.h"
|
||||
|
||||
CGraphicImage::CGraphicImage(const char * c_szFileName, DWORD dwFilter) :
|
||||
CResource(c_szFileName),
|
||||
m_dwFilter(dwFilter)
|
||||
{
|
||||
m_rect.bottom = m_rect.right = m_rect.top = m_rect.left = 0;
|
||||
}
|
||||
|
||||
CGraphicImage::~CGraphicImage()
|
||||
{
|
||||
}
|
||||
|
||||
bool CGraphicImage::CreateDeviceObjects()
|
||||
{
|
||||
return m_imageTexture.CreateDeviceObjects();
|
||||
}
|
||||
|
||||
void CGraphicImage::DestroyDeviceObjects()
|
||||
{
|
||||
m_imageTexture.DestroyDeviceObjects();
|
||||
}
|
||||
|
||||
CGraphicImage::TType CGraphicImage::Type()
|
||||
{
|
||||
static TType s_type = StringToType("CGraphicImage");
|
||||
return s_type;
|
||||
}
|
||||
|
||||
bool CGraphicImage::OnIsType(TType type)
|
||||
{
|
||||
if (CGraphicImage::Type() == type)
|
||||
return true;
|
||||
|
||||
return CResource::OnIsType(type);
|
||||
}
|
||||
|
||||
int CGraphicImage::GetWidth() const
|
||||
{
|
||||
return m_rect.right - m_rect.left;
|
||||
}
|
||||
|
||||
int CGraphicImage::GetHeight() const
|
||||
{
|
||||
return m_rect.bottom - m_rect.top;
|
||||
}
|
||||
|
||||
const CGraphicTexture& CGraphicImage::GetTextureReference() const
|
||||
{
|
||||
return m_imageTexture;
|
||||
}
|
||||
|
||||
CGraphicTexture* CGraphicImage::GetTexturePointer()
|
||||
{
|
||||
return &m_imageTexture;
|
||||
}
|
||||
|
||||
const RECT& CGraphicImage::GetRectReference() const
|
||||
{
|
||||
return m_rect;
|
||||
}
|
||||
|
||||
bool CGraphicImage::OnLoad(int iSize, const void * c_pvBuf)
|
||||
{
|
||||
if (!c_pvBuf)
|
||||
return false;
|
||||
|
||||
m_imageTexture.SetFileName(CResource::GetFileName());
|
||||
|
||||
// Ư<><C6AF> <20><>ǻ<EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD> Unknown<77><6E><EFBFBD><EFBFBD> '<27><>'<27>ϸ<EFBFBD> ƨ<><C6A8><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>-_-; -<2D><><EFBFBD><EFBFBD>
|
||||
if (!m_imageTexture.CreateFromMemoryFile(iSize, c_pvBuf, D3DFMT_UNKNOWN, m_dwFilter))
|
||||
return false;
|
||||
|
||||
m_rect.left = 0;
|
||||
m_rect.top = 0;
|
||||
m_rect.right = m_imageTexture.GetWidth();
|
||||
m_rect.bottom = m_imageTexture.GetHeight();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGraphicImage::OnClear()
|
||||
{
|
||||
// Tracef("Image Destroy : %s\n", m_pszFileName);
|
||||
m_imageTexture.Destroy();
|
||||
memset(&m_rect, 0, sizeof(m_rect));
|
||||
}
|
||||
|
||||
bool CGraphicImage::OnIsEmpty() const
|
||||
{
|
||||
return m_imageTexture.IsEmpty();
|
||||
}
|
Reference in New Issue
Block a user