Copy arbitrary rect from one image to another
Posted: Sun Jan 30, 2011 8:38 pm
I have spent more time that I'll admit trying to accomplish what appears to be a simple task.
Via script I need to copy a rectangle of one image object and paste it into the same-sized rectangle of another image object.
Ideally this needs to be done with neither of the images visible.
I'm developing custom transitions so I am floating one image obj over another (larger) image obj, doing the transition and then needing to
copy the resulting obj, selecting a rect in the underlying obj and pasting in the results.
In a perfect world, one would think that this might be accomplished with one statement like:
copy image "hover" to rect "100,100,200,300" of image "canvas" -- (bad syntax)
MORE PERFECT API
copy rect "50,50,150,250" of image "hover" to rect "100,100,200,300" of image "canvas" -- (bad syntax)
OR MAYBE
copy image "hover"
select image "canvas"
choose select tool
drag from "100,100" to "200,300"
paste
-- this "paste" creates a duplicate of image "hover", not at all what was intended
-- since choosing the select tool negates the image selection
OR MAYBE
export image "hover" to rect "100,100,200,300" of image "canvas"
Problematic is the fact that when an image is selected (select image "canvas") that the size/location handles appear (not cool)
and unless and image is visible it doesn't seem to always participate in operations like paste. Similarly, using "import snapshot"
(which allows rect to define the region) creates a new floating image which is visible - cosmetically unacceptable.
I've scoured the user guide/dictionary for a rigorous description of "the right way" of doing this.
export looked like a possibility, but you cannot export to rect of an object...
Rather than exploiting some undocumented quirk I'd prefer knowing what's "sanctioned" since anything less might
change in subsequent releases of the product. It's been triply frustrating that some of the alternative techniques
I've tried might work in Runrev 4.5.0-dp-3 but fail when built as standalone for Mac and hang when built for web.
So,
Is there a platform-independent approved syntax for copying the contents of a rectangle of one image object and
replacing an identical-dimensioned rectangle (at different location) within a second image object - invisibly,
"behind-the-scenes" with possibly neither of these image objects visible at the time?
Via script I need to copy a rectangle of one image object and paste it into the same-sized rectangle of another image object.
Ideally this needs to be done with neither of the images visible.
I'm developing custom transitions so I am floating one image obj over another (larger) image obj, doing the transition and then needing to
copy the resulting obj, selecting a rect in the underlying obj and pasting in the results.
In a perfect world, one would think that this might be accomplished with one statement like:
copy image "hover" to rect "100,100,200,300" of image "canvas" -- (bad syntax)
MORE PERFECT API
copy rect "50,50,150,250" of image "hover" to rect "100,100,200,300" of image "canvas" -- (bad syntax)
OR MAYBE
copy image "hover"
select image "canvas"
choose select tool
drag from "100,100" to "200,300"
paste
-- this "paste" creates a duplicate of image "hover", not at all what was intended
-- since choosing the select tool negates the image selection
OR MAYBE
export image "hover" to rect "100,100,200,300" of image "canvas"
Problematic is the fact that when an image is selected (select image "canvas") that the size/location handles appear (not cool)
and unless and image is visible it doesn't seem to always participate in operations like paste. Similarly, using "import snapshot"
(which allows rect to define the region) creates a new floating image which is visible - cosmetically unacceptable.
I've scoured the user guide/dictionary for a rigorous description of "the right way" of doing this.
export looked like a possibility, but you cannot export to rect of an object...
Rather than exploiting some undocumented quirk I'd prefer knowing what's "sanctioned" since anything less might
change in subsequent releases of the product. It's been triply frustrating that some of the alternative techniques
I've tried might work in Runrev 4.5.0-dp-3 but fail when built as standalone for Mac and hang when built for web.
So,
Is there a platform-independent approved syntax for copying the contents of a rectangle of one image object and
replacing an identical-dimensioned rectangle (at different location) within a second image object - invisibly,
"behind-the-scenes" with possibly neither of these image objects visible at the time?