Code example for Picture

Methods: getHeight, getWidth

0
		float targetH = bottom - top;
		float targetR = targetW / targetH;
 
		// Source picture and its dimensions 
		Picture picture = svg.getPicture();
		float sourceW = picture.getWidth();
		float sourceH = picture.getHeight();
		float sourceR = sourceW / sourceH;
 
		// Find the best size for the final image 
		float finalS;
		if (targetR > sourceR) {
			// Target ratio is wider than source, use source height 
			finalS = targetH / sourceH;
		} else { 
			// Target ratio is taller than source, use source width 
			finalS = targetW / sourceW;
		} 
		int finalW = Math.round(sourceW * finalS);
		int finalH = Math.round(sourceH * finalS);