-
December 21st, 2008, 06:08 AM
#1
Hotspots in .Net
Hi All
I am creating a Windows based application, my main screen is based on a picture, instead of using buttons, I would like to create hotspots on the picture for navigation, is this possible in the .net Windows application, this is not for the web.
Cheers
Djbel
-
December 21st, 2008, 07:41 PM
#2
Re: Hotspots in .Net
You can load an image directly onto a form, or onto a picturebox control. Then, you can capture mouse clicks, and compare the location to 'spots' that you activate, and fire in the 'click event' and produce the action.
-
December 22nd, 2008, 05:11 AM
#3
Re: Hotspots in .Net
Hi dglienna
Thanks for the reply. unfortuantly I am not exactly clear on what you mean. Do you mean have a set of cordinates for each area, then take the position of a mouse click and check if it is within a set of coordinates, if it is then fire a click event? If this is the case just got a couple of questions, how do I set up a coordinate location for an area on a picture and secondly how would I do this for complex shapes such as circles, ect?
Cheers
Djbell
-
December 22nd, 2008, 06:18 AM
#4
Re: Hotspots in .Net
It is going be a bit more complicated if you are using irregular shaped hotspots.
Using the mouseup event will give you coordinates clicked in the picbox. You will need a way to determine which region the clicked coordinates are in.
Rectangular and circular regions should be relatively easy. I would create a class for your regions containing the following vars: region_type (enum), parameter1, parameter2
region_type specifies whether the region is circular or rectangular. If circular, parameter1 is midpoint of circle and parameter2 is radius. If rectangular, parameter1 is upper left corner and parameter2 is lower right.
You will need a routine that accepts your coordinates, checks through your regions and calls the appropriate function (this could happen in the region class if you do it that way).
ps: have you looked at WPF ? I think this can be done on a WPF form.
Last edited by HairyMonkeyMan; December 22nd, 2008 at 06:40 AM.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010
-
December 22nd, 2008, 07:18 PM
#5
Re: Hotspots in .Net
Not with a class of shapes, if they are all the same size (within circle or square dim's)
Gets more complex with different sized shape, though
-
December 23rd, 2008, 12:40 AM
#6
Re: Hotspots in .Net
IF you control the picture, there is a simple trick...Use the LSB of each color. This allows for 7 hotspots in an impage without ANY calculations.
Stegography in action!!!!
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
December 23rd, 2008, 12:49 AM
#7
Re: Hotspots in .Net
Which 7 are those?
-
December 23rd, 2008, 10:59 AM
#8
Re: Hotspots in .Net
Originally Posted by dglienna
Which 7 are those?
Use a 24/32 bit format. Make sure the "real" picture has only EVEN color values (LSB or R,G,B are 0.)
Now modify the picture to the the LSB to 001,010,011,100,101,110,111 (R,G,B) for seven different areas.
Now when you geta click, look at a the pixel. Grab the LSB of R,G,B; combine. If 000 then not a hotspot, otherwise it is one of the 7...
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
January 16th, 2009, 02:31 AM
#9
Re: Hotspots in .Net
I made it even easier than that ...
Because Pic2 is a background mask, and the user does not get to see it, i used all the greyscale bits, giving me 256 different regions. (&H00 - &HFF) ..
I used white (&HFF) as the base region, or background, non hotspot. and painted each region needed as a hotspot with a different color.
So for the first region i used black (&H00).. For region 2, I could have used the next color (&H01) but i jumped a few to visually show the different regions in the masked image. So region 2 is color 10 (&H0A), region 3 = 20 (&H14) .. etc
Esentually you use each available color as a region, and can have 255 hotspot regions set in the image.
Gremmy..
Last edited by GremlinSA; January 16th, 2009 at 02:33 AM.
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
January 16th, 2009, 02:54 AM
#10
Re: Hotspots in .Net
OK. That makes sense. I've used a Mask image before, but it was two-color only
-
January 16th, 2009, 08:38 AM
#11
Re: Hotspots in .Net
Originally Posted by GremlinSA
I made it even easier than that ...
Because Pic2 is a background mask,.....
That is a clean and usually better approach....but, the original post:
Technically eliminated any approach where 2 images (one for display one for mask) was used.
Once one "plays with" the two image approach and is comfortable in understanding its operation, it should not be difficult to make the jump to slight restrictions in the image colors. e.g. only even shades so that the least significant bit is not used to convey color, but rather conveys (part of) the mask.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
January 16th, 2009, 02:58 PM
#12
Re: Hotspots in .Net
TheCPUWizard,
Man, you just disagree with everything.
Technically, the original post didn't say
"based on one picture"
That was your own mental restriction.
-
January 16th, 2009, 03:10 PM
#13
Re: Hotspots in .Net
Once one "plays with" the two image approach and is comfortable in understanding its operation, it should not be difficult to make the jump to slight restrictions in the image colors. e.g. only even shades so that the least significant bit is not used to convey color, but rather conveys (part of) the mask.
Have any code? I was trying to figure out how you'd go about setting LSB of the original image...
-
January 16th, 2009, 03:42 PM
#14
Re: Hotspots in .Net
Originally Posted by dglienna
Have any code? I was trying to figure out how you'd go about setting LSB of the original image...
I answered that publically back in Reply #8, (and also sent you detailed information via PM....
Step #1: AND each pixel with 0xFFFEFEFE
Step #2: Convert Hot Spot ID 1-7 into 0X000001, 0X0000100, 0X0000101, 0X010000, 0x010001, 0x010100, 0x010101
Step #3: Or Value with color.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
January 16th, 2009, 08:37 PM
#15
Re: Hotspots in .Net
For those who can not find the original material on stegography and its utilization for hotspots, or have problems with the c++ implementation in the article, here is a (non-optimized) VB.NET
Code:
Public Shared Sub Encode(ByVal src As Bitmap, ByVal mask As Bitmap, ByVal key As List(Of Color))
Dim x As Integer
For x = 0 To src.Width - 1
Dim y As Integer
For y = 0 To src.Height - 1
Dim rgb As Integer = (src.GetPixel(x, y).ToArgb And -65794)
Dim m As Integer = key.IndexOf(mask.GetPixel(x, y))
rgb = (rgb Or HotSpot.t(m))
src.SetPixel(x, y, Color.FromArgb(rgb))
Next y
Next x
End Sub
Public Shared Function HotIndex(ByVal src As Bitmap, ByVal x As Integer, ByVal y As Integer) As Integer
Dim m As Integer = (src.GetPixel(x, y).ToArgb And &H10101)
Dim i As Integer
For i = 0 To 8 - 1
If (HotSpot.t(i) = m) Then
Return i
End If
Next i
Return 0
End Function
Shared Sub New()
HotSpot.t = New Integer() { 0, 1, &H100, &H101, &H10000, &H10001, &H10100, &H10101 }
End Sub
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|