Pasting an Image from windows clipboard and annotating it

31 views
Skip to first unread message

frangonve

unread,
Jun 26, 2020, 10:44:44 PM6/26/20
to Racket Users
Hello, A newbie here:

I want to insert an image from windows clipboard to a rectangular widget that will take the image size. Then when  repeatedly clicking the mouse on different coordinates of the image I want to superimpose each time the next letter in alphabetic order with transparent background:

This is the type of images to insert:

Clever Mines 20200318.png

This is what I want to show after clicking several times on the image high-left corner:

Clever Mines 20200318 id.png

Please can you help me?

Cheers

Francisco 

Alex Harsanyi

unread,
Jun 27, 2020, 9:12:57 PM6/27/20
to Racket Users
You can get the bitmap from the clipboard using "(send the-clipboard get-clipboard-bitmap)" and you can use the bitmap dimensions (see get-with and get-height methods of the bitmap% object) to make the canvas the same size as the bitmap by constructing it with stretchable-width and stretchable-height set to #f and setting the min-width and min-height to the bitmap dimensions.   To draw the bitmap onto the canvas, you can use the draw-bitmap method in the paint callback.

For the mouse clicks, you will need to override the `on-subwindow-event` on the canvas to look at the mouse events and record where the user clicked.  You can draw the letters at the click positions in the paint-callback of the canvas using the draw-text method.

Hope this helps,
Alex.
Reply all
Reply to author
Forward
0 new messages