[comp.lang.pascal] Writing Images to Disk in TP 5.0

ccsnad@gdr.bath.ac.uk (Neil A. Drage) (02/01/91)

Hi there,

I am looking for a way of saving images captured by GETIMAGE to 
disk on a VGA system. I actually managed to do this once
in a program I wrote a couple of years ago for a CGA display but really
it was just a kludge.

Doing this:

	write(fil,grafic^);

should, I would have thought, write the image stored in grafic to the
file 'fil'. But when I try to read it using the correspond READ command
the image produced seems to be random noise.

By the way the kludge I made involved creating an array of bytes
large enough to hold the image, assign a pointer to the array and
use this to hold the image. When I want to save the image I write the
array to the disk.

I am currently using Turbo Pascal 5.0, but am going to be upgrading to
version 6.0 very soon. So solutions for either version would be very
welcome.

Thanks, as they say, in advance.

------------------------------------------------------------------------------
"I'm stirred and no longer free, like a fly in a cup of tee." (The Damned)
==============================================================================
Neil A Drage            JANET: N.A.Drage@UK.AC.BATH
University of Bath       UUCP: ...!mcsun!ukc!bath!N.A.Drage
Bath, BA2 7AY     EARN/BITNET: N.A.Drage%uk.ac.bath@UKACRL
England              INTERNET: N.A.Drage%bath.ac.uk@nsfnet-relay.ac.uk
===============================================================================

mcastle@mcs213f.cs.umr.edu (Mike Castle {Nexus}) (02/02/91)

In article <1991Feb1.103512.8094@gdr.bath.ac.uk> ccsnad@gdr.bath.ac.uk (Neil A. Drage) writes:
>I am looking for a way of saving images captured by GETIMAGE to 
>disk on a VGA system. I actually managed to do this once
>in a program I wrote a couple of years ago for a CGA display but really
>it was just a kludge.
>
>Doing this:
>
>	write(fil,grafic^);

Try blockread/write. 

Probably something like:

Size := ImageSize(x1,y1, x2,y2);
GetMem(P,Size);
GetImage(x1,y1, x2,y2, P^);
BlockWrite(fx,P^,Size);
. 
.
.
BlockRead(fx,P^,Size);
PutImage(x3,y3, x4,y4, P^);

paraphrased from the turbo manual.. and off the top of my head... not guaranteed
to work  :->
-- 
Mike Castle (Nexus) S087891@UMRVMA.UMR.EDU (preferred)       | ERROR:  Invalid
                mcastle@mcs213k.cs.umr.edu (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.  |