I was searching for a way to convert a local image, which was saved in my “assets”-Folder to ByteArray.
Why did I need this? Well – I had got a model, which saved images as ByteArrays (so I could update it with the FileReference-Class easily), but wanted to set a default image into the mode.
[Bindable]
public class MyModelClass
{
[Embed(source="assets/myImage.png")]
private var myImage:Class;
public var imageToDisplay:ByteArray = new ByteArray();
public function MyModelClass(){
var bitmap:Bitmap = new myImage();
var bitmapData:BitmapData = bitmap.bitmapData;
bitmapData.draw(bitmap);
var encoder:PNGEncoder = new PNGEncoder();
imageToDisplay = encoder.encode(bitmapData);
}
}
November 8, 2010 at 1:26 pm |
Hi fightermv,
Can you help me with converting the embedded gif to Byte Array….
Its Urgent……………………………………….
Thanks in advance…………….
November 8, 2010 at 3:21 pm |
Hey,
what is not working?