HTML5 : Starling 2 drawToBitmapData() not transparent


when I use drawToBitmapData() on HTML5, the BitmapData is not transparent but black


My code


import flash.display.Bitmap;
import flash.display.BitmapData;

import starling.display.Canvas;
import starling.display.Image;
import starling.display.Sprite;
import starling.textures.Texture;

@:keep class DrawToBitmapData extends Sprite
	private var canvas: Canvas = new Canvas();
	public function new()
	public function start():Void
		canvas.x = canvas.y = 100;
		canvas.drawRectangle(0, 0, 50, 50);
		canvas.rotation = 0.1;
	private function drawBitmap() : Void
		var bitmapData : BitmapData = canvas.drawToBitmapData();
		this.addChild( new Image( Texture.fromBitmap( new Bitmap( bitmapData ) ) ) );

Thanks for the sample

This is resolved:

These should fix it so <window color-depth="32" /> or openfl test html5 --window-color-depth=32 fixes the issue. It will enable alpha on a WebGL context, and on native increase the bit depth from 16 to 32-bit, requiring more memory, but allowing for alpha in the GL framebuffer :slight_smile:

I tried <window color-depth="32" /> but it doesn’t work ?

It is fixed only after using the latest development version of Lime and OpenFL, with the changes I posted above. It should work better in the next release

I use lime 5,8,1 and openfl 6,4,0, thanks.
I try it later.