Saving Pointers To Fies

I'm working on a 3D Scrolling engine for pascal in which I am using the function Getimage to save portions of the screen to files.  The problem is when using a pointer, you are only saving the memory location of the image not what is actually at the pointer location.  I was wondering if anyone knew if and how this is can be accomplished.  I do not know assembly language and would appreciate an answer without it.
Who is Participating?
scrapdogConnect With a Mentor Commented:
Are you using Turbo Pascal?

You could do it this way:

Declare this variable:

var Image :Pointer;

And in your code:

Size := ImageSize(x1,y1,x2,y2);
GetMem(Image, Size);

{open your file here (a file of bytes)}

to write to the file:

BlockWrite(File, Image^, Size, Result);  {result returns number of bytes sent to file}

When you are done with the image buffer:

FreeMem(Image, Size);

if you have a pointer variable it's always same :

  Something : Pointer;

"Something" is the Pointer (xxxx:yyyy)
"Something^" is the Data where the Pointer points to
Corey080698Author Commented:
I tried the above answers, but neither of them are working...when i reload the image to a pointer variable from the file, its not coming acrossed as it was saved or not at all.  Any more sugestions?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.