Skip to main content
GameDev.net gamedev.net
🔒 Locked

CreateImageSurface vs RenderTarget

Started by spade Jan 20, 2003 at 2:29 PM 3 replies 500+ views
Original Post
spade
spade
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
bmoberly
bmoberly
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
spade
spade
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
Zarmax
Zarmax
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.
spade
spade
Thanks,
I see it can be done in an easy way by locking the surface.

Regards,
Tim

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.