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 / How are images stored in memory?

Author
Message
Aura Art
15
Years of Service
User Offline
Joined: 29th Sep 2008
Location:
Posted: 1st Oct 2008 00:30
Okay, I managed to:

1. Load an image to memory.

2. convert it to a Memblock.

3. Access that Memblock and make alterations.

4. Put it back into a image.

5. Show the image on screen.

It all seems to make sense now.

I only need to know one more thing.

How is image date stored in D GDK?

I know the first twelve bytes are Height, width and depth.

Yay

But how is the actual image data stored(ie colors of each pixel).

I know each pixel is in four bytes.. but I don't know how to translate those four bytes into a color.
I don't know how to translate a color into this four bytes format.

I hope someone can help with this.

It should be perfectly simple if you know how it works.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 1st Oct 2008 02:42
It's been a while since I've been able to work with any Dark GDK stuff so I'm a bit off. Best advice I can give you from, mostly memory, is to look in the DarkGDKImage.h file for some undocumented functions.

void dbGetImageData ( int iID, DWORD* dwWidth, DWORD* dwHeight, DWORD* dwDepth, LPSTR* pData, DWORD* dwDataSize, bool bLockData )

gets the information about the data you want. You'll have to dig for some of it as it's not at my fingertips at the moment.

LPDIRECT3DTEXTURE9 dbGetImagePointer ( int iID )

gets you a pointer to the data.

You'll find that the data is of type DWORD where the first, most significant byte, is the alpha data which should always be 255 or 0FFh for totally opaque. The next bytes are red, green and blue in descending order.

Be careful of the pitch since that's the actual width of the image even if it's not the visible width.

I've been able to use this information to copy all of the bitmap operations over to images in an Image class and added a few more of my own.

But in order to use it efficiently and safely you'll want to study up on some of Direct X. It's especially important to know how to lock the memory before manipulating the data.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Oct 2008 21:49
Quote: "I've been able to use this information to copy all of the bitmap operations over to images in an Image class and added a few more of my own."


very interesting. did you ever make this available anywhere?
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 1st Oct 2008 22:43
It's part of a larger set of classes that are somewhat interrelated. The Image class is somewhat dependent on knowing about the Bitmap class for example. They're not as massive as Jason's classes since I focused on 2D only and I haven't compiled them down into libs. I've found myself without time to properly test them though I have used them in a couple of developments I have going on. I also haven't gotten animated sprites to work though I could release it with the caveat.

The source code is somewhat haphazard but I'll probably zip it up and release it as-is at some point.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Login to post a reply

Server time is: 2024-05-03 21:11:08
Your offset time is: 2024-05-03 21:11:08