bmprectcombo.cs

来自「这是网上下载的很好的串口发短信的程序! 是用VC++来做的」· CS 代码 · 共 67 行

CS
67
字号
using System;
using System.Collections.Specialized;
using Microsoft.DirectX.DirectDraw;

namespace DDGameHelper
{
	/// <summary>
	/// BitmapObject 与 RectangleArray 的组合体(包含 DirectDraw 相关定义及操作 ,用于图像绘制)
	/// </summary>
	public class BmpRectCombo
	{
		protected BitmapObject _bitmapObject;
		protected RectangleArray _rectangleArray;

		protected DDHandler _dDHandler;
		protected SurfaceDescription _surfaceDesc;
		protected Surface _bitmapSurface;

		public BitmapObject BitmapObject{get{return _bitmapObject;}set{_bitmapObject=value;}}
		public RectangleArray RectangleArray{get{return _rectangleArray;}set{_rectangleArray=value;}}

		public DDHandler DDHandleR{get{return _dDHandler;}set{_dDHandler=value;}}
		public Surface BitmapSurface{get{return _bitmapSurface;}set{_bitmapSurface=value;}}

		public BmpRectCombo(ref BitmapObject bitmapObject, ref RectangleArray rectangleArray, ref DDHandler dDHandler)
		{
			_bitmapObject=bitmapObject;
			_rectangleArray=rectangleArray;
			_dDHandler=dDHandler;

			initializeSurfaceDescription();
			initializeSurface();
		}

		/// <summary>
		/// 初始化surface描述
		/// </summary>
		protected void initializeSurfaceDescription()
		{
			_surfaceDesc = new SurfaceDescription();
			_surfaceDesc.SurfaceCaps.OffScreenPlain = true;

			_surfaceDesc.Width = _bitmapObject.Size.Width;
			_surfaceDesc.Height = _bitmapObject.Size.Height;
		}

		/// <summary>
		/// 初始化surface
		/// </summary>
		protected void initializeSurface()
		{
			this._bitmapSurface = new Surface(_bitmapObject.BitmapSource, _surfaceDesc, _dDHandler.Device);
			
			if (_bitmapObject.BitmapDisplayType == BitmapDisplayType.Transparent)
			{
				//创建黑色的 colorkey
				ColorKey tempKey = new ColorKey();
				tempKey.ColorSpaceHighValue = 0;
				tempKey.ColorSpaceLowValue = 0;

				_bitmapSurface.SetColorKey(ColorKeyFlags.SourceDraw, tempKey);
			}
		}
	}

}

⌨️ 快捷键说明

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