views:

515

answers:

1

hello, i'm developping an application in CF 3.5 for windows Mobile 6 Pro using C# and i have a little issue requiring the advice of someone that knows better.

Basically, i want my application to run and scale on multiple device sizes and resolutions. Eveything scales properly but the images. Some images that are for example 16X16 will look very small on a high resolution screen, so I want to display a 32X32 image, but I don't know what's the best way to decide which image size to display.

I have the option to check the dpi and then manually choose which image to display, but it seems like dirty work.

Isn't there any way to do it otherwise or what's the best way to do it?

A: 

I recommend that you create a layer between your forms and the images. Create a new class that would be responsible for returning the correct sized image. The code in your forms will rely on that to get the image and would have to know nothing about the sizes. For example:

mypicturebox.Image = ImageFactory.Image01;

The good thing is that you can use any technique you want inside the ImageFactory without affecting the rest of the code. The easiest thing to do is to check the size of the screen (using Screen.PrimaryScreen.WorkingArea) and do a manual decision.

kgiannakakis
thank you for the reply.I'm definitely going to do a layer.one last thing: Is it better to have the images in a resource file or in a folder within the app?
jeremy
Having the images in the resource file makes your code simpler (single line of code to load - no error checking) and probably faster. Deployment is also simpler. Store the images in a folder only if you expect to modify them often.
kgiannakakis