Reputation: 5818
Been trying to smooth images loaded with FileReferece with no luck. Below is the code I'm using:
fileRef = new FileReference();
fileRef.addEventListener(Event.COMPLETE, fileLoaded);
private function fileLoaded(e:Event):void{
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void{
var bm:Bitmap = Bitmap(e.target.content as Bitmap);
bm.smoothing = true;
img.load(bm)
});
ldr.loadBytes(fileRef.data);
}
<custom:SWFLoaderAdvanced id="img"/>
bm.smoothing should've smoothened the loaded image, but for some reason it doesn't. Am I missing something here?
Note: SWFLoaderAdvanced automatically smoothens any image that's loaded inside it. It works perfectly with loaded images other than the ones loaded with FileReference.
Upvotes: 1
Views: 1377
Reputation: 910
I'm not sure why bm.smoothing
isn't working, perhaps it is but the effect is barely noticeable. One thing you could try is a BlurFilter
.
import flash.filters.BlurFilter;
var blur:BlurFilter = new BlurFilter(1, 1, 5);
Where the first and second arguments are blurX
and blurY
, and the third is the quality. I imagine you can apply this to a Bitmap
object, probably using this function:
bitmapDataObject.applyFilter();
That function is detailed further in the AS3 Reference; I'm not at a computer with Flash installed so I can't test exactly how this would work. You will definitely be able to apply blur effects to Bitmap
objects though, and if you do a very slight one with high quality, it'll appear to smooth the image. Check out BlurFilter
and BitmapData
in the docs.
Hope this helps!
Upvotes: 0
Reputation: 2051
I believe that the data is loaded into flash as byteArray, try this and see what happens.
your line here:
var bm:Bitmap = Bitmap(e.target.content as Bitmap);
wants to be:
var bm:Bitmap = new Bitmap(e.target.content as BitmapData);
Upvotes: 1