Detecting portions of bitmap clicked on

Discussion in 'Questions (Windows Mobile)' started by wize999, Feb 27, 2009.

  1. wize999

    wize999 New Member Licensed User

    Hi,
    I have a bitmap that is made up of various different areas. These areas are not simple squares but odd shapes. Is there any way I can detect if the user clicks on a particular area? Also some are the same colour as others but have a border around. An example is a map divided up in counties that have differend shading.

    Apologies if the answer is obvious but I'm new to coding but I have some great ideas!

    Thanks in advance.:)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    I don't think that there is a simple solution for this.
    One thing you can do is using an image editing application create a copy of your image and paint each section with a specific color.
    Now draw the original image on the forelayer with Form.FDrawImage and draw the colorized image on the background with Form.DrawImage (it will be hidden from the user).
    When the user clicks on your image you should use Form_MouseUp event and check the value of Form.GetPixel(x,y). According to this value you can decide which region was clicked.
    Note that you should not rely on any specific color value as different devices may return slightly different values. Instead at runtime check some known coordinates and save there values.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice