开发者

Best way to represent icons on a background image

I have a map image (bitmap, ~4MB) that contains services (i.e. restrooms/elevators/exits/etc..) Based on user selection from a table I would like to show the map with the selected service only. For example, if the user selects restrooms the map appears with only restrooms colored/highlighted. I have the separate icons for the services. There are a few ways to do this:

a) Create static map images of each service (one with restrooms highlighte开发者_Python百科d, one with elevators highlighted, etc..) However that will use a lot of memory since I will store ~8 images one for each service (8*4MB)

b) Have one map image but dynamically draw the highlighted/selected icons over the map using coordinates. Very tedious, time consuming, and annoying.

Are there any other ways to go about this? Is there a way to reduce bmp file image size without obliterating the quality?

Thanks

Edit: Went with the static images choice a above. Converted bmp to png (went down from 4MB to 150KB).


Honestly, I would've thought that the first option would be "Very tedious, time consuming, and annoying."

Suppose you find out that another bathroom has been added. I'd much prefer to put in an X coordinate and a y coordinate and be done with it.

I'd create an array of x and y coordinates and use a for loop to add the bathrooms. Shove the icons in imageViews and be done with it.

// Mock code
for (Bathroom *bathroom in bathroomArray) {
    UIImageView *bathroomImgView = [[UIImageView alloc] init];
    bathroomImgView.image = [UIImage imageNamed:@"BathroomIcon.png"];
    bathroomImgView.center = CGPointMake(bathroom.x, bathroom.y);
    [mapHolder addObject:bathroomImgView];
}

The above code assumes that you have a UIView surrounding the bitmap of the map, and a bunch of custom objects that each have an x and y value in an array called bathroomArray.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜