Implementing copy, cut and paste

依然范特西╮ 提交于 2020-03-23 06:58:08

问题


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:


  1. 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.
  2. Inherit all the shapes of the program from a base class that implements the copy & paste.
  3. For copy (or cut), serialize the object and place it in the system clipboard.
  4. 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)
  5. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!