📄 bdi.h
字号:
//Blue Dream Engine V1.1
//BlueDreamImage FileHeader
//by Kylinx
#ifndef BLUE_DREAM_IMAGE_H_
#define BLUE_DREAM_IMAGE_H_
#include<windows.h>
#include<string>
using namespace std;
#include"GLayer.h"
#define D_BDIID 'BI'
#define RGBTo16Bit565(r,g,b) (((r>>3)<<11)|((g>>2)<<5)|(b>>3))
#define GET16Bit565_R(w) ((((unsigned short)w)>>8)&0xff)
#define GET16Bit565_G(w) ((((unsigned short)w)>>3)&0xff)
#define GET16Bit565_B(w) ((((unsigned short)w)&0x1f)<<3)
#define BDI_NOCOLORKEY 0x0
#define BDI_SRCCOLORKEY 0x1
#define BDI_DESTCOLORKEY 0x2
#define BDI_ALPHA 0x3
#define BDI_SRCCKALPHA 0x4
#define BDI_DESTCKALPHA 0x5
#define BDI_ADDITIVE 0x6
#define BDI_SRCCKADDITIVE 0x7
#define BDI_DESTCKADDITIVE 0x8
#define BDI_SUB 0x9
#define BDI_SRCCKSUB 0x10
#define BDI_DESTCKSUB 0x11
#define BDI_GRAY 0x12
#define BDI_SRCCKGRAY 0x13
#define BDI_DESTCKGRAY 0x14
#define BDI_METHOD_TRANS 0x80000000
struct BDIFILEHEADER
{
unsigned short wID;
unsigned char byVersion;
unsigned char byCompress;
unsigned short wWidth;
unsigned short wHeight;
unsigned long dwCompressedImageDataSize;
unsigned long dwOrgDataSize;
};
class GFileLoader;
class GScreen;
class GBDI:public GLayerObject
{
public:
static unsigned char BDI_AlphaBlendTable[16][256][256]; //16级Alpha混合表
static unsigned char BDI_AdditiveTable[256][256]; //Additive表
static unsigned char BDI_SubTable[256][256];
static unsigned char BDI_GrayTable[256]; //灰度表
static void SaveBDITable(const string &strFile);
static void LoadBDITable(GFileLoader*pFileLoader,const string &strFile);
static void InitAlphaBlendTable();
static void InitAdditiveTable();
static void InitSubTable();
static void InitGrayTable();
GBDI();
virtual ~GBDI();
virtual void DrawToScreen(GScreen*pScreen);
void SetColorKeyRGB(unsigned r,unsigned g,unsigned b);
inline void SetColorKeyIndex(unsigned char index){m_byColorKeyIndex=index;}
inline unsigned char GetColorKeyIndex()const{return m_byColorKeyIndex;}
inline int GetWidth()const{return m_nWidth;}
inline int GetHeight()const{return m_nHeight;}
bool LoadBDI(GFileLoader*pFileLoader,const string & strFileName);
void SetShowArea(const RECT*pRect=NULL);
inline RECT GetShadowArea()const{return m_rtShowArea;}
inline void SetPosition(int x,int y){m_position.x=x;m_position.y=y;}
inline void SetPosition(const POINT & pt){m_position=pt;}
inline POINT GetPosition()const{return m_position;}
inline void SetDrawMethod(int nMethod,int nArg){m_nShowMethod=nMethod;m_nArg=nArg;}
inline int GetDrawMethod()const{return m_nShowMethod;}
inline int GetDrawParam()const{return m_nArg;}
void Grayed();
private:
void DrawToScreenNoColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow);
void DrawToScreenSrcColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow);
void DrawToScreenDestColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow,unsigned char byDestColorKey);
void DrawToScreenAlphaNoColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow,int nAlpha);
void DrawToScreenAlphaSrcColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow,int nAlpha);
void DrawToScreenAlphaDestColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow,int nAlpha,unsigned char byDestColorKey);
void DrawToScreenGrayNoColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow);
void DrawToScreenGraySrcColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow);
void DrawToScreenGrayDestColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow,unsigned char byDestColorKey);
void DrawToScreenAdditiveNoColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow);
void DrawToScreenAdditiveSrcColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow);
void DrawToScreenAdditiveDestColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow,unsigned char byDestColorKey);
void DrawToScreenSubNoColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow);
void DrawToScreenSubSrcColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow);
void DrawToScreenSubDestColorKey(unsigned char*pBufDest,int nDestWidth,unsigned char*pBufSour,int nLine,int nRow,unsigned char byDestColorKey);
POINT m_position;
int m_nShowMethod;
int m_nArg;
RECT m_rtShowArea;
BDIFILEHEADER m_bdi;
int m_nWidth;
int m_nHeight;
unsigned char *m_pData;
unsigned char m_byColorKeyIndex;
unsigned char m_byDrawMethod;
unsigned char m_bEnableTrans;
unsigned char m_bRes;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -