[SOLVED] Rendering issue with Starling Image from Bitmapdata

Hi there,

When I try to create a Starling Image from a vector Flash Sprite, with an intermediate Bitmapdata, the rendering is weird…


// creating a new instance of my Flash Sprite
var sprite:MyFlashVectorSprite = new MyFlashVectorSprite();

// converting it in Bitmapdata
var bmd:BitmapData = DisplayObjectHelper.fromDisplayObjectToBitmapData(cast(sprite));

// creating a new bitmap with this bitmapdata and adding the bitmap...
// to the root scene to check if it is nice (the result is the left image)
var bm:Bitmap = new Bitmap(bmd, null, true);
AppData.MAIN.addChild(bm);

// creating the starling image (the result is the right image)
var starlingTexture:Texture = Texture.fromBitmapData(bmd, false);
var starlingImage:Image = new Image(starlingTexture);
starlingImage.x = 500;
addChild(starlingImage);

Am I doing something wrong ?
The odd is that it is working with very simple vector shapes as a circle or a rectangle…

Thanks for your help.

I forgot to mention that I use Starling 1.8.

I think I understood the problem:

To convert my Flash Sprite to Bitmapdata, I was using:

var bmd : BitmapData = new BitmapData(cast(dob.width), cast(dob.height), true, 0xFFFFFF);

And it’s OK for OpenFL but not for Starling that needs a more secure casting:

var bmd : BitmapData = new BitmapData(Std.int(dob.width), Std.int(dob.height), true, 0xFFFFFF);

When using “cast()”, the generated Bitmapdata width end height were not Int…and Starling did not like this.

2 Likes