Click here to Skip to main content
15,868,016 members
Articles / Multimedia / DirectX
Article

2D Blits in DirectX 9

Rate me:
Please Sign up or sign in to vote.
1.64/5 (18 votes)
19 Apr 2005MIT1 min read 81.2K   2.2K   20   6
Describes how to do 2D Blits in DirectX 9 with direct surface access between various surface formats (using color conversion).

Sample Image

Introduction

The sample code provided illustrates how you can do 2D blits in DirectX 9. Starting from DirectX 8, Microsoft removed all 2D code from DirectX. The advice that they gave people wanting to use the 2D features was that those people should use DirectX 7 whenever they wanted to use the 2D functions. Of course, that was not an option if you needed the functionality provided in DirectX 8 and DirectX 9.

So while I was in the technical beta testing team for DirectX 8, I decided to write some sample code which would show how you can get direct access to the D3D surfaces and do 2D blits on them. You would have to write all the 2D functions yourself, but using my code as a starting point, that would be easy to do. In addition, my code also illustrates how to do conversion between the various surface formats introduced in DirectX 8 and 9.

Of course, when direct access to the surfaces is not needed, you would be better off using the standard D3D blitting routines, which are hardware accelerated and as a result are faster than the software 2D blits in my code.

Using the code

A sample project is provided in the downloadable ZIP file which shows how to use the code provided. Please see the readme.txt file also included in the ZIP file, for more information. If you have questions, feel free to email me. For updates or other code samples, visit my homepage.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior)
Suriname Suriname
I'm an IT Consultant / Software Engineer, Graphic Designer and Photographer based in Suriname. Check my website for details at https://www.kareldonk.com/

Comments and Discussions

 
GeneralDoes not follow standards. Pin
Prakash Nadar5-Aug-06 23:05
Prakash Nadar5-Aug-06 23:05 
GeneralRe: Does not follow standards. Pin
Karel Donk6-Aug-06 0:58
Karel Donk6-Aug-06 0:58 
GeneralRe: Does not follow standards. Pin
#realJSOP16-Nov-07 9:25
mve#realJSOP16-Nov-07 9:25 
GeneralRe: Does not follow standards. Pin
OriginalJax13-Apr-07 21:23
OriginalJax13-Apr-07 21:23 
GeneralGreat... Pin
tom_dx20-Apr-05 15:34
tom_dx20-Apr-05 15:34 
GeneralRe: Great... Pin
KDonk21-Apr-05 1:03
sussKDonk21-Apr-05 1:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.