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 / A question about bitmap and image pointers and memory allocation for each

Author
Message
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 26th Feb 2008 01:58
I'm writing a DBPro plugin that makes use of the FreeImage library.
The plugin is being developed with PureBASIC and Freddix's PurePLUGIN.

I was wondering if anyone knows exactly how DBPro manages memory for
bitmaps and images? More specifically, memory allocation, de-allocation
and the recognition of existance for a bitmap or image created or loaded.

I'm currently working on passing data between FreeImage and DBPro for
both bitmaps and images. I can get FreeImage to save a bitmap or image
out of DBPro, but the reverse I'm having issue with.

The loading of an image can be done with the use of memblocks, but I
was wondering if it would be possible to take a more direct approach.
Like, copying the bitmap pointers from the bitmap loaded by freeimage
into the DBPro pointers. Would DBPro recognize that image as existing
if it wasn't originally created by DBPro? (i.e. existing by using
create bitmap, make image from memblock, load image or bitmap, ect.)

I read the information that Freddix provided in the DBPro_Extras include
file for PurePLUGIN and he mentions that you can not only read, but also
also write to the bitmap and image pointers. Is this safe? Haven't tried
it yet.

Thanks,
D Ogre
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 27th Feb 2008 02:35
Nevermind.

I took another look at this and realized that I overlook the fact that
you can't force an image or bitmap ID upon DBPro. As far as I can see there
are no provisions (at least with PurePLUGIN) to do this. Although, you could
probably edit the pointers. I would deemed it very unsafe to do so in the fear
of over writing something else in memory.

So, I decided to just use memblocks to pass the data from FreeImage to DBPo.

1. Load a pic with FreeImage
2. Convert it to a DBPro friendly format
3. Create a memblock the size of the pic
4. Pass the pic to the memblock
5. Make an image or bitmap from the memblock
6. Delete the memblock
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Feb 2008 14:39
This has been done before for images (not bitmaps) - I can't remember who did it, but I provided code that helped him.

There are several Make* functions in the Image DLL that you can use to create an image of the size you require. There's also a function that allows you to get the DX texture pointer directly, so you can lock it, write to the texture memory and then unlock when done.

For bitmaps, I don't think you can get the DX surface pointer, but you can call the lock function, get a bitmap pointer and then write to the memory directly.

Basically, both the same techniques, just with different ways of doing it.

D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 28th Feb 2008 02:41
Thanks for the info, Ianm.

I'm sticking to using memblocks for now until I get the plugin roughed
out and working. I will look into what you suggested later.

However, I would like to a see an example, if you don't mind and have the
time.

Login to post a reply

Server time is: 2024-11-23 02:40:29
Your offset time is: 2024-11-23 02:40:29