Page 1 of 1
Posted: Tue Dec 10, 2002 6:30 pm
by BackupUser
Restored from previous forum. Originally posted by waffle.
could someone show an example of how to copy a bitmap.
complete problem:
the PB code is in a DLL
the dll is called with the address of the bitmap
and any other required data.....(hight/width/depth)
how can PB place this data into a file to save as a .bmp?
without having an "open window"?
i may eventually figure this out, but just thought maybe someoneelse
may have already done it

Posted: Tue Dec 10, 2002 6:37 pm
by BackupUser
Restored from previous forum. Originally posted by freak.
Well, with the address of the Bitmap, you can use CatchImage(), and then SaveImage() to
save it to a file, like this:
Code: Select all
ProcdureDLL SaveBmp(address.l, filename.s)
CatchImage(1, address.l)
SaveImage(1, filename.s)
FreeImage(1)
EndProcedure
Ofcourse you will have to add some Error-handling, if one of these commands returns 0.
You don't need height/width or depth here, as CatchImage() handles all this.
Hope this is, what you wanted...
Timo
Posted: Tue Dec 10, 2002 9:26 pm
by BackupUser
Restored from previous forum. Originally posted by waffle.
i think that is.
but i thought i could not use image commands without an open PB window. Or is that just for incase i wish to display the image?
i'll try it and let you know later if that works.
Posted: Wed Dec 11, 2002 1:50 pm
by BackupUser
Restored from previous forum. Originally posted by waffle.
that did not do it for me.
it seems that the program that is using the bitmap
does not store the bitmap in BMP format
so i need to
1 - create a blank image in PB that is of the same size and depth as the original bitmap.
2 - obtain the memory address of the new bitmap
3 - copy memory from the source to the new one
4 - then the save image function will work
so i guess my next question is how to obtain the Address of the new image and calculate the size of the image (in bytes)
so am i starting to get complicated now ?
someoneelse gave me a DLL in delphi that does my job, but i would like to keep my own code instead of distributing anothers .dll
So, this is important, but not critical to anything at this time.
another method just came to me....
read each word from the source bitmat address and use the "dot" function to place the colored dot into the new image and then save....
this seems a slow way though, when compared to just copy the memory.
Posted: Wed Dec 11, 2002 5:54 pm
by BackupUser
Restored from previous forum. Originally posted by freak.
Sorry, there i can't help you.
Timo
Posted: Tue Dec 17, 2002 3:16 am
by BackupUser
Restored from previous forum. Originally posted by TheBeck.
You can not access another program's memory from your program, this will cause a GP fault. Windows memory is protected. The other program has to send the image to your program.
Posted: Tue Dec 17, 2002 3:35 am
by BackupUser
Restored from previous forum. Originally posted by PB.
> You can not access another program's memory from your program,
> this will cause a GP fault. Windows memory is protected.
Actually, only NT-based Windows PCs are memory protected, and you can
easily access another program's memory on non-NT machines. It's done
using API calls, and I've done it in the past with Visual Basic. As
yet I haven't really tried it with PureBasic, especially as I am using
XP and not 98se anymore.
Posted: Tue Dec 17, 2002 4:27 am
by BackupUser
Restored from previous forum. Originally posted by TheBeck.
> Actually, only NT-based Windows PCs are memory protected, and you can
> easily access another program's memory on non-NT machines.
By "Windows", I of course meant modern Windows and not obsolete Windows 9x, witch is little more than windows 3.1 with 32 bit extensions.
I wish Microsoft had killed Windows 3.1 when they had the chance.
Posted: Tue Dec 17, 2002 5:19 am
by BackupUser
Restored from previous forum. Originally posted by PB.
> By "Windows", I of course meant modern Windows and not obsolete
> Windows 9x
Okay. I wish memory access to other processes was possible under
NT-based Windows, though... things like trainers and such are so
much fun to use! Damn Microsoft.
Posted: Tue Dec 17, 2002 10:08 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.
System security is more important than game trainers/cheaters, PB.
cya,
...Danilo
(registered PureBasic user)
Posted: Tue Dec 17, 2002 11:38 am
by BackupUser
Restored from previous forum. Originally posted by PB.
> System security is more important than game trainers/cheaters, PB.
Hehehe, I disagree. I come from the old C64 days where peeking and
poking was the norm, and nothing ever really got lost/damaged then.
But yes, the C64 wasn't booted from disk, which is why no viruses
or damage could really exist.
I guess these days, with NT-based machines, we'll find saved game
editors becoming more the norm, instead of real-time memory trainers.
Posted: Tue Dec 17, 2002 12:59 pm
by BackupUser
Restored from previous forum. Originally posted by freak.
I thought the PB code was in a DLL?
A dll has access to the Memory of the
Program that has loaded it, or am I wrong here?
So this should not be the Problem.
Timo
Posted: Fri Dec 20, 2002 3:24 pm
by BackupUser
Restored from previous forum. Originally posted by waffle.
the problem was not access to the memory because a pointer to the bitmap was obtained and passed to a DLL. The problem is i'm using DBPro which does not store the bitmap internally in .bmp format. Someoneelse wrote a DLL for me, but did not wish to release the code. I think the way it was coded was by counting bits (bit depth) and then calling a Dot API call with that color and position in the new bitmap. This just seems to be slow, so i was looking for a faster way.
in summary, i gave up on reverse ingeneering because i have too many other things to do

Thanks for all the thoughts though.