MultiDPIBitmapSource multiple use

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

MultiDPIBitmapSource multiple use

agm65
This post has NOT been accepted by the mailing list yet.
Hi all,

how to define the MultiDPIBitmapSources global to multiuse them in my app?

Regards!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MultiDPIBitmapSource multiple use

rodolpho@essencialcode.com.br
See if this may help you:

Code:
public class ImageClassManager
{
        public static function getDPI(): void
        {
                var dpi: Number = Capabilities.screenDPI;
                                       
                if ((dpi > 0)&&(dpi < 240))
                        return 160;

                if ((dpi >= 240)&&(dpi < 320))
                        return 240;


                if ((dpi >= 320)&&(dpi < 480))
                        return 320;

                if ((dpi >= 480)&&(dpi < 640))
                        return 480;

                if (dpi >= 640)
                 return 640;
        }

                       
        public static function getImageSource(imageName: String):String
        {
                var path: String = "";
               
                switch (ImageClassManager.getDPI())
                {
                        case 160: path = "assets/images/160/" + imageName;
                                break;
                       
                        case 240: path = "assets/images/240/" + imageName;
                                break;
                       
                        case 320: path = "assets/images/320/" + imageName;
                                break;
                       
                        case 480: path = "assets/images/480/" + imageName;
                                break;
                       
                        case 640: path = "assets/images/480/" + imageName;
                                break;
                       
                        default:

                }
                return path;
        }
}



And use...

image.source = ImageClassManager.getImageSource("myImage.png");
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MultiDPIBitmapSource multiple use

agm65
thx alot!
Loading...