Board index » delphi » Hot spots on graphics
Emiel Peeters
![]() Delphi Developer |
Emiel Peeters
![]() Delphi Developer |
Hot spots on graphics2006-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 |
RandomAccess
![]() Delphi Developer |
2006-05-16 08:35:12 PM
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 |
Emiel Peeters
![]() Delphi Developer |
2006-05-17 12:01:25 AM
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 QuoteIt's fairly easy to make your own if they are rectangular. |
Peter
![]() Delphi Developer |
2006-05-17 03:57:36 AM
Re:Hot spots on graphics
Emiel Peeters writes:
QuoteI'm lookings for a way to put several hotspots on a picture so I can 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 |
Ronaldo Souza
![]() Delphi Developer |
2006-05-17 07:40:21 AM
Re:Hot spots on graphics
Emiel Peeters writes:
QuoteHi, 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 |
RandomAccess
![]() Delphi Developer |
2006-05-17 03:49:04 PM
Re:Hot spots on graphics
Ok, then I'd suggest you take Ronaldo's advice.
best regards |
Andrew Jameson
![]() Delphi Developer |
2006-05-17 03:56:23 PM
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 |
Herre de Jonge
![]() Delphi Developer |
2006-05-17 05:48:02 PM
Re:Hot spots on graphicsQuoteYou don't actually need any components for that. If you display the accurate would be to save the position you get in OnMouseDown() and use that in the OnClick() event. Take care, Herre |
Joey
![]() Delphi Developer |
2006-05-18 03:37:54 PM
Re:Hot spots on graphics
Hi
try this component www.mirkes.de/en/delphi/vcls/rgnimg.php HTH QuoteI'm lookings for a way to put several hotspots on a picture so I can use |
Noener
![]() Delphi Developer |
2006-05-24 05:55:50 PM
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 |
Noener
![]() Delphi Developer |
2006-05-24 05:58:53 PM
Re:Hot spots on graphics
I cant email you an example using the Q&D method if you like...
|
Shaker
![]() Delphi Developer |
2006-05-25 10:19:18 AM
Re:Hot spots on graphics
i have this problem too..
Thank you all Noener can you show me an example if you can Thanks |
Shaker
![]() Delphi Developer |
2006-05-25 10:19:26 PM
Re:Hot spots on graphics
Great Example
thank you Noener |
Noener
![]() Delphi Developer |
2006-05-26 02:32:28 PM
Re:Hot spots on graphics
Pleasure. If you need anything else, let met know.
Shaker writes: QuoteGreat Example |