Solved. This was the solution.
private function copypixels(target:BitmapData, src:BitmapData, destP:Point,
targetR:Rectangle ):Boolean{
var toR:Rectangle = new Rectangle(destP.x, destP.y, src.width,
src.height);
var inR:Rectangle = targetR.intersection(toR);
if(inR.width==0 || inR.height==0){return false;} // skip
var srcR:Rectangle = new Rectangle(inR.x-toR.x, inR.y-toR.y,
inR.width, inR.height);
target.copyPixels(src, srcR, new Point(inR.x, inR.y), null, null,
true);
return true;
}
/Elia
On Thu, Apr 22, 2010 at 8:32 PM, Elia Morlin <[email protected]> wrote:
> Yes I know, but I need a function that calculates the optimal source
> rectangle to fit in a target rectangle.
>
>
> On Thu, Apr 22, 2010 at 7:51 PM, Zeh Fernando <[email protected]> wrote:
>
>> sourceRect is one of the parameters of the copyPixels method. It describes
>> which is the rectangle to be used when copying. No masking is necessary.
>> This has the same effect as limiting the target area to a specific
>> rectangle.
>>
>>
>> http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001400.html
>>
>> Zeh
>>
>> On Thu, Apr 22, 2010 at 8:37 AM, Elia Morlin <[email protected]>
>> wrote:
>>
>> > Say I have a BitmapData that is 500x500 pixels.
>> > I want to restrict the area that will be updated in a series of
>> copypixel
>> > operations.
>> > For example I want to restrict the rectangle that will be updated in the
>> > target Bitmapdata to Rectangle(100,100,50, 50).
>> > How do I do that without using a mask?
>> >
>> > Thanks
>> > Elia
>> > _______________________________________________
>> > Flashcoders mailing list
>> > [email protected]
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders