?
Solved

using directx to load TARGA files

Posted on 2004-10-09
3
Medium Priority
?
335 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 total points
ID: 12289748
A8 should work fine -- though of course everything depends on your board and drives. ;)

-d
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

777 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