Get bitmap from clipboard problem

  • Thread starter Thread starter Christopher Bailey
  • Start date Start date
C

Christopher Bailey

I have a program where I'm copying a bitmap from the clipboard and
displaying it. It seems that after I perform this operation a few
times (3-4) even after confirming there is bitmap data on the
clipboard {if (iData.GetDataPresent(DataFormats.Bitmap))} when I get
the data it returns null.

I have made a simple test case in MSVC.NET

File->New->Project->Windows Application. Under the
InitializeComponent() I added this simple test case.

for (int i = 0; i < 10; i++)
{
// Get the image from the clipboard
IDataObject iData = Clipboard.GetDataObject();

// Make sure we have a bitmap available
if (iData.GetDataPresent(DataFormats.Bitmap))
{
Image kImage = (Image)iData.GetData(DataFormats.Bitmap);
int t = 0; // So we can see kImage in debugger
}
}

The first 3 times kImage will be a System.Drawing.Bitmap object.
Afterwards it will be null.

I can only imagine that there is some sort of resource limit I'm
coming up against (This is my first C# project). I'm using a "print
screen" capture (3120 x 2400) which is quite large.

Remember to put something on the clipboard to test. Printscreen works
great.

Thank you in advance for any help you can provide!

Christopher
 
Hi Christopher,

Did you ever find a solution or work-around for this problem?
I've just hit exactly the same problem using vb.net. It seems to be the
'CType(iData.GetData(DataFormats.Bitmap), Bitmap)' command which is using up
memory and not releasing it fully.

Dave.
 
Back
Top