Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

using directx to load TARGA files

Posted on 2004-10-09
3
Medium Priority
?
351 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

636 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