Page 1 of 2

Getting pointer to the image data in memory?

Posted: Mon Apr 18, 2005 4:17 am
by dagcrack
Hi guys,

Loading an image here with PB's image library, and I wanted to know how to access the pointer to the image data in memory?, I don't know how this data is stored by the lib, but I hope this helps me in my project. As if I get the pointer, things can be faster enough to be worth the try.

Thx in advice.
:!:

Re: Getting pointer to the image data in memory?

Posted: Mon Apr 18, 2005 4:23 am
by PB
I don't have the answer (sorry) but I have a similar question for anyone who's
reading: how to get the MD5 checksum of the image data in the clipboard?

Posted: Mon Apr 18, 2005 4:55 am
by Amiga5k
Yes, this information would be valuable to me as well because I'd like to write my own sprite drawing routines and this would make it much faster than using the usual method (using built-in PB commands to copy-modify-copy, etc).

I'm sure, internally, PB keeps things like that in a structure of some sort, so we just need access to that structure. Hey, we can get the address of the video memory, variables, labels and functions so we're almost there!

How about it, Fred? :D

Russell

Posted: Mon Apr 18, 2005 8:28 am
by dagcrack
Nice to hear I'm not the only one that needs this hehe.
I thought it was a whim of mine... But it makes sense if you think about it.

Right now I'm reading every pixel of the image and storing it into an array, tell me if it wouldnt be faster to simply access the image data which is in memory?.

Loading a big image takes no time, the problem in my case is having to read every pixel and store it into an array, thats the slow-downer.

It should be possible to get this pointer (im asking myself as well)...

Posted: Mon Apr 18, 2005 8:32 am
by dagcrack
PB: clipboard? but when you load an image using LoadImage() does it end up in the clipboard? I thought the clipboard was for other things... If you want to get the checksum of the image in memory, why doing this? I mean you can get it from the disk (okey maybe you want a very secure method instead?, if its for a watermark or something like that I can tell of a better method, if not it's maybe a whim :P ).

Posted: Mon Apr 18, 2005 9:48 am
by PB
> PB: clipboard? but when you load an image using LoadImage() does it end
> up in the clipboard? I thought the clipboard was for other things

I'm not interesting in loading an image. My question is not the same as yours.
It's similar, but not the same. We both want to get image data from memory,
but my memory is the clipboard. :)

Posted: Mon Apr 18, 2005 11:10 am
by dagcrack
Ahh! Nevermind me
:shock: Still couldnt find a way to get the pointer to the image data ...

But I found this (someone pointed it out in another thread)

Image (Langage: C)
-----

_PB_Image_ObjectsNumber
_PB_Image_ObjectsArea
_PB_Image_CurrentDC
_PB_Image_CurrentObject

Structure PB_StructureDataBase
Bitmap.l ; OS Bitmap pointer (HBITMAP)
Width.w ; Width in pixel of the image
Height.w
Depth.w
ColorArray.l ; Memory pointer on a color array for 256 colors pictures
EndStructure


I'll check later. I wonder if I could access it..

Posted: Mon Apr 18, 2005 12:12 pm
by dagcrack
Nope no luck yet.

Posted: Mon Apr 18, 2005 12:44 pm
by traumatic
If I got you right, your question has already been asked by others as well:

viewtopic.php?t=8347
viewtopic.php?t=9474


Regarding the PB_StructureDataBase thing, you could use it like this:

Code: Select all

*img.PB_StructureDataBase = LoadImage(#PB_Any, "yourImage.ext")
Debug *img\Bitmap
Debug *img\Width
Debug *img\Height
Debug *img\Depth
Debug *img\ColorArray
Don't know if this helps.

Posted: Mon Apr 18, 2005 1:00 pm
by dagcrack
Yup I tried but my real problem comes with the color array, it seems empty.
And i've seen someone got the same exact problem before (empty array, well, at least it returns a null).

Posted: Mon Apr 18, 2005 1:02 pm
by traumatic
You know it's supposed to be like this if you're not using 8bit images, right?

EDIT: Ah no, I think I remember now, there was something with PB converting
every image to the screens' bit-depth. I tried it myself, opening an 8bit
bitmap and 'depth' said 32...

Posted: Mon Apr 18, 2005 1:06 pm
by dagcrack
No I don't, where is the image data allocated at?
Thats my first question which answer still I don't know :?
And thanks for your time :) You always seem to pop up when I have a question :P You might be a vip member of the forum!

Edit: ah edits!!, Didnt seen your edit!, and also I didnt knew PB converted to the current depth, thats odd. Still Im wondering wheres all this data allocated at.

Posted: Mon Apr 18, 2005 1:57 pm
by traumatic
I'd suggest you to use GetDIBits_() in order to gain access to the actual data.
The threads I mentionend will help you with this.

BTW: If you want to access the other things the docs talk about,
like _PB_Image_CurrentDC etc.:

Code: Select all

!extrn _PB_Image_CurrentDC

LoadImage(#PB_Any, "yourImage.ext")

!MOV [v_hDC], _PB_Image_CurrentDC
Debug hDC

That should work.

dagcrack wrote:And thanks for your time :) You always seem to pop up when I have a question :P You might be a vip member of the forum!
:oops:

Posted: Mon Apr 18, 2005 5:14 pm
by traumatic
I forgot to mention this one of course:
viewtopic.php?t=8781

Posted: Tue Apr 19, 2005 1:28 pm
by traumatic
dagcrack, you could have told me you're needing this for loading textures in OpenGL... ;)