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.

Programming Talk / C++ / C# - How do you get a DBP image pointer?

Author
Message
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th May 2008 18:19
Hello everyone,

I have been searching on the forums for this, but can't get a good answer on it.

I suspect I'll have to access the GetPointer(int nr) command from somewhere, but I have no idea how I would implement it in my DLL.

Can anyone give me some information on this please?

Thanks!
Sven B

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th May 2008 19:08
There's a function within the DBProImageDebug.dll called '?GetPointer@@YAPAUIDirect3DTexture9@@H@Z', which basically translates to 'IDirect3DTexture9 * GetPointer(int)', so yes, you're 100% correct!

Just get an address to it using GetProcAddress and assign it to a function pointer.

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 8th May 2008 21:48 Edited at: 8th May 2008 21:48
Thanks!

Is there also a way to retrieve image pixel data from it when you have the pointer?

I thought I could extract it if DirectX used some sort of easy-to-understand structure (which isn't the case apparently).

Or should I use the same method, but implement memblock commands to convert the image to a memblock internally and extracting the pixel data from there out?

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 8th May 2008 23:56 Edited at: 9th May 2008 00:03
Once you obtain the pointer to the IDirect3DTexture9 object, you need to lock the texture with the LockRect member function to obtain a pointer to the pixel data.

Here's some code for an example DLL I've written, which sets each mipmap level to a solid colour. You should be able to figure out how to access the pixel data from this. Note that it assumes that the texture is 32-bit.

main.cpp:



resource.rc:



dbp:



IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 8th May 2008 23:56
Memblocks are easier, updating the texture directly *can* be faster.

A D3D Texture is made up of either many surfaces (if mipmapped) or a single surface (if not mipmapped). For mipmapped textures, any change made to the larger top surface is automatically propagated to the other surfaces unless you specify otherwise - so basically, you can treat the two types in exactly the same way.

NOTE: I'm leaving out an awful amount of checking of the HRESULT values from the following code.

First task - get the texture. Assuming you have a correctly populated function pointer...


Next, get the surface pointer to the top surface of the texture:


From that, you can get the surface size, bit depth, pitch and format:


If you need to read or write to the surface, you need to lock before you start to get it's address, and unlock when done:


And finally, because you created a surface pointer from the texture, you need to tell DirectX you are done with it:


Those are the basics. Obviously the reading/writing of colour information will depend in the colour depth and the colour format, but there's enough there that you should be able to puzzle it out with a little help from the DX documentation.

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 10th May 2008 08:46
Wow, thanks for the big help!!!

I'm not planning on writing information to images, just retrieving colors etc.
I will first try it the memblock way, so I can figure out the code you just posted on my own tempo.

Thanks!
Sven B

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.

Login to post a reply

Server time is: 2024-03-28 20:34:16
Your offset time is: 2024-03-28 20:34:16