BitmapData.copyPixels(). For future reference, it allows you to copy a portion of a bitmap specified by a rectangle - exactly what I need. Thanks for the help, Bjorn.
--- In flexcoders@yahoogroups.com, "Shaun" <[EMAIL PROTECTED]> wrote: > > Thanks Bjorn, I think I'm headed in the right direction now, but I > still have one hurdle. > > I'm successfully copying the source image to the preview control, but > I can't figure out how to only copy a portion of the source image > instead of the whole thing. How do I get just a certain rectangle of > the source image to pass into the BitmapData.draw() function? > > Any ideas? > > Thanks again, > shaun > > > --- In flexcoders@yahoogroups.com, Bjorn Schultheiss > <bjorn.schultheiss@> wrote: > > > > On the click handler for my image i've got something like > > > > var dragInitiator:Canvas = event.currentTarget as > Canvas; > > var dragInit:AssetPreviewPanelView = > dragInitiator.parent as > > AssetPreviewPanelView; > > > > var dragSource:DragSource = new DragSource(); > > dragSource.addData( > dragInit.dataProvider, "dataProvider" ); > > > > var proxyBitmapData:BitmapData = > > BitmapDataHelper.getUIComponentBitmapData( dragInit ); > > var dragProxy:Image = new Image(); > > var lc:LoaderContext = new LoaderContext(); > > lc.checkPolicyFile = true; > > dragProxy.loaderContext = lc; > > dragProxy.source = new Bitmap( > proxyBitmapData ); > > > > DragManager.doDrag(dragInit, dragSource, > event, dragProxy, 0, 0, > > 0.5, true); > > > > > > > > public static function getUIComponentBitmapData > > ( target:DisplayObject ):BitmapData > > { > > var bd : BitmapData = new BitmapData( target.width, > > target.height ); > > var m : Matrix = new Matrix(); > > bd.draw( target, m ); > > return bd; > > } > > > > > > Does this help? > > > > Bjorn > > > > On 20/04/2007, at 8:16 AM, Shaun wrote: > > > > > I am working on a project where I need to create an image based > on a > > > user selected portion of a source image. > > > > > > The selected area of the source image needs to be > > > scaled/stretched/shrunk to fit the specific dimensions of the > new > > > image. > > > > > > I'm basically looking for advice on how to accomplish this. > > > > > > Currently I have an image control in a canvas. The user clicks and > > > drags to select the portion of the image they want to use. This > works > > > fine - I have the coordinates and size of the rectangle I need to > copy > > > from the source canvas. > > > > > > What I can't figure out is the best way to use those coordinates > to > > > get > > > the underlying image from the canvas and put it into another > control. > > > I've tried creating a sprite containing a bitmap and using the > > > BitmapData.draw function passing in the source canvas and what I > > > believe is a correct matrix, but have not succeeded. > > > > > > Any pointers, examples to look at, etc. would be greatly > appreciated. > > > > > > Thanks, > > > Shaun > > > > > > > > > > > > > Regards, > > > > Bjorn Schultheiss > > Senior Developer > > > > Personalised Communication Power > > > > Level 2, 31 Coventry St. > > South Melbourne 3205, > > VIC Australia > > > > T: +61 3 9674 7400 > > F: +61 3 9645 9160 > > W: http://www.qdc.net.au > > > > ((------------This transmission is confidential and intended > solely > > for the person or organization to whom it is addressed. It may > > contain privileged and confidential information. If you are not > the > > intended recipient, you should not copy, distribute or take any > > action in reliance on it. If you believe you received this > > transmission in error, please notify the sender.---------------)) > > >