Lazarus

Free Pascal => Beginners => Topic started by: John_Nicol on June 18, 2017, 11:27:43 pm

Title: How to obtain/write to Imagecanvas, colour values for a given pixel in bitmap
Post by: John_Nicol on June 18, 2017, 11:27:43 pm
I want to be able to provide the pixel coordinates in a picture and obtain a numerical or string definition of the colour represented by that pixel.  Can someone provide a clear, simple code which will run in Lazrus Free Pascal? Thank you.
John Nicol
Title: Re: How to obtain/write to Imagecanvas, colour values for a given pixel in bitmap
Post by: Ian123 on June 19, 2017, 04:45:17 pm
The OP on this thread (http://forum.lazarus.freepascal.org/index.php?topic=23016.0) by wjackson153 (who credits taazz) has a little program that seems to do what you are looking for (if I am understanding what you are looking for).

1) Put 3 labels on a form and a shape and a timer
2) double click the timer to create its default event handler
3) Replace all the code in the unit with what's in the OP on that thread.

BTW I don't know if you'll have this problem but I am on windows and the program wouldn't compile until I got rid of the MouseAndKeyInput entry (and its preceding comma) in the uses clause
Title: Re: How to obtain/write to Imagecanvas, colour values for a given pixel in bitmap
Post by: taazz on June 19, 2017, 08:24:50 pm
BTW I don't know if you'll have this problem but I am on windows and the program wouldn't compile until I got rid of the MouseAndKeyInput entry (and its preceding comma) in the uses clause
http://wiki.freepascal.org/MouseAndKeyInput
Title: Re: How to obtain/write to Imagecanvas, colour values for a given pixel in bitmap
Post by: Ian123 on June 19, 2017, 11:22:26 pm
BTW I don't know if you'll have this problem but I am on windows and the program wouldn't compile until I got rid of the MouseAndKeyInput entry (and its preceding comma) in the uses clause
http://wiki.freepascal.org/MouseAndKeyInput

Thanks, I should have realised that the problem occurred because I had not installed that package.
Still, the program seems to work fine without it on windows
Title: Re: How to obtain/write to Imagecanvas, colour values for a given pixel in bitmap
Post by: taazz on June 20, 2017, 12:11:35 am
Still, the program seems to work fine without it on windows
Its not required it is a left over from the OPs previous attempts. I never noticed it.
Title: Re: How to obtain/write to Imagecanvas, colour values for a given pixel in bitmap
Post by: Handoko on June 20, 2017, 01:19:42 pm
The OP did a double post. I answered it on:
http://forum.lazarus.freepascal.org/index.php/topic,37242.msg249742.html#msg249742
TinyPortal © 2005-2018