Sign in to follow this  
gunner_uk2000

Splicing an image or serval smaller images...

Recommended Posts

In an application I am working on, mostly written by someone else who has spent around a year writing it, my job is to make it into a releasable product... There is a sprite based toolbar along with a bitmap with all the buttons images including pressed/unpressed/locked images all on one big bitmap. When it comes to drawing the toolbar this image is cut up using the parameter in Sprite::Draw() which defines the rectangle to draw the image from. These values are all hard coded, and any time you want add a new buttons you have to edit this bitmap in paint. There is also problems such as the whole thing is designed for buttons only ie a slider bar is going to want to be draw in a different way to the button. (ie a background image, with the bar drawn over it). This makes it very difficult to add things to the toolbar, which is going to need to happen if the software is going to be in a releasable state. As to have a slider you'd have to store the bar co-ordinates in the pressed image rectangle. Before I do this I need to know does splicing a large bitmap up have any SIGNIFICANT performance advantages over have several smaller (no more than 20-30) sprites in the toolbar. Thanks for any help. ------gunner_uk2000----------

Share this post


Link to post
Share on other sites
Hey.

I don't know what API we are talking here, but in general there is a trade-off between the two approaches:

Multiple bitmaps require slightly more space to store due to the additional overhead of describing each image, although this is trivial. It also implies more files that the app depends on (unless the bitmaps are stored as resources).

A single bitmap requires slightly more computation when being split up to draw each cell, although again this is pretty trivial.

If you put aside the trivial performance questions, perhaps the most flexible solution would be to create a container class of individual images that supported a method that allowed you to load either single or strip images seperately and stored them all in a uniform manner, either by maintaining a single internal image and copying them onto that, or storing individual images and splitting up strip images when they are loaded.

The Win32 image list from the common controls library must use one of the above approaches. I'd assume the former since all the images need to be the same size.

You could then load both strips and single images, even selected dynamically, into the same container and present a uniform interface to the drawing code.

Just a thought.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this