CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2002
    Posts
    60

    Several links in bitmaps

    HI,
    I would like to put a bitmap in my view. In the bitmap their are certain elements that I would like to behave as links. Those elements can have states, e.g enable(with colors) / disable (grayed).
    Does anyone has idea how can I do it?

  2. #2
    Join Date
    Feb 2002
    Posts
    60
    Hi,
    Maybe with an example the problem will be clearer.

    Lets say that I have a bitmap with a house, dog and a car in addition to other elements.

    1. In certain cases I want the house will be colorfull and in others grayed.
    This can be solved by creating the whole bitmap as much cases as I have (in our case: 2 states for 3 bitmaps, 2^3 bitmaps).
    Hard work but will work.

    2. I want to identify when the user clicks the house (or the dog or the house). I don't know how to identify a user click in part of the bitmap.

  3. #3
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210
    You can use PtInRegion() API to determine if the point is inside a region,,
    but this way you'll have to save region data with the bitmap (cerate you're own file format)
    or create the icture elements in fixed colors(grass in Green , cars in red etc) and use GetPixel() to get the color then the type of element.

  4. #4
    Join Date
    Feb 2002
    Posts
    60
    Hello,
    Thanks for the quick response.

    How can I obtain the region of certain element in bitmap?

  5. #5
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    I don't know much about graphics but I think Windows does not have support of that type of thing that is good as the support in HTML. However is it not true that in HTML it is necessary to specify what portion of an image is associated with a specific link?
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  6. #6
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210
    I think you'll have to get the coordinates for corners of the bitmap items ,, then use CreatePolygonRgn()
    how to get the corners ?
    i'm afraid you'll have to get them by eye !! or create a small utility to store that coordinates in text files (you click the point and the prog gets x,y and store them..
    Not a (best) solution .. but we are making a brain storming !!

  7. #7
    Join Date
    Sep 2002
    Location
    DC Metro Area, USA
    Posts
    1,509
    Originally posted by Haim B
    Hi,
    Maybe with an example the problem will be clearer.

    Lets say that I have a bitmap with a house, dog and a car in addition to other elements.

    1. In certain cases I want the house will be colorfull and in others grayed.
    This can be solved by creating the whole bitmap as much cases as I have (in our case: 2 states for 3 bitmaps, 2^3 bitmaps).
    Hard work but will work.

    2. I want to identify when the user clicks the house (or the dog or the house). I don't know how to identify a user click in part of the bitmap.
    It would be better to have the complete bitmap(background) and a bit map for each element's state i.e. house_en, house_dis, etc... This saves the complexity of selecting the appropiate bitmap and saves space as you're only storing the necessary delta's. It also helps in determining the clickable region. There is an example in the article section on making a "skinable" progress bar (click here). This should show you how to create a region from a bitmap (basically it uses a background color to determine what's in the desired portion of the image), you then can use that region with PtInRegion() to determine a hit.
    bytz
    --This signature left intentionally blank--

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured