Click here to Skip to main content
15,884,816 members
Articles / Desktop Programming / MFC

Drawing with DirectDraw & GDI

Rate me:
Please Sign up or sign in to vote.
4.88/5 (11 votes)
24 May 2002 300.3K   13.8K   68  
Drawing Graphics fast with DirectDraw than with GDI
// Copyright (C) 1991 - 1999 Rational Software Corporation

#if defined (_MSC_VER) && (_MSC_VER >= 1000)
#pragma once
#endif
#ifndef _INC_CDDCANVASIMPL_3C181F4B007E_INCLUDED
#define _INC_CDDCANVASIMPL_3C181F4B007E_INCLUDED
#include "canvasimpl.h"
#include "ddscreen.h"
#include "ddsurface.h"

//##ModelId=3C181F4B007E
class CDDCanvasImpl : public CCanvasImpl
{
public:
	
	virtual CDC* GetMemDC(){ return NULL;}
	HRESULT Create(CWnd* pWnd,int Width,int Height,int BPP);
	CDDCanvasImpl(CWnd* pWnd,int Width,int Height,int BPP);
	virtual HRESULT Blt(CCanvasImpl* pDestcanvas ,LPRECT pDestRect,LPRECT pSrcRect);
	virtual HRESULT Release();
	virtual HRESULT TextOut(int x, int y, COLORREF col, LPCTSTR pString);
	virtual HRESULT SaveAsBMP(const char *szFilename);
	virtual HRESULT RoundedRect(int X1, int Y1, int X2, int Y2, int Radius, DWORD Col);
	virtual void* GetSurfacePointer( void );
	virtual BOOL ClipRect(RECT *Rect);
	
	//����ֱ��
	virtual HRESULT Line(int X1, int Y1, int X2, int Y2, DWORD Col);
	
	//ȡ�ñ���ṹ
	virtual void GetSurfaceDescriptor(LPDDSURFACEDESC2 lpddsd);
	
	//ȡ��������
	virtual char* GetFontName(char *name);
	//���ƾ���
	virtual HRESULT Rect(int X1, int Y1, int X2, int Y2, DWORD Col);
	
	//ȡ��������ɫ
	virtual DWORD GetPixel (int X, int Y);
	
	//�Ӵ����ж�ȡλͼ����ʾ
	virtual HRESULT LoadBitmap(const char *szFilename);
	
	//�����ַ���
	virtual HRESULT DrawText(LPCSTR pString, COLORREF col, LPRECT pRect);
	
	//������ҳ�洫�͵���������
	virtual HRESULT BltFast(NDDSurface* lpDDSurface);
	
	//�õ�һ��ɫ������
	virtual HRESULT Fill(DWORD Col);
	
	//����Բ��
	virtual HRESULT Circle(int X, int Y, int Radius, DWORD Col);
	
	//���òü�������
	virtual void SetClipRect (LPRECT lpClipRect);
	
	//���Բ��
	virtual HRESULT FillCircle (int X, int Y, int Radius, DWORD Col);
	
	//������
	virtual HRESULT FillRect (int X1, int Y1, int X2, int Y2, DWORD Col);
	
	//�������
	virtual HRESULT PutPixel(int x, int y, DWORD Col);
	
	NDDSurface		 * m_pSurface;  
	static NDDScreen * m_pScreen;
	
	CDDCanvasImpl(CWnd* pWnd);
    ~CDDCanvasImpl();
	//��������
	virtual HRESULT Create(CWnd* pWnd);
    

	//##ModelId=3C1EE8910108
	//ֱ�ӽ�λͼ�ļ����ݴ��͵�������豸�����ľ����
	virtual HRESULT Blt(LPRECT pDestRect, LPRECT pSrcRect, CONST VOID *lpBits, CONST BITMAPINFO *lpBitsInfo);
    

	//##ModelId=3C1812A80174
    

	//	���Ƶ�

	//	ȡ��ָ�������ɫ

	//	����: Rect
	//	˵��: ���ƾ���
	//	����: 0 or > - �ɹ�
	//	      < 0    - ʧ��

	//	����: FillRect
	//	˵��: ����������
	//	����: 0 or > - �ɹ�
	//	            < 0    - ʧ��

	//	����: Line
	//	˵��: ����ֱ��.
	//	����: 0 or > - �ɹ�
	//	      < 0    - ʧ��

	//	����: Circle
	//	˵��: ����Բ��
	//	����: 0 or > - �ɹ�
	//	      < 0    - ʧ��

	//	����: FillCircle
	//	˵��: ����һ��������
	//	����: 0 or > - �ɹ�
	//	      < 0    - ʧ��

	//	����: RoundedRect
	//	˵��: ����Բ�Ǿ���
	//	����: 0 or > - �ɹ�
	//	      < 0    - ʧ��

	//	����: Fill
	//	˵��: ��ָ����ɫ��䱳��
	//	����: 0 or > - �ɹ�
	//	      < 0    - ʧ��

	//	����: TextXY
	//	˵��: ��ָ��λ��������֣����ֱ���͸��
	//	����: x - X ����
	//	y       - Y ����
	//	col     - ��ɫ.
	//	pString - �ַ���
	//	����: 0 or > - �ɹ�
	//	      < 0    - ʧ��
	/////////////////////////
	//	����: DrawText
	//
	//	˵��: ��ָ�������ڻ����Զ����е�����
	//	����: pString - �ַ���
	//	col     - ��ɫ
	//	pRect   - �
	//
	//	����: 0 or > - �ɹ�
	//	      < 0    - ʧ��
	//
	//	/////////////////////////////////////////////////////////
	//	///////////////////////


	//	///////////////////////
	//	����: ClipRect
	//	˵��: �޶��������
	//	����: Rect - �޶��������
	//	����: TRUE  - proceed with the draw operation
	//	FALSE - after clipping there is �� to draw, exit
	//	draw operation.

	//	����: Restore
	//	˵��: ���涪ʧ��������ָ�����
	//	����: ��
	//	����: 0 or > - �ɹ�
	//	      < 0    - ʧ��
	virtual HRESULT Restore ();


	//	����: Lock
	//	˵��: �������棬�Ա�ֱ�ӷ��ʱ�������
	//	����: ��
	//	����: ��������    - �ɹ�
	//	      < 0         - ʧ��
	//	ע��: ʹ�ý�����Ҫ���˵���UnLock.
	virtual HRESULT Lock ();

	//	����: UnLock
	//	˵��: ȡ����������
	//	����: ��
	//	����: ��������    - �ɹ�
	//	      < 0         - ʧ��
	virtual HRESULT UnLock ();

	//	����: GetDC
	//	˵��: ȡ���豸�����ľ��
	//	����: ��
	//	����: 0 or > - �ɹ�
	//	      < 0    - ʧ��
	//	ע��:  ʹ����GDI������Ӧ����ReleaseDC
	virtual HDC GetDC ();

	//	����: ReleaseDC
	//	˵��: �ͷ��豸������. Ӧ����ʹ��GetDC������Ӧ����ReleaseDC
	//	����: ��
	//	����: 0 or > - �ɹ�
	//	      < 0    - ʧ��
	//	ע��:  Ӧ����ʹ��GetDC������Ӧ����ReleaseDC
	virtual HRESULT ReleaseDC ();


	// ȡ�ñ�������ָ��

	// ȡ�òü���
	virtual LPRECT GetClipRect ();

	//	����: SetClipRect
	//	˵��: ���òü���
	//	����: clipRect - �ü���
	//	����: ��
	//	ע��: �ü������ܳ�������

	//	����: GetFontName
	//	˵��: ȡ����������

	//	����: GetSurfaceDescriptor
	//	˵��:ȡ�ñ������
	//	����: [out, retval]lpddsd 
	//	����: ��

	//ȡ��DirectDraw����
	virtual LPDIRECTDRAWSURFACE7 GetDDS ();

	// ˢ��
	virtual HRESULT Refresh(LPRECT lpRect);
protected:
	BOOL m_bIsDBuffer;
};

#endif /* _INC_CDDCANVASIMPL_3C181F4B007E_INCLUDED */

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions