You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by "rodolpho@essencialcode.com.br" <ro...@essencialcode.com.br> on 2017/05/26 18:23:27 UTC

Re: MultiDPIBitmapSource multiple use

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");



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/MultiDPIBitmapSource-multiple-use-tp15275p15276.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Re: MultiDPIBitmapSource multiple use

Posted by agm65 <ag...@gmx.de>.
thx alot!



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/MultiDPIBitmapSource-multiple-use-tp15275p15277.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.