Board index » delphi » Hot spots on graphics

Hot spots on graphics


2006-05-16 03:16:36 AM
delphi117
Hi,
I'm lookings for a way to put several hotspots on a picture so I can use
them as a button. The shape of the hot spot is not really rectangulat. Is
this possible i n Delphi 7 or do I need to install extra components.
Does anybody have any suggestions where I can find these components (free if
possible..)
Thanks,
Emiel
 
 

Re:Hot spots on graphics

It's fairly easy to make your own if they are rectangular.
But we need to know more about what you are trying to achieve in order to
recommend an appropriate solution.
Best Regards
 

Re:Hot spots on graphics

I want to create a darts board and use a jpg as back ground in combination
with a touch screen. When you press 15, it is like you trow 15. The shapes
are basicly something like a piece of pie.
"RandomAccess" <XXXX@XXXXX.COM>schreef in bericht
Quote
It's fairly easy to make your own if they are rectangular.
But we need to know more about what you are trying to achieve in order to
recommend an appropriate solution.

Best Regards

 

Re:Hot spots on graphics

Emiel Peeters writes:
Quote
I'm lookings for a way to put several hotspots on a picture so I can
use them as a button. The shape of the hot spot is not really
rectangulat. Is this possible i n Delphi 7 or do I need to install
extra components.

Does anybody have any suggestions where I can find these components
(free if possible..)

You don't actually need any components for that. If you display the
picture in a TImage you can use the images OnClick event to detect a
click on the image. Use
var
Pt: TPoint;
begin
Pt := Image1.ScreenToClient(Mouse.CursorPos);
to get the position of the mouse in image-relative coordinates. Then
you "just" need to figure out if the click landed on one of your
pseudo-buttons.
--
Peter Below (TeamB)
Don't be a vampire (slash7.com/pages/vampires),
use the newsgroup archives :
www.tamaracka.com/search.htm
groups.google.com
www.prolix.be
 

Re:Hot spots on graphics

Emiel Peeters writes:
Quote
Hi,

I'm lookings for a way to put several hotspots on a picture so I can use
them as a button. The shape of the hot spot is not really rectangulat. Is
this possible i n Delphi 7 or do I need to install extra components.

Take a look at CreateRectRgnIndirect, CreateEllipticRgnIndirect and
CreatePolygonRgn. To test if a point is inside a region, use PtInRegion
in conjunction with GetCursorPos and ScreenToClient. Use FrameRgn to
draw a border around a region. Finally, use DeleteObject to free the
regions.
Good luck,
Ronaldo
 

Re:Hot spots on graphics

Ok, then I'd suggest you take Ronaldo's advice.
best regards
 

Re:Hot spots on graphics

Whilst you could define regions for every area that you need a hotspot, as
it's a dartboard it would seem much simpler to apply the x, y coordinates
mathematically as the dartboard layout does lend itself to be defined
mathematically ... its nothing more than a circle that has been cut into 20
segments ... the doubles, triples, and bull are concentric circles ...
Andrew
 

Re:Hot spots on graphics

Quote
You don't actually need any components for that. If you display the
picture in a TImage you can use the images OnClick event to detect a
click on the image. Use

var
Pt: TPoint;
begin
Pt := Image1.ScreenToClient(Mouse.CursorPos);
Rather I would use the OnMouseDown() event and get the mouse coordinates
where you actually clicked (touched the screen?). Or actually most
accurate would be to save the position you get in OnMouseDown() and
use that in the OnClick() event.
Take care,
Herre
 

Re:Hot spots on graphics

Hi
try this component
www.mirkes.de/en/delphi/vcls/rgnimg.php
HTH
Quote
I'm lookings for a way to put several hotspots on a picture so I can use
them as a button. The shape of the hot spot is not really rectangulat. Is
this possible i n Delphi 7 or do I need to install extra components.

Does anybody have any suggestions where I can find these components (free
if possible..)

 

Re:Hot spots on graphics

There is a Quick and Dirty approach to this:
Create an additional mask BITMAP and with unique colors in each region
you want to click on. Use a copy of your jpeg and just colour in each
area using paintshop or something similar.
Get the coordinates using Herre de Jonge's code:
"Pt := Image1.ScreenToClient(Mouse.CursorPos); "
and get the corresponding color on the mask bitmap using
mColor := Image2.Picture.Bitmap.Canvas.Pixels[Pt.X, Pt.y];
Case mColor of
clGray: Result := 1;
clRed: Result := 2;
clGreen Result := 3;
clOlive: Result := 4;
..... etc
end;
or just use a 256 color bitmap for the mask and fill the regions
starting with color 1 and skip the need for the case statement. Also
look at the GetRValue() function which return a specific RGB component
from a color.
Enjoy
 

Re:Hot spots on graphics

I cant email you an example using the Q&D method if you like...
 

Re:Hot spots on graphics

i have this problem too..
Thank you all
Noener can you show me an example if you can
Thanks
 

Re:Hot spots on graphics

Great Example
thank you Noener
 

Re:Hot spots on graphics

Pleasure. If you need anything else, let met know.
Shaker writes:
Quote
Great Example
thank you Noener