locked
vb.net mobile app - hotspots on an image RRS feed

  • Question

  • Hi

    I have to write a windows mobile app - vb.net - vis studio 2008

    One thing I need to do is display an image of a horse (no kidding) and it will have various hotspots - e.g. click on the nose of the horse and it opens up a dialog to let you do certain actions - click on the fetlocks and it opens a different dialog

    Any pearls of wisdom on this with regard to the image manipulation stuff ?

    Thanks
    Bruce

    Thanks
    Bruce





    Tuesday, January 5, 2010 5:28 AM

Answers

  • You can use pictureboxes, one for each part.
    To assign the images, you can extract the part of the horse image your picturebox is located at, for example:

    Dim partOfHorseImage As New Bitmap(bounds.Width, bounds.Height)
    Using gx As Graphics = Graphics.FromImage(partOfHorseImage )
        gx.DrawImage(horseImage, New Rectangle(0, 0, partOfHorseImage.Width, partOfHorseImage.Height), bounds, GraphicsUnit.Pixel)
    End Using
    pictureBox.Image = partOfHorseImage

    Where bounds is picturebox bounds.
    Then you can handle the mouseclick event of the picturebox.

    Ray
    • Marked as answer by warrentang Monday, January 11, 2010 3:42 AM
    Tuesday, January 5, 2010 5:45 AM
  • You can also handle the PictureBox.MouseDown event and do some hit-testing there. The MouseEventArgs argument has the click location. 

            private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
            {
                Point location = new Point(e.X, e.Y);
            }

    Please mark the post that helps you, and unmark that does not. This benefits our community.
    • Marked as answer by warrentang Monday, January 11, 2010 3:42 AM
    Thursday, January 7, 2010 7:15 AM

All replies

  • You can use pictureboxes, one for each part.
    To assign the images, you can extract the part of the horse image your picturebox is located at, for example:

    Dim partOfHorseImage As New Bitmap(bounds.Width, bounds.Height)
    Using gx As Graphics = Graphics.FromImage(partOfHorseImage )
        gx.DrawImage(horseImage, New Rectangle(0, 0, partOfHorseImage.Width, partOfHorseImage.Height), bounds, GraphicsUnit.Pixel)
    End Using
    pictureBox.Image = partOfHorseImage

    Where bounds is picturebox bounds.
    Then you can handle the mouseclick event of the picturebox.

    Ray
    • Marked as answer by warrentang Monday, January 11, 2010 3:42 AM
    Tuesday, January 5, 2010 5:45 AM
  • You can also handle the PictureBox.MouseDown event and do some hit-testing there. The MouseEventArgs argument has the click location. 

            private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
            {
                Point location = new Point(e.X, e.Y);
            }

    Please mark the post that helps you, and unmark that does not. This benefits our community.
    • Marked as answer by warrentang Monday, January 11, 2010 3:42 AM
    Thursday, January 7, 2010 7:15 AM