I've been trying to figure out how to dynamically allocate memory to be used as a screen buffer to display AggPas generated images with PTCGraph. I don't want it hard coded because I do not know what resolution monitor is going to be used. Here is where I am at:
I can define a static variable like this: Const RGB_Width = 2; Buffer_Width=1920; Buffer_Height=1280; Type TGraphBitmapBuffer=packed record width, height, reserved: LongInt; data: array[0.. (Buffer_Width+1) * (Buffer_Height+1)] of word; // I don't know why I need the +1's but it won't work without them End; Var graph_buffer: TGraphBitmapBuffer; Then I attach it to AggPas with: agg^.attach(@graph_buffer.data, graph_buffer.width, graph_buffer.height, - graph_buffer.width * RGB_Width); Then I put it on the screen with: PutImage(0,0,graph_buffer,NormalPut); I should point out that I like to do this: Original_screen:=graph_buffer; to save my screen then put new stuff on it, then just copy back the original and putimage it back when I'm done. So I need a solution that will allow me to do this. I also don't always use the whole screen, sometimes I just want to getimage a little area, and putimage that back... but I don't know the size of these areas... they are calculated based on the resolution of the monitor and various settings and configurations. Here is where I am at with my attempt to make the memory dynamically allocated: I can use a dynamic method with PTCGraph with getimage and putimage But if I allocate memory this way, while it works fine with getimage and putimage, I can't figure out how to use it with AggPas because the first 3 words are not part of the bitmap data... It seems like there should be a way to make this work but the solution eludes me. I've been trying to come up with a way to do *something* like this: Var graph_buffer: Pointer; Max_X, Max_Y: Word; Max_X:=1920; //these will be detected by PTCGraph... Max_Y:=1280; Size := ImageSize(0, 0, Max_X-1, Max_Y-1); GetMem(graph_buffer, Size); GetImage(0, 0, Max_X-1, Max_Y-1, graph_buffer^); agg^.attach(@graph_buffer[12], Max_X-1,Max_Y-1, -(Max_X-1) * RGB_Width); //graph_buffer[12] is to skip over the 3 longints 4 bytes each PutImage(0,0,graph_buffer^,NormalPut); The problem is with Agg^.attac() of course now graph_buffer isn't an array anymore... so what I have won't work and I haven' figured out how to attach AggPas at a position where the bitmap data is so I can use PutImage and still have the Longints that were put in by GetImage. Any advice is greatly appreciated James _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal