bitmapdata - Some questions regarding Image manipulation in Flex -


here's want do. image loaded default when app run. there way load image user wants specifying url. when user defined image loaded, default image still in background , there method used apply filters on image whole (i mean resultant image both default , user loaded image blended) , want save final image jpg or png.

now, still beginner @ flex, , getting confused canvas, image control, bitmapdata etc. want what's best way implement want? should load default image image url/embed or should load bitmapdata, how load second user defined image? whats best way blend 2 images?

you can leave default image embedded one, , retrieve bitmapdata work further.

when user-defined image loaded, retrieve bitmapdata, , draw embedded image on user-defined one:

/**  * embedded image's class (your default image)  */ [embed(source="/assets/logo.png")] public static var logo:class;  /**  * @param bitmapdata: user-defined bitmapdata want modify  * @param matrix: transofrmation matrix applied resulting bitmapdata   */ public function getcustombitmapdata(bitmapdata:bitmapdata, matrix:matrix):bitmapdata {     // initialize , drawing resulting bitmapdata's first layer      var result:bitmapdata = new bitmapdata(bitmapdata.height, bitmapdata.width);     result.draw(bitmapdata, matrix);      // load bitmapdata of embedded logo image     var bitmapasset:bitmapasset = new logo();     var logobd:bitmapdata = bitmapasset.bitmapdata;      // draw logo on result alpha of 0.3     result.draw(logobd, matrix, new colortransform(1, 1, 1, .3));     //todo: should play size of images, apply filters, etc.      return result; } 

then can save resulting bitmapdata instace local file system:

/**  * save bitmapdata local file  * @param bitmapdata: data save  */ public function savebitmapdata(bitmapdata:bitmapdata):void {     // initialize encoder     var pngencoder:pngencoder = new pngencoder();     // encode bitmapdata , save byte array     var imagebytes:bytearray = pngencoder.encode(bitmapdata);     // create new filereference:     var imagefile:filereference = new filereference();     // save file:     imagefile.save(imagebytes, "myimage.png"); } 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -