Solved

using directx to load TARGA files

Posted on 2004-10-09
3
287 Views
Last Modified: 2011-09-20
Hi experts,

i'm a beginner in directx programming, i would like to load a targa files using directx, can the directx load the RGB and the ALPHA channel? and how to display it in two different image? (1 for RGB and the other one for ALPHA channel?)

0
Comment
Question by:mamamia
  • 2
3 Comments
 
LVL 17

Expert Comment

by:davebytes
ID: 12277259
Well, yes, DirectX can load most major formats using D3DXLoadSurfaceFromFile:

pD3DDevice->CreateImageSurface(600,800,D3DFMT_X8R8G8B8 , &pD3DSurface);
D3DXLoadSurfaceFromFile(pD3DSurface, NULL, NULL, filepath ,NULL, D3DX_DEFAULT,0, NULL) ;

For more details look at:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c/directx/graphics/reference/d3dx/functions/texture/d3dxloadsurfacefromfile.asp

Now, if you want TWO different images, you'll need to create a second alpha-only surface, 'strip' the alpha bytes from the first surface and copy them in to the second surface.  I've not seen an 'automated' process for this -- you have to do it 'by hand' in a loop that walks the entire texture data.

-d

0
 

Author Comment

by:mamamia
ID: 12286116
i'm not sure whether i can use D3DFMT_A8 or D3DFMT_A8P8
anyone tried this before?
0
 
LVL 17

Accepted Solution

by:
davebytes earned 500 total points
ID: 12289748
A8 should work fine -- though of course everything depends on your board and drives. ;)

-d
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Where to Market / Sell your Game. 2 734
Sudoku - eraseable white board 2 276
General  PC Gaming question about re-playing a game 5 126
Fix45 challenge 15 103
Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now