Copy drawn image to clipboard

Posted on 2009-04-20
Medium Priority
Last Modified: 2012-05-06
I am drawing an image onto a picturebox which I then need to copy to the clipboard.

I have done this before with groups of controls using:

Dim bmp As New Bitmap(icontrolwidth, icontrolheight)
Me.pic1.DrawToBitmap(bmp, New Rectangle(icontrolleft, icontroltop, icontrolwidth, icontrolheight))

but since I am drawing this myself (using Graphics.FillPolygon) it does not put any data in the clipboard.

How can I acheive this (which will be pasted into MS Office document after this).
Question by:CarlPritchard
  • 2
LVL 39

Accepted Solution

abel earned 1500 total points
ID: 24186188
If I make an image myself, the following works for me:

Bitmap bmpTest = new Bitmap(picSourceSmall.Image);
Graphics graphTest = Graphics.FromImage(bmpTest);
graphTest.DrawString("HELLO WORLD", 
    new SolidBrush(Color.Black), 
    new PointF(10.0F, 10.0F));
picSourceSmall.Image = bmpTest;

Open in new window

LVL 39

Expert Comment

ID: 24186197
oops, that was C# in a VB thread. Can you read it or do you need me to transform it to VB?

Author Comment

ID: 24187223
No - was able to interpret that and make it work (thanks).

The image box does not start with an image so I create a new  bitmap to feed to the graphics object. The problem with this is that the background is grey (the image control has white as a background but guess this is not relevant). I have worked around this by first drawing a white filled rectangle but is there a better way

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question