⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddrawsystem.h

📁 本原码主要介绍了如何在arm处理器上针对24位真彩位图的处理的方法
💻 H
字号:
// DDrawSystem.h: interface for the CDDrawSystem class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_DDRAWSYSTEM_H__1E152EB4_ED1D_4079_BDD4_773383DD98C8__INCLUDED_)
#define AFX_DDRAWSYSTEM_H__1E152EB4_ED1D_4079_BDD4_773383DD98C8__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <ddraw.h>

#define _CHARACTORBUILDER_


const int WINDOW_SIZE_X = 800;
const int WINDOW_SIZE_Y = 600;

class CDDrawSystem  
{
public:
	CDDrawSystem();
	virtual ~CDDrawSystem();

	BOOL Init(HWND hWnd);
	void Terminate();
	void Clear();
	void Render1(POINT & dst, WORD * src_arr, int size_x, int size_y);
	void Render2(POINT & dst, WORD src_col, int size_x, int size_y);
	void AlphaBlend_Render(POINT & dst, WORD * src_arr, int size_x, int size_y, int percent);
	void DrawPoint(POINT & dst, WORD src_col);
	void Display();

// testing routines are written below.
public:
/*	void TestDraw(int x, int y);
	void TestDraw2();
	void TestDraw3(BYTE percent);
	void TestDraw4();
*/

protected:
	WORD MakeRGB16(BYTE r, BYTE g, BYTE b)
	{
		WORD ret_result = 0;
		__asm
		{
			mov AL, r // load the lower 8 bits of AX
			mov BL, g // load the lower 8 bits of BX
			mov CL, b // load the lower 8 bits of CX
			and AX, 0xf8
			shl AX, 8
			and BX, 0xfc
			shl BX, 3
			and CX, 0xf8
			shr CX, 3
			or  BX, CX
			or  AX, BX
			mov ret_result, AX
		}
		// equivalent to ((((WORD)r&0xf8)<<8)|(((WORD)g&0xfc)<<3)|(((WORD)b&0xf8)>>3));
		return ret_result;
	}

	BYTE GetRed(WORD x)
	{
		BYTE ret_result;
		__asm
		{
			mov AX, x
			and AX, 0xf800
			shr AX, 8
			mov ret_result, AL
		}
		//equivalent to (BYTE)((unsigned int)((x)&0xf800)>>8);
		return ret_result;
	}
	BYTE GetGreen(WORD x)
	{
		BYTE ret_result;
		__asm
		{
			mov AX, x
			and AX, 0x7e0
			shr AX, 3
			mov ret_result, AL
		}
		//equivalent to (BYTE)((unsigned int)((x)&0x7e0)>>3);
		return ret_result;
	}
	BYTE GetBlue(WORD x)
	{
		BYTE ret_result;
		__asm
		{
			mov AX, x
			and AX, 0x1f
			shl AX, 3
			mov ret_result, AL
		}
		//equivalent to (BYTE)((unsigned int)((x)&0x1f)<<3);
		return ret_result;	
	}
	BYTE CalcAlphaBlendVal(WORD dst_val, WORD src_val, BYTE percent)
	{
		// I get some help from GameDev.com There is an excellent article
		// about Alpha Blending. The idea is from this article.
		BYTE ret_result;
		
		WORD perc = percent;
		WORD absol = 256;

		__asm
		{
			mov AX, dst_val    //AX = tr2
			mov CX, perc       //CX = perc;
			mov DX, absol      //DX = 256
			mul CX             //AX = AX * CX = tr2 * perc
			shr AX, 8          //AX = AX >> 8
			mov BX, AX
			sub DX, CX         //DX = 256 - perc;
			mov AX, src_val    //AX = tr
			mul DX             //AX = AX * DX = tr * (256 - perc)
			shr AX, 8          //AX = AX >> 8
			add AX, BX
			mov ret_result, AL
		}
		return ret_result;
	}

protected:
	LPDIRECTDRAW7 m_pDD;
	LPDIRECTDRAWSURFACE7 m_pddsFrontBuffer;
	LPDIRECTDRAWSURFACE7 m_pddsStoreBuffer;
    LPDIRECTDRAWCLIPPER pcClipper;

	HWND hWnd;
};

#endif // !defined(AFX_DDRAWSYSTEM_H__1E152EB4_ED1D_4079_BDD4_773383DD98C8__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -