flash builder - How to convert Image to ByteArray in Flex 4 -


i write image in pdf. use alivepdf , method pdf.addimagestream(image,...). image bytearay , not know how convert image object in bytearray. appreciate if can give me suggestion.

1.load image:

var loader:loader = new loader(); loader.contentloaderinfo.addeventlistener(event.complete, begindraw); loader.load(new urlrequest(imgurl)); 

2.get bitmapdata , convert bytearray:

private function begindraw(event:event):void{     var bitmap:bitmap = loader.content bitmap;     var rect:rectangle = new rectangle(0,0,bitmap.width. bitmap.height);     var result:bytearray = bitmap.bitmapdata.getpixels(rect); } 

Comments