Someone sent the following comment directly to me:
> ... if he has a few of this click able images you need more memory
> for your map as it's bitmap if it's not 255 colors it's a big memory
> consumption...
Since the comment is valid here is my answer (also valid ;)
If you have a large screen image with a tiny round button - create a
small bitmap to cover this button only and store it along with
left,top pixel coordinates on the screen. You can have bunch of such
"clickable" areas if you want to minimize RAM.

There is another cool solution with some restrictions:
Use lower 2-3 bits in the Alpha channel of the visible image to store
the "click ID"
We need to use ARGB 32 bpp bitmap format so we have 8 bit to store
alpha (transparency)
However, in case of custom GUI the alpha layer usually set to the
completely non-transparent value.
If we add just a few bits of transparency just the end user most
likely won't see the difference.
But you can extract this value for the click point and get the code
from there.
There are two serious limitations:
1. Only a limited number of "click ID" can be supported otherwise end
user will see some artifacts around the click able areas.
2. The bitmap preparation becomes really tricky because you have to
set alpha level for a certain areas to some exact value.


On Dec 6, 3:08 am, bagelboy <[email protected]> wrote:
> It just so happens that each area of the image has a specific color,
> so that is an excellent idea, thanks very much for your suggestion.
>
> On Dec 6, 7:19 am, ip332 <[email protected]> wrote:
>
>
>
>
>
>
>
> > Here is a generic solution for handling any number of arbitrary shaped
> > hotspots:
> > 1) create additional bitmap (same size as what you plan to show on the
> > screen) and draw "hot areas" with a specific color. If you have less
> > than 255 hotspots then use 8bpp bitmap with background of color with
> > index 0. Draw the first hot spot with desired shape and color it with
> > index 1, then the second area - with index 2 and so on. Or you can do
> > it with 24bpp bitmap but assign each area a specific RGB combination.
> > 2) load this bitmap (let's call it "control") when your application
> > starts up.
> > 3) on screen click: convert screen coordinates into x,y from the
> > origin of your image (which can be larger than the screen)
> > 4) get pixel color from the control bitmap - if it is > 0 then it is a
> > hotspot index of code.
> > Good luck
> > Igor
>
> > On Dec 5, 5:43 am, bagelboy <[email protected]> wrote:
>
> > > I have an image and I want to make parts of it clickable. From my
> > > research I can see 2 ways to do this:
> > > 1) I could chop the image into pieces and put them into a relative
> > > layout
> > > 2) I could create a matrix of points that describe the clickable areas
> > > and use onTouch events to track clicks
>
> > > Option 1 has the drawback where you have to make areas square or
> > > rectangular, plus alignment and scaling are a pain.
>
> > > Option 2 can be scaled easier however I'm not sure how to go about
> > > coding it.
>
> > > Am I missing any possibilities? Are there any tools or source code
> > > that would make it easier?
>
> > > -BB

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to