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.

Dark GDK / dbGetBitmapData() Function. LPSTR?

Author
Message
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 2nd Sep 2009 03:17
I can't find any documentation on this command it wants a LPSTR(char* long pointer to a string) i am confused why it wants that type of variable. a char can't hold all the pixel information so one char isn't a hole pixel.

New Site! Check it out \/
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 2nd Sep 2009 03:34
Most of the parameters for that functions are taking pointers to data, so the LPSTR is more than likely an array of characters representing the pixel's data somehow, im not sure how, maybe setting up a dummy program in debug mode and setting breakpoints to examine what it's doing to the data might help ?

I havent used this command myself, or found the need to yet, although I can find any docs on it either anywhere so cant help in that regard. But, can I ask what you are planning on using the command for ? There may be a different way of achieveing what you want without wrestling with unknown commands and potentially wasting your time

If it ain't broke.... DONT FIX IT !!!
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 2nd Sep 2009 04:53
Um, you can store any type of data in a "string". Have you thought that maybe every three or four chars would be a pixel? Red channel is 8 bits (a byte), Green is 8, Blue is 8.

Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 2nd Sep 2009 06:13
Mista Wilson:

I am not sure what i would use it for but my first thought was that it might be faster then using make memblock from bitmap and then get memblock ptr and using the data that way. i don't have a specific use but with that and dbSetBitmapData() functions it would probably be faster. it's not documented in the help though just in the DarkSDKBitmap.h file.

Zuka:

Well ya i did think about that but it makes more sense to use DWORD and then you get rgb and alpha all in one and it's easier to find out how big of a array you need since it's just a DWORD to every pixel. i might test out your idea. that would be a odd way of doing it.

New Site! Check it out \/
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 2nd Sep 2009 07:08
Quote: "Well ya i did think about that but it makes more sense to use DWORD"


Why? Not all images are 32 bit. If you know that it's 32bit then you can always static_cast it to DWORD*.

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 2nd Sep 2009 07:28 Edited at: 2nd Sep 2009 07:30
void dbGetBitmapData( int iID, DWORD* dwWidth, DWORD* dwHeight, DWORD* dwDepth, LPSTR* pData, DWORD* dwDataSize, bool bLockData );

Let's look at what these are and why they're needed. Notice that with a couple of exceptions it wants you to pass the address of various data elements. This is because the function is designed to return multiple pieces of data instead of one data type. So you pass it the address where you want it to put the data.

In the case of pData you're not passing a long pointer to a string. You're passing the address of a long pointer to a string into which the function will place an address.

To be honest, I've used this as part of a class that accesses image data and I have a comment by the side of my LPSTR pData that says "// not sure what this is but it's needed".

Looking at my code I can't see that I ever need to use that information beyond the need to provide a place to put it.

It's late and I don't have the time to dig out all the dependent support headers. However, at the risk of letting out code that needs to be treated gingerly, I'll provide the header and code for my image class just in case it might help. Some of the dependence is on my Bitmap class and at least a rectangle structure I've defined somewhere else so I'm providing this for instructional purposes. It will show you some techniques for accessing image data directly. I'm sure that bitmaps can be accessed pretty much the same way.

Image.h



Image.cpp



Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 2nd Sep 2009 08:04 Edited at: 2nd Sep 2009 08:04
Quote: "If you know that it's 32bit then you can always static_cast it to DWORD*."


Or you can just do a regular C cast which looks simpler and has no disadvantages to its more verbose C++ counterpart.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 2nd Sep 2009 14:58 Edited at: 2nd Sep 2009 15:00
Where did you get the pointer to the image data? i can see you are changing it directly but i can't find where you got it. i get lost right about the time when you get the Direct3DTexture9 pointer. lol. i understand pretty much all the d3d stuff you use. it's just i can find that pesky little place where you get the pointer lol

New Site! Check it out \/
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 2nd Sep 2009 15:40
The dbGetBitmapData() function is wrapped in the Image::ImageData Image::GetData(int imgnum) method.

It looks like it gets called during the Image::Load method with this : thisImage = GetData(imageNumber);

hope that answers your question

If it ain't broke.... DONT FIX IT !!!
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 2nd Sep 2009 18:01 Edited at: 2nd Sep 2009 18:01
Quote: "Where did you get the pointer to the image data?"


That comes from a db call

temp.data = dbGetImagePointer (imgnum);

It's a completely separate call for information than dbGetImageData but it appears to be necessary to get not only the pointer to the data but the dimensions and pitch information.

The LPDIRECT3DTEXTURE9, IMS, is a structure with more information (and functions) and the pointer to the actual image data is imgPtr. bytes is assigned as a pointer to DWORD during the call to Lock(). I'm not sure why I put it there but apparently I did. Since Lock() should be called before all operations where the image is accessed it doesn't matter.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 2nd Sep 2009 19:30
Ok well looking through the d3d functions i think that dbGetImageData() and dbSetImageData() is just call Direct3DTexture9::GetPrivateData() and Direct3DTexture9::SetPrivateData() that's what it looks like atleast.

Does anyone know what a GUID struct is for?

New Site! Check it out \/
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 2nd Sep 2009 20:15 Edited at: 2nd Sep 2009 20:15
Quote: "Does anyone know what a GUID struct is for?"


I believe it stands for Global Unique ID. It's some assurance that an ID you're using to define an entity is unique out of all such things that may be created.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 2nd Sep 2009 22:03
Oh ok cuz i was trying to use Direct3DTexture9::GetPrivateData() function and it is asking for it. it has 4 variables i think unsigned long, char array, and 2 others i can't remember now. hmmmm

New Site! Check it out \/

Login to post a reply

Server time is: 2024-10-06 05:35:27
Your offset time is: 2024-10-06 05:35:27