Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / How to get the pointer to an image by its ID?

Author
Message
Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 15th Nov 2008 12:57
Is there a way to get a pointer to access the contents of an image by its ID? It would be a lot faster than repeatedly calling Make Memblock From Image, Get Memblock Ptr and Make Image From Memblock.

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Nov 2008 14:54
It's a DirectX texture, so you need to:
- Get the DX texture pointer (function in the Image DLL is ?GetPointer@@YAPAUIDirect3DTexture9@@H@Z - IDirect3DTexture9 *GetPointer(int))
- Use that to get a pointer to the top level DirectX surface of the texture.
- Lock the surface.
- The pointer to the actual image data is held within the lock structure - manipulate the data to your hearts content.
- Unlock the surface (which will regenerate any mipmaps required).

Don't miss any steps out, don't use the pointer after you unlock the surface, and ensure that you unlock the surface before you use the image anywhere.

If you don't follow this advice and your code does actually work, it's possible that it won't work for other cards/drivers/patch levels, so it's best to take the extra care.

Mistrel
Retired Moderator
18
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 15th Nov 2008 20:52
Excellent! Thank you.

Login to post a reply

Server time is: 2024-03-28 19:25:10
Your offset time is: 2024-03-28 19:25:10