Path: utzoo!news-server.csri.toronto.edu!rutgers!att!news.cs.indiana.edu!ux1.cso.uiuc.edu!s.psych.uiuc.edu!amead From: amead@s.psych.uiuc.edu (alan mead) Newsgroups: comp.lang.pascal Subject: Re: Displaying EGA/VGA graphics. (Screen Captures) Keywords: Screen capture/redisplay Message-ID: <1991Mar13.071250.11258@ux1.cso.uiuc.edu> Date: 13 Mar 91 07:12:50 GMT References: <3977@ac.dal.ca> <1991Mar13.041954.26340@ux1.cso.uiuc.edu> Sender: usenet@ux1.cso.uiuc.edu (News) Organization: University of Illinois at Urbana Lines: 118 amead@s.psych.uiuc.edu (alan mead) writes: >tjr@ac.dal.ca writes: >>I have been successful in displaying CGA bitmaps, but have not been >>able to get anywhere with the higher resolutions. Any help would be >>greatly appreciated. >This is the easiest way the caputure/display screens in TP: Well, I decided to just write it. Here it is. Sorry, but I seem unable to kill my original followup. This code seems to mistreat TP (or perhaps TP has a bug). There are lines left on the screen after restoring the captured image. To save the screen to disk, you need to write bytes equal to the Size field starting with the one pointed to by the Image field. Is that clear? Perhaps I'll add that later. ---------------------------------------------------------------------- program GraphicsScreenSave; uses graph; { PURPOSE: A quick graphics mode screen save demo routine WRITTEN: 03-12-91 by Alan D Mead COPYRIGHT: Feel free to use this code--however, if you use it without substantially modifying it, please give me credit. BUGS: What are those annoying lines at the top of each restored chuck? Use your own path in InitGraph This is the first linked list I've ever written :( } type ListPtr = ^ListType; ListType = record Image : pointer; Size : word; ULx, Uly : integer; next : ListPtr; end; var head, tail, P : ListPtr; { to the ends of a singly linked list } procedure ListInsert( L:ListPtr ); var p,pred:ListPtr; begin L^.Next := nil; if ( Head=nil ) then begin Head := L; Tail := L; end else begin tail^.next := L; Tail := L; end; end; procedure SaveScreen( ULx,ULy,LRx,LRy:integer ); var i,j,k : integer; Size:word; l:ListPtr; begin Size := ImageSize( ULx,ULy,LRx,LRy ); if Size = 0 then begin SaveScreen( ULx,ULy,LRx,2+(ULy+((LRy-ULy) DIV 2))); SaveScreen( ULx,(ULy-2+((LRy-ULy) DIV 2)),LRx,LRy ); end else begin new( l ); GetMem( l^.Image, Size); { Get memory from heap } GetImage( ULx,ULy,LRx,LRy,l^.Image ); l^.Size := Size; l^.ULx := ULx; l^.ULy := ULy; ListInsert( l ); end; end; var Gd, Gm : Integer; Size : Word; I : Integer; begin randomize; head := nil; tail := nil; Gd := Detect; InitGraph(Gd, Gm, 'C:\TP5'); if GraphResult <> grOk then Halt(1); for i := 1 to 10 do Bar( Random(50), Random(50), Random(GetMaxX), Random(GetMaxY)); SaveScreen( 0,0,GetMaxX,GetMaxY ); ReadLn; ClearDevice; p := head; while P <> nil do begin PutImage( P^.ULx, P^.ULy, P^.Image, NormalPut ); P := P^.next; { readln;} end; ReadLn; CloseGraph; end.