Filter support has been up and down since v8.9.5. Lots of wonderful changes happening, and, well, …to make an omelette…
Can you please try branch “develop-v9”, where filters should work fine?
If it doesn’t work as expected there, please respond.
I’m use other example ,I use the same typescript code in three openfl version,
when use the openfl 8.9.6,effect preview.bitmap is draw from the Sprite.but filter cann’t work.
when use in the openfl develop-v9,filter can work,but bitmap cann’t display that draw from the Sprite
when use in the openfl 9.8.5 .filter can work,bitmap cann’t display that draw from the Sprite.
this example code eg:
var sprite=new Sprite();
sprite.graphics.beginFill(0xffff41,1);
sprite.graphics.drawRect(0,0,50,50);
sprite.graphics.endFill();
sprite.filters=[new GlowFilter(0xff0000, 1, 5, 5, 1, 1,true)] ;
this.addChild(sprite)
var newBitmapData=new BitmapData(sprite.width,sprite.height);
newBitmapData.draw(sprite);
var newBitmap=new Bitmap(newBitmapData);
newBitmap.x=100;
this.addChild(newBitmap)
I just moved the newer GlowFilter improvements for the Context3D renderer to the ‘develop’ branch on Github. Here’s how it looks:
(This should be the best of the above screenshots where the displayed version has the full filter and the bitmapData.draw version at least preserves the original fill)
The issue is that glow has been implemented in OpenGL shaders but has not been implemented for an inner glow in software. bitmapData.draw by default runs in software so that you can getPixel on the results
Long-term I think the best solution is for us to get more complete filter implementations in both hardware and software, but there’s a workaround you can use in order to force bitmapData.draw to use hardware instead of software. It does mean you cannot “read” the pixels again later (such as getPixels()) but it is useful for caching:
var newBitmapData=new BitmapData(sprite.width,sprite.height);
newBitmapData.disposeImage(); // force hardware
newBitmapData.draw(sprite);
var newBitmap=new Bitmap(newBitmapData);
newBitmap.x=100;
this.addChild(newBitmap)