how to save a graphfile 
Author Message
 how to save a graphfile

How can I save the screen of a graph program? How can I save a picture thats
been created by graph???
 Thanks Jan


Wed, 18 Jun 1902 08:00:00 GMT  
 how to save a graphfile

Quote:

>How can I save the screen of a graph program? How can I save a picture thats
>been created by graph???

If you do not need any standard format, then you can use getimage and
putimage with blockwrite/brockread. However, as those are limited to
64K, you have to do it in parts. You can use imagesize to check how many
parts you need. Or on 16-bit modes you can use the fact that a pixel
takes 4 bits.  You can store the 640x480x16 screen in three parts.

The following unit has simple save/load routines. (Note there is text
after the code)

Unit GrSave;

interface

uses graph;

Procedure Savescreen(var fp:file);
Procedure LoadScreen(var fp:file);

implementation

const maxb=65500;

type Block=record
              x:word;
              y:word;
              buffer:byte;
           End;

Procedure GetBlocksize(var rows:word; var size:word);
var d:word;
begin
  rows:=getmaxy+1;
  d:=0;
  repeat
    inc(d);
    rows:=(getmaxx+1+d div 2) div d;
    size:=imagesize(0,0,getmaxx,rows-1);
  until (size>0) and (size<maxb)
End;

Procedure Savescreen(var fp:file);
var p:^block;
    rows,size:word;
    first,last:word;
begin
  GetBlocksize(rows,size);
  getmem(p,size+4);
  last:=rows-1;
  first:=0;
  rewrite(fp,1);
  blockwrite(fp,size,2);
  repeat
    getimage(0,first,getmaxx,last,p^.buffer);
    p^.x:=0;
    p^.y:=first;
    blockwrite(fp,p^,size+4);
    inc(first,rows);
    inc(last,rows);
    if (last>getmaxy) and (last>=first) then begin
         last:=getmaxy;
         size:=imagesize(0,first,getmaxx,last);
    End;
  until first>getmaxy;
  freemem(p,size+4);
  close(fp);
End;

Procedure LoadScreen(var fp:file);
var p:^block;
    size:word;
    bytesread:word;
begin
  reset(fp,1);
  blockread(fp,size,2);
  getmem(p,size+4);
  blockread(fp,p^,size+4,bytesread);
  while bytesread>0 do begin
    putimage(p^.x,p^.y,p^.buffer,NormalPut);
    blockread(fp,p^,size+4,bytesread);
  End;
  freemem(p,size+4);
  close(fp);
End;

end.

If on the other hand want standard format and use windows, then press
printScr. It copies the image into the clipboard. Then paste it inno any
graphics program.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 how to save a graphfile
If you do not need some special format and if you are using less than 64kb
of video memory, then you can just copy video memory to some file, using
blockwrite:

procedure savevideomemory(name:string);
var f:file; {declares a file variable, which can be used by
blockwrite/blockread}
begin
assign(f,name);
rewrite(f,1); {1 is needed to set one block size to one byte(default is 512
bytes)}
blockwrite(f,ptr($a000,0)?,65536); {ptr($a000,0)? is video memory - it will
be written directly from video meory to disk. If you want to read from file,
then just change BlockWrite to BlockRead and ReWrite to ReSet}
close(f);
end;


Quote:
> How can I save the screen of a graph program? How can I save a picture
thats
> been created by graph???
>  Thanks Jan



Wed, 18 Jun 1902 08:00:00 GMT  
 how to save a graphfile

Quote:



> >How can I save the screen of a graph program? How can I save a picture thats
> >been created by graph???

> If you do not need any standard format, then you can use getimage and
> putimage with blockwrite/brockread. However, as those are limited to
> 64K, you have to do it in parts. You can use imagesize to check how many
> parts you need. Or on 16-bit modes you can use the fact that a pixel
> takes 4 bits.  You can store the 640x480x16 screen in three parts.

Or search for pasjpeg (or its porter Jacques Nomssi Nzali)
( I never tried with TP though, but FPC eats it, and the library is
16-bit compatible), to make output to bmp or jpg possible.

The problem will possibly be how to pass image data so that pasjpeg will
accept it, which might not be possible for a beginner, (I don't know the
skill level of the originator) but it could be as simple as getimage
format, with or without the dimensions prepended



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How do I save a table using a standard save dialog?

2. DB records not saving!

3. ado save question

4. save mutiple writeln's into an array

5. How to save an image in a database

6. Save to/read from BLOB-fields

7. How can I save SQL Query results?

8. Saving Binary Files

9. Saving Table Changes and Power Outages

10. How to Save a Visual Components Formula One WorkBook to a Database BLOB field

11. How do I save query results?

12. Howto: Save Columns of a TDBGrid ???

 

 
Powered by phpBB® Forum Software