Osmo Ronkan
Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:GETIMAGE Not Working - Better Code Example
In article <7nqcup$q1...@news2.tor.accglobal.net>, QuoteTransactoid <transact...@hotmail.com> wrote: >Thank you for your responses to my question. Here is a better example of the >code I'm using, which causes the error. >uses > Graph, crt, dos; >var Gd, Gm : integer; >var Window : array [1 .. 11] of record > x : integer; > y : integer; > x2 : integer; > y2 : integer; > P : pointer; > end; >procedure DrawWindow (handle : integer); > var x1, y1, x2, y2 : integer; > var Size : integer; > begin > x1 := Window[handle].x; > y1 := Window[handle].y; > x2 := Window[handle].x2; > y2 := Window[handle].y2; > Size := ImageSize(x1,y1,x2,y2); > GetMem(Window[handle].P, Size); > GetImage(x1,y1,x2,y2,Window[handle].P^); > {Commands to draw window > . > . > . > } > end; >begin >Gd := Detect; InitGraph(Gd, Gm, 'c:\tp\bgi'); >Window[1].x := 20; >Window[1].y := 20; >Window[1].x2 := 400; >Window[1].y2 := 400;
Come on, that is 144,000 pixles. At 16 colors it is 72,200 bytes (+a few for book keeping). You need to do it in parts of no less than about 64K. Quote>DrawWindow (1); >readln; >end. >Someone mentioned it could be exceeding 64k and would have to be split up. >This is entirely possible; the windows are large, and it is in 640x480 mode. >So how would I go about splitting it up?
Simply get window (20,20),(199,400) and (200,400),(200,400) separately. In a more generic case use imagesize to to estimate how much you can get at once. For example use imagesize() to check how much one pixel row in your image takes, then divide 65500 by that and you get how many rows you can safely take with one getimage(). On 16 color modes you could also use the fact that one pixel takes 4 bits, i.e. 2 pixels take one byte, in addition there is some book keeping (IIRC about a 6-12 bytes) Osmo
|