Hi! I’m trying to import an image and assign it to a Loader object, which works just fine, though I want to use the PNGEncoder rather than a the JPGEncoder, because if the source image has an alpha channel (transparency) I want that data preserved.
The code, or the encoder, or something is preventing or deleting the alpha channel data. What should be transparent is showing as white.
I anyone could point out the error I’d much appreciate it… This is my last major task and has been stumping me for months!
Thanks!
(Snip of code is below)
import com.adobe.images.PNGEncoder;
function Editor_fileLoadedCallback(event:Event):void
{
bytes=fileRef.data;
trace("Editor_fileLoadedCallback(event:Event) fileLoaded Complete, " + bytes.length + " bytes.");
_imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, _onByteLoad);
_imageLoader.loadBytes(bytes);
}
function _onByteLoad(e:Event):void
{
var scaleWidth:int = 300;
var content:Bitmap = _imageLoader.content as Bitmap;
content.smoothing = true;
var origWidth:Number = content.width;
content.width = scaleWidth;
content.scaleY = 1 / (origWidth / scaleWidth);
var m:Matrix = new Matrix(content.scaleX, 0, 0, content.scaleY);
var smaller:BitmapData = new BitmapData(scaleWidth, content.height, false);
smaller.draw(content, m);
_loaderByteArray = PNGEncoder.encode(smaller);
_loader.loadBytes(_loaderByteArray);
}