Solved

using directx to load TARGA files

Posted on 2004-10-09
3
272 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

20 Experts available now in Live!

Get 1:1 Help Now