[comp.lang.pascal] Saving graphics screen to file in TP 5.5

ajayshah@almaak.usc.edu (Ajay Shah) (11/15/90)

In article <90318.10233434ZL4RT@CMUVM.BITNET> 34ZL4RT@CMUVM.BITNET (Nilesh) writes:
>and would like to save the screen image to disk for retrieval later. I have

I can contribute part of the code, provided you tell me how to do
the rest when you figure it out!

Part A: grabbing the screen into memory:

procedure GrabScreen(var p:pointer);
var
	p:pointer;
	Need : word;
begin
	Need := ImageSize(0, 0, GetMaxX, GetMaxY);
	if (maxavail < Need) then
	begin
		writeln('Sorry, no memory available.');
		exit
	end;
	getmem(p, Need); {hence need p above as var}
	GetImage(0, 0, GetMaxX, GetMaxY, p^)
end;

Part B: writing it to disk.  If you were committed to (say) a
CGA, then you know the size above (Need = 16k) and you can write
code like:

---------------------------------------------------------------------------
procedure WriteScreen(var data; fname:string);
type
	CGAScreen = array[1..16384] of byte;
	ScreenFileType = file of CGAScreen;

var
	thiscreen : CGAScreen absolute data;
	f : ScreenFileType;

begin
	assign(f, fname); rewrite(f); write(f, data); close(f)
end;

where you would issue the call as follows:

	WriteScreen(screen^, 'afile');
	NOT 
		WriteScreen(screen, 'afile');

---------------------------------------------------------------------------

But you can't because you don't know how big Need is going to be.
The trick is to use the bufstm module bundled with tp5.5, except
that I don't know how it's done.  Remember what you promised me
at the start of this posting!

-- 
_______________________________________________________________________________
Ajay Shah, (213)734-3930, ajayshah@usc.edu
                              The more things change, the more they stay insane.
_______________________________________________________________________________

mcastle@mcs213f.cs.umr.edu (Mike Castle) (11/15/90)

In article <90318.10233434ZL4RT@CMUVM.BITNET> 34ZL4RT@CMUVM.BITNET (Nilesh) writes:
>Hi,
>I am writing a structure diagram editor using the graphics mode in TP 5.5
>and would like to save the screen image to disk for retrieval later. I have
>no idea how to go about doing this and would be grateful if someone could
>help me out. Magical source code would be highly appreciated.
>Thanks,
>
>Nilesh
>(34zl4rt @ cmuvm )

Might try using GetImage/PutImage to put part of the screen into an array, 
and then using BlockWrite/BlockRead to put it onto disk.

-- 
Mike Castle (Nexus) S087891@UMRVMA.UMR.EDU (preferred)       | ERROR:  Invalid
                    mcastle@mcs213k.cs.umr (unix mail-YEACH!)| command 'HELP'
Life is like a clock:  You can work constantly, and be right | try 'HELP'
all the time, or not work at all, and be right twice a day.  |

zhou@brazil.psych.purdue.edu (Albert Zhou) (11/15/90)

If you want to save the whole screen, just use a absolute variable with its
address set at the address of the visual buffer. For Monochrome, its
$8000:0; for CGA its $b800:0. 
Or you could use procedures in graph unit: GetImage and PutImage. They are
in the manual.

streich@tigger.Colorado.EDU (Mark Streich) (11/15/90)

All of the solutions proposed to save a graphics screen to disk assume
you can have one data structure that includes the entire screen.  This
just isn't true for VGA modes.  The memory required is greater than the 64k 
byte limit on arrays.

You need to divide the screen up into 4 areas and then use 'getimage'
and 'putimage' for each area.