问题
I want to implement copy, cut and paste in my drawing program (copy part of an image that is selected)
I don't know how to start
Any Ideas?
回答1:
to copy: take the selected rectangle, create a new image of that size, take a copy of the current image and place it on the new rectangle, offset by the topleft of the selected rectangle
回答2:
in short there are two ways exists
1) your own clipboard 2) system-wide clipboard
in second case use must use standard format for storing your data. read MSDN for more information about windows clipboard
or you can maintain two clipboards - own and system. then in your clipboard you can store specific information for your application and in system cliboard just image
回答3:
Here are some global points that will drasticly speed up your issues that you'll be facing.
Try to search for reversible line / rubberband. to make selections in the picture. Try to search for LockBits in VB .NET , to create a fast way of reading and writing pixels. Try to learn background thread , and report progress. For per pixel operations that take a long time. Try to make a MDI. With enough status bars to report the status. Try to serialize to xml/binary when saving a project-file to disk (like a psd for example). This could also be handy , for creating a undo function.
回答4:
see this one...
http://www.wallpaperama.com/forums/javascript-copy-selected-text-box-select-all-highlight-text-form-copy-paste-t706.html
but for firefox its not working. am also searching for similar one. will post if i get more.
回答5:
- Use the system-wide clipboard, just in case the user copy in one instance on your app and paste in another, or if the user close the window and re-open it, he can paste back the data.
- Inherit all the shapes of the program from a base class that implements the copy & paste.
- For copy (or cut), serialize the object and place it in the system clipboard.
- For paste, read the system clipboard and try to de-serialize back to a shape object (if the cast fails, the clipboard content was not an object of your app)
- Move the position of the pasted shape slightly to the left and bottom (to let the user know that there is a new shape in the drawing)
来源:https://stackoverflow.com/questions/891702/implementing-copy-cut-and-paste