Jump to content
Excelsior Forums
ZVDP

Graph library and procedure point

Recommended Posts

Hello,

For a small school game project, I would like to read some pixels from the graph window.

According to the graph.def file, the procedure 'Point' is what I need,

but when I call it in my module, 'Point' always returns 0.

How do I use this procedure correctly, or is there another (relativly simple) way of getting the colour of a pixel?

Share this post


Link to post
Share on other sites

It seems to me the procedure Graph.Point() does not work at all, unfortunately. You may try to use the next, slightly ugly, code:

(* read pixel's color of the screen *)

PROCEDURE PointColor(x, y : LONGCARD): Windows.DWORD;

VAR

  gbm: Graph.HBITMAP;

  wbm: Windows.HBITMAP;

  color: Windows.DWORD;

BEGIN

  Graph.GetImage(x, y, x, y, gbm);

  wbm := Windows.HBITMAP(gbm);

  IF Windows.GetBitmapBits(wbm, SIZE(color), color) = 0 THEN

    color := Windows.DWORD(-1);

  END;

  Graph.DelImage(gbm);

  RETURN color;

END PointColor;

Note it return RGB color instead of an index of palette.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×