Archived

This topic is now archived and is closed to further replies.

spade

CreateImageSurface vs RenderTarget

Recommended Posts

Hi Folks, is there an easier way to get the pixels of a texture/image ? For now I create an ImageSurface und get the backbuffer written in this struct. Is it possible to get the pixels without Rendering the whole stuff ? I just want to get the pixels of an image... Regards, Tim

Share this post


Link to post
Share on other sites
Hi - have you considered using Direct3DTexture8.GetSurfaceLevel to access the surface (or surfaces) associated with a texture? You can this lock this surface and access its pixels.

Hope this helps-

BM

Share this post


Link to post
Share on other sites
No I didn''t. Thanks

But I have several problems with this GetSurfaceLevel.
I want to do RenderToTexture in a different part of my app also.

Are there any good tutorials ?
Are there any boobytraps to watch for when setting the renderstages !?

Regards,
Tim

Share this post


Link to post
Share on other sites
I struggled a bit with this too when working in C#/Dx9. For that case here is how you can create a texture and get direct access to the bits. I am currently using it for real-time light maps.

m_txrLightMapTexture = new Texture(m_d3dDevice, 256, 256, 1, 0, Format.A8R8G8B8, Pool.Managed);

uint[,] lm = (uint[,])m_txrLightMapTexture.LockRectangle(typeof(uint), 0, 0, 256, 256);

twiddle bits...

m_txrLightMapTexture.UnlockRectange(0);

This can be sped up I heard by changing to a 1d array, or using unsafe code and pointers.

Share this post


Link to post
Share on other sites