LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
on copyPartImage
lock screen
hide grc "cadreCopy"
set the tool to "select tool"
click at the topleft of grc "cadreCopy"
drag from the topleft of grc "cadreCopy" to the bottomright of grc "cadreCopy"
wait 2 milliseconds
copy
wait 2 milliseconds
click at 2,2
answer (the clipboarddata["image"] = empty) -- return true
paste
end copyPartImage
Export a snapshot which keeps transparent areas should be an other way but I don't know how.
Best regards
Jean-Marc
Last edited by jmburnod on Sun Jan 07, 2018 12:32 pm, edited 1 time in total.
Hi Craig,
Your script works fine with pointer tool and controls but i want to do the same with
the select tool and a paint image to copy a part of the image
Jean-Marc
If I change "pointer tool" to "Select tool", place an image, and drag over only part of that image, the whole image is duplicated.
8.1.8
Craig
EDIT.
If i do that several times, only one copy is produced, even though all the previous images underly each other perfectly. Apparently only the topmost image "sees" the select tool.
I think you'd have better luck using the import snapshot command with the parameter "with effects". You can either set a rect or let the user drag out a region. The new image will appear at the center of the card.
If you want the image in the clipboard you can copy the new image and optionally delete it.
on mouseUp
clone img 1 -- the original image
put the ID of it into tImgID
put the rect of img ID tImgID into tRect
subtract 200 from item 4 of tRect -- adjust this to what you want
crop img ID tImgID to tRect
end mouseUp
When you know it works, you can lock the screen.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
on mouseUp
clone img 1 -- the original image
put the ID of it into tImgID
put the rect of grc "cadrecopy" into tRect
repeat with i = 1 to 4
add 30 to item i of tRect
end repeat
crop img ID tImgID to tRect
put specialfolderpath("documents") & "/" & "TestImg.png" into tPath
export img id tImgID to file tPath as PNG
end mouseUp
My handler adjusts the rect of the clone directly. Your handler uses the rect of another object, which is why you need to add the offset. If you align the clone to the graphic before cropping, it should work without any math adjustments.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com