I tried using SVG assets for Android, it works okay on Neko target (desktop with the base default resolution), but on Android (N5), the resulting Bitmap is jagged (very visible). I tried smoothing both the BitmapData.draw and the Bitmap. Still jagged. Basically what I did was, I calculate the scaleFactor from the screen size compared to the base default resolution, and then render the SVG with
… in other words, what is “the base default resolution?” Is it “SVG.data.width?” I surmise that “screen size” is the size of the Stage …
Unfortunately it’s a throwaway code. But I’ll try to explain it further.
base defautl resolution is the resolution that I use in project.xml (in non mobile target, neko, windows), which I usually set to 480x640
scaleFactor is calculated as mobile screen height / 640 (base height).
I assume that with SVG if I’m drawing a cicle, and the size (in pixel) that I request is larger than the default size that come from the SVG (SVG.data.width & SVG.data.height), it will still be smooth. But in reality, it was jagged.
Here is how I was scaling svgs before I started using swf assets. It worked pretty well ( I was adding shapes to empty container, but it’s not necessary). Also remember about setting antialiasing to 3 or 4 in application.xml.
private function setup(path:String, scaleType:String = "x"):BitmapData
{
var svg:SVG;
var shape:Shape;
svg = new SVG(Assets.getText(path));
shape = new Shape();
svg.render(shape.graphics);
var targetScale:Float;
if (scaleType == "y")targetScale = STAGE_HEIGHT / ASSETS_HEIGHT;
else targetScale = STAGE_WIDTH / ASSETS_WIDTH;
addChild(shape);
shape.scaleX = shape.scaleY = targetScale;
var bitmapData = new BitmapData(Math.ceil(width), Math.ceil(height), true, 0x00FFFFFF);
removeChild(shape);
return bitmapData;
}