Hello,
when I use drawToBitmapData() on HTML5, the BitmapData is not transparent but black
Thanks
My code
package;
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()
{
super();
}
public function start():Void
{
canvas.x = canvas.y = 100;
canvas.beginFill(0xFF0000);
canvas.drawRectangle(0, 0, 50, 50);
canvas.endFill();
canvas.rotation = 0.1;
this.addChild(canvas);
drawBitmap();
}
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
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.