hi rajveer,
in the code you mentioned the background image for the canvas is
fixed.
can background image be loaded dynamically??
how to do that??

On Dec 23, 2:05 pm, Rajveer Goud <[email protected]> wrote:
> Hi..pradeep..!!!
>
> it may help you..!!!
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute">
>
>            <mx:Script>
>         <![CDATA[
>         import mx.utils.Base64Encoder;
>         import mx.rpc.events.ResultEvent;
>         import mx.rpc.events.FaultEvent;
>         import mx.utils.ObjectUtil;
>         import mx.controls.Alert;
>         import mx.graphics.codec.PNGEncoder;
>
>         private var isDrawing:Boolean=false;
>         private var x1:int;
>         private var y1:int;
>         private var x2:int;
>         private var y2:int;
>         private var drawColor:uint;
>         private var PNGEnc:PNGEncoder;
>
>         private function doErase():void
>         {
>             canvas.graphics.clear();
>         }
>
>         private function doMouseDown():void
>         {
>             x1 = canvas.mouseX;
>             y1 = canvas.mouseY;
>             isDrawing = true;
>         }
>
>         private function doMouseMove():void
>         {
>             x2 = canvas.mouseX;
>             y2 = canvas.mouseY;
>             if (isDrawing)
>             {
>                 canvas.graphics.lineStyle(5, drawColor);
>                 canvas.graphics.moveTo(x1, y1);
>                 canvas.graphics.lineTo(x2, y2);
>                 x1 = x2;
>                 y1 = y2;
>             }
>         }
>
>         private function doMouseUp():void
>         {
>             isDrawing = false;
>         }
>
>                 public function onResult(event:ResultEvent) :void
>                 {
>                         Alert.show(ObjectUtil.toString(event.result));
>                 }
>                 public function onFault(event:FaultEvent) :void
>                 {
>                         Alert.show("Got error: "+event.message);
>                 }
>                 public function takeSnapshot():void
>                 {
>
>                         var bd:BitmapData = new 
> BitmapData(canvas.width,canvas.height);
>                         bd.draw(canvas);
>                         var ba:ByteArray = PNGEnc.encode(bd);
>                         var be:Base64Encoder = new Base64Encoder();
>                         be.encodeBytes(ba);
>                         var encodedData:String = be.flush();
>                         myService.cancel();
>                         var params:Object=new Object;
>                         params.param1=encodedData;
>                         Alert.show(encodedData);
>                         myService.send(params);
>                         //ro.saveImage(encodedData);
>                 }
>         ]]>
>
>     </mx:Script>
>
>         <mx:HTTPService id="myService" fault="onFault(event)" result="onResult
> (event)" url="doSave.php" method="POST">
>         </mx:HTTPService>
>
>         <mx:Panel title="FlexPaint">
>         <mx:Canvas id="canvas" width="500" height="500"
>             horizontalScrollPolicy="off" verticalScrollPolicy="off"
>             mouseDown="doMouseDown()"
>             mouseMove="doMouseMove()"
>             mouseUp="doMouseUp()" backgroundAlpha="0.8"
> backgroundImage="assets/abc.JPG" />
>
>         <mx:ControlBar>
>             <mx:ColorPicker change="drawColor =
> event.target.selectedColor"/>
>             <mx:Button label="Erase" click="doErase()"/>
>             <mx:Button label="Save Image" click="takeSnapshot()"/>
>         </mx:ControlBar>
>     </mx:Panel>
>         <mx:TextInput x="667" y="47" id="name1"/>
> </mx:Application>
> -------------------------------------------------------------------------------------------------------------
>
> On Dec 23, 11:26 am, ManInAction <[email protected]> wrote:
>
> > HiPradeep,
>
> > How to draw jpg or png??you can draw only vector image in flash and
> > flex.After you can save tht image as jpg or png.
> > For pain you can use Flash API drawing.
>
> > On Dec 22, 4:08 pm, "[email protected]"
>
> > <[email protected]> wrote:
> > > Hi everyone,
> > > I have an application where i need to draw an image(.png
> > > or .jpg, .gif) on canvas,
> > > after then i must be able to paint (annotate) on that canvas with the
> > > mouse.
> > > Any Ideas.
>
> > > thanks
> > >Pradeep

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to