BitmapData.draw() and android

Hi,

I can’t get drawing a Sprite to a Bitmap to work on android. Is this not implemented or am I just doing something terribly wrong?

class Main extends Sprite {	
	public function new () {	
		super ();
		var size = new Point( 400, 300 );
		
		var circle = new Sprite();
		circle.graphics.beginFill( 0xFF0000 );
		circle.graphics.drawCircle( 100, 100, 40 );
		circle.graphics.endFill();
			
		var bitmapData  = new BitmapData( Std.int(size.x), Std.int(size.y));
		bitmapData.draw( circle );
		var bitmap = new Bitmap( bitmapData );
		bitmap.y = size.y+1;
		
		addChild(circle);
		addChild(bitmap);
		
		graphics.beginFill( 0, 0 );
		graphics.lineStyle( 1, 0 );
		graphics.moveTo( 0, size.y );
		graphics.lineTo( size.x, size.y );
		graphics.endFill();
	}
}

Does it work when you target Windows/Mac/Linux (whatever your machine is)? How about Neko? All of those ought to use the same renderer, and they’re all easier to debug than Android.

Yup! Works for:

  • Windows
  • HTML5
  • Neko
  • Flash

.

I wonder if there’s something weird going on with the invisible fill you’re adding. Try it without “graphics.beginFill( 0, 0 );.”

Edit: now that I look at it again, that isn’t likely. Instead, try testing fillRect() to make sure that works.

Same thing with drawRect() .

I’ve also tried drawing a hexagon using moveTo and lineTo, with the same result.

(It’s actually from this, but simplified to better show the problem)

Actually, I was asking about this.

Displays a black rectangle for me, which I assume is tied to [this][1]. It may also be interesting to note the black rectangle is the size of the bitmap data, rather than the size of the filled rectangle.

    class Main extends Sprite {	
	public function new () {	
		super();
		var bitmapData  = new BitmapData( 400, 400);
		bitmapData.fillRect( new Rectangle( 0, 0, 40, 40 ), 0xFF336699 );
		var bitmap = new Bitmap( bitmapData );
		addChild(bitmap);
	}
}

I guess bitmaps are currently broken for android?
[1]: All images are black in android

Sounds like it.

Have you tried enabling legacy mode?

Both BitmapData.draw() and BitmapData.fillRect() work in legacy mode.
Also solves [the black images][1] issue and [the bunnymark crash][2].

Thanks for the help!
[1]: All images are black in android
[2]: Open fl sample bunnymark crash on android