开发者

Create a D3DX texture from a bitmap or graphic

I am attempting to create a texture using DirectX 9 in Delphi 2007.

I am aware of these functions开发者_JS百科:

D3DXCreateTextureFromFile 
D3DXCreateTextureFromFileEx
D3DXCreateTextureFromResource
D3DXCreateTextureFromFileInMemory

but I have the need for the textures to be dynamic (and fast). Is there a function to create a texture from a TBitmap?

More Info:

My end goal is to use DirectX to display a video the user selects. The need for DirectX is to overlay text on top of the Video as well as transition between videos as the user selects the next one. I am using a component that plays the videos and pumps out a bitmap for each frame, and this is what I would like to use for the texture.


You can simply lock a D3D texture and then use GetDIBits on TBitmap.Handle.

You are however wasting a lot of processing time doing this. It would be far better to lock the texture and directly load the image on to the D3D Texture.

This does mean using an external image loading lib, though.

You may also find that using D3DXLoadSurfaceFromFile is significantly faster as you won't need to create a texture each time. Simply grab its top-level surface and load the texture on to it.

Whatever you do, however, loading individual frames like this from disk will be slow. The hard disk loading will be the slowest part. You may find block loading a set of frames into memory and then using D3DXLoadSurfaceFromFileInMemory for each frame while you asynchronously loading another block of frame's images into memory is the fastest method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜