Hi Yannick!
I solved it with your advice. Maybe not so elegant, but works, with some limitations - import format.SVG is needed.
I modified the
cocktail.port.platform.flash_player.ImageResource.hx to load the image into ByteArray first with a _bin_loader:URLLoader.
cast(_bin_loader.data, ByteArray).position = 0; // to the first byte - maybe this is not needed here
if (cast(_bin_loader.data, ByteArray).readUTFBytes(5) == "<?xml") // SVG loaded
{
cast(_bin_loader.data, ByteArray).position = 0; // to the first byte
var svg:SVG = new SVG( cast(_bin_loader.data, ByteArray).readUTFBytes(_bin_loader.data.length) );
var sh = new Shape();
svg.render(sh.graphics, 0, 0);
// create a transparent bitmap
nativeResource = new BitmapData(Math.ceil(sh.getBounds(sh).right), Math.ceil(sh.getBounds(sh).bottom), true, 0);
nativeResource.draw(sh);
setSVGIntrinsicDimensions(nativeResource.width, nativeResource.height);
onLoadComplete();
}
else // This is not SVG, so this is a normal image.
{
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onNativeLoadComplete);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onNativeLoadIOError);
_loader.loadBytes(_bin_loader.data); // load the bytes
}
The first limitation of this solution, that we need to convert the vector SVG into BitmapData.
The second one is that if the SVG is wrong positioned, and some graphics extends over the left, or top, that will be cropped.
That's all!
Thanks again your help, I'm appreciate it!
Cheers!Cheers!
Tom