📄 bitmap.cpp
字号:
// Bitmap.cpp: implementation of the CBitmap class.
//
//////////////////////////////////////////////////////////////////////
#include "Bitmap.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CBitmap::CBitmap()
{
m_pIBitmap = NULL;
}
CBitmap::CBitmap(IBitmap* pIBitmap)
{
m_pIBitmap = pIBitmap;
}
CBitmap::~CBitmap()
{
}
int CBitmap::BltIn(IBitmap* pDest, int xDest, int yDest, int dx, int dy,
int xSrc, int ySrc, AEERasterOp rop)
{
if (m_pIBitmap == NULL)
{
return EBADCLASS;
}
return IBITMAP_BltIn(pDest, xDest, yDest, dx, dy, m_pIBitmap, xSrc, ySrc, rop);
}
CBitmap* CBitmap::CreateInstance()
{
CBitmap* pObj = new CBitmap();
// 返回实例指针
return pObj;
}
int CBitmap::GetBMPInfo(AEEBitmapInfo& bmpInfo)
{
if (m_pIBitmap == NULL)
{
return EBADCLASS;
}
return IBITMAP_GetInfo(m_pIBitmap, &bmpInfo, sizeof(bmpInfo));
}
int CBitmap::Draw(int nDrawX, int nDrawY, int dx, int dy, int xSrc, int ySrc, AEERasterOp rop)
{
IBitmap* pbmScreen = NULL;
IBitmap* pbmDdb = NULL;
AEEBitmapInfo bi;
CGameApp* pApp = (CGameApp*)GETAPPINSTANCE();
if (pApp == NULL)
{
IBITMAP_Release(pbmDdb);
IBITMAP_Release(pbmScreen);
return 0;
}
pbmScreen = IDISPLAY_GetDestination(((CGameApp*)GETAPPINSTANCE())->m_pIDisplay);
IBITMAP_GetInfo(m_pIBitmap, &bi, sizeof(bi));
IBITMAP_CreateCompatibleBitmap(pbmScreen, &pbmDdb, (uint16)bi.cx, (uint16)bi.cy);
IBITMAP_BltIn(pbmDdb, 0, 0, dx, dy, m_pIBitmap, xSrc, ySrc, AEE_RO_COPY);
IBITMAP_SetTransparencyColor(pbmDdb, pApp->m_pDoc->m_Color);
IBITMAP_BltIn(pbmScreen, nDrawX, nDrawY, dx, dy, pbmDdb, 0, 0, AEE_RO_TRANSPARENT);
IBITMAP_Release(pbmDdb);
IBITMAP_Release(pbmScreen);
return 0;
}
int CBitmap::Draw(boolean bSheer, int nDrawX, int nDrawY, int ndx, int ndy,
int nSrcX, int nSrcY, AEERasterOp rop)
{
IBitmap* pbmScreen = NULL;
IBitmap* pbmDdb = NULL;
AEEBitmapInfo bi;
pbmScreen = IDISPLAY_GetDestination(((CGameApp*)GETAPPINSTANCE())->m_pIDisplay);
IBITMAP_GetInfo(m_pIBitmap, &bi, sizeof(bi));
IBITMAP_CreateCompatibleBitmap(pbmScreen, &pbmDdb, (uint16)bi.cx, (uint16)bi.cy);
IBITMAP_BltIn(pbmDdb, 0, 0, bi.cx, bi.cy, m_pIBitmap, nSrcX, nSrcY, AEE_RO_COPY);
if (bSheer)
IBITMAP_SetTransparencyColor(pbmDdb, ((CGameApp*)GETAPPINSTANCE())->m_pDoc->m_Color);
IBITMAP_BltIn(pbmScreen, nDrawX, nDrawY, ndx, ndy, pbmDdb, nSrcX, nSrcY, rop);
// IDISPLAY_Update (((JFZGameApp*)GETAPPINSTANCE())->m_pIDisplay);
IBITMAP_Release(pbmDdb);
IBITMAP_Release(pbmScreen);
return SUCCESS;
}
void CBitmap::FreeData()
{
if (m_pIBitmap)
IBITMAP_Release(m_pIBitmap);
}
int CBitmap::Load(int nResID)
{
// 首先释放原有资源
// FreeData();
// 载入图片
CGameApp* pApp = NULL;
IShell* pIShell = NULL;
BEGIN_CHECK
{
CHECK_NULL(pApp, (CGameApp*)GETAPPINSTANCE());
CHECK_NULL(pIShell, pApp->m_pIShell);
CHECK_NULL(m_pIBitmap, ISHELL_LoadResBitmap(pIShell, EIDOLON_RES_FILE, nResID));
}
CATCH_CHECK
{
CUSTOM_RELEASE(pApp);
ISHELL_Release(pIShell);
IBITMAP_Release(m_pIBitmap);
return EFAILED;
}
END_CHECK
return SUCCESS;
}
void CBitmap::Release()
{
FreeData();
if (this)
delete this;
}
void CBitmap::DrawBgBitmap(int nX, int nY, int nWidth, int nHeight, int nSrcX, int nSrcY)
{
int nReturn;
// 获取显示的设备
IBitmap* pScreen;
nReturn = IDISPLAY_GetDeviceBitmap(((CGameApp*)GETAPPINSTANCE())->m_pIDisplay, &pScreen);
if (nReturn != SUCCESS)
{
IRELEASE(pScreen, BITMAP);
return;
}
CBitmap bmpDisplay(pScreen);
// 绘图
BltIn(bmpDisplay.m_pIBitmap, nX, nY, nWidth, nHeight, nSrcX, nSrcY, AEE_RO_COPY);
// IDISPLAY_Update(((JFZGameApp*)GETAPPINSTANCE())->m_pIDisplay);
IRELEASE(pScreen, BITMAP);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -