Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-02

Graph Unit

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Olaf Leidinger

Hello Everybody!

Is there an example of bitmap-handling in the graph unit. I'd like to use them as a kind of off-screen sourfaces (e.g. for drawing onto them).

The Unit-Reference sais about GetImage:

"Bitmap must have enough room to contain the image."

Well, how do I allocate a bitmap?

And can I draw to it?

Ciao

Olaf

Shifted Soul
to Olaf Leidinger

This what the help of Borland Pascal 7.0 tells :
"BitMap is an untyped parameter that must be greater than or equal to 6 plus the amount of area defined by the region. The first two words of BitMap store the width
and height of the region. The third word is reserved." after these six bytes the remaining is for the bitmap. then :

Well, how do I allocate a bitmap?
You must use the ImageSize function and use a pointer to allocate the memory
needed like this :
program image;
uses graph;
var
  img : pointer;
  imgSize
begin
  {code for initialisation of graphic mode ...}
  imgSize:=ImageSize(100,100,200,200);
  getmem(img,imgSize);
  getImage(100,100,200,200,img);
  PutImage(300,300,img,CopyPut);
  freemem(img,imgSize);
  {other code ...}
end.
And can I draw to it?

You can now use the pointer to draw to it or save its contents to a file (or what you like).Example : if you use a 16bit color mode then you have to fill with double words your memory space which is pointed by img.

Ciao

bye

Andreas K. Foerster
to Olaf Leidinger: Hello Everybody! Is there an example of bitmap-handling in the graph unit. I'd like to…
Olaf Leidinger wrote
Is there an example of bitmap-handling in the graph unit. I'd like to use them as a kind of off-screen sourfaces (e.g. for drawing onto them).

If you want to make "off-screen" drawing, have a look at the procedures SetActivePage and SetVisualPage.

Example:

SetVisualPage(0); SetActivePage(1);
{... draw draw draw - invisible}
SetVisualPage(1); { there it is }

Tschuess Andreas
Olaf Leidinger
to Andreas K. Foerster
Andreas K. Foerster wrote 14 lines
On Wed, Feb 13, 2002 at 08:27:35PM +0100, Olaf Leidinger wrote: > Is there an example of bitmap-handling in the graph unit. I'd like to > use them as a kind of off-screen sourfaces (e.g. for drawing onto them). If you want to make "off-screen" drawing, have a look at the procedures SetActivePage and SetVisualPage. Example: SetVisualPage(0); SetActivePage(1); {... draw draw draw - invisible} SetVisualPage(1); { there it is }

Well, I tested it on Windows 2000 but it didn't work. The drawing was very visible (if you know what I mean). Are these functions perhaps simply dummy-functions on windows?

Ciao,

Olaf

Andreas K. Foerster
to Olaf Leidinger
Olaf Leidinger wrote 7 lines
> SetVisualPage(0); SetActivePage(1); > {... draw draw draw - invisible} > SetVisualPage(1); { there it is } Well, I tested it on Windows 2000 but it didn't work. The drawing was very visible (if you know what I mean). Are these functions perhaps simply dummy-functions on windows?

Arrgl, sorry you're right.
I've looked it up in the source code of 1.0.4...

It's not yet implemented.
Neither for Windows nor for Linux. :-(
But for DOS it is...

Tschuess Andreas