C# Clipboard and pasting images from games

Hi

I'm trying to get images taken in games with the 'Print Screen' key to

be pasted into my picturebox control in the application I am

developing. (C# .NET2)

At the moment I am testing this out in a game called Rome: Total War,

and am able to paste the screenshot from the clipboard into Microsoft

Paint but am unable to paste it into my application.

Below are 2 code samples for the methods I have tried.

if(Clipboard.GetDataObject().GetDataPresent(DataFormats.Bitmap))
pictureBox1.Image = (Bitmap)Clipboard.GetDataObject().GetData(DataFormats.Bitmap);
and

if (Clipboard.ContainsImage())
pictureBox1.Image = Clipboard.GetImage());
Both of these samples return true in the if statement (I.e. there is am

image in the clipboard) but then I came to extract the image on the

next line all I get is a null value.

I also tested these code samples with a screenshot taken of a standard windows desktop and that worked fine.

What do I have to do to get it to work with 3D games. I'm guessing it

can be done since Paint can do it and the if statements say I have

valid data.

Thanks

[1127 byte] By [bobbobber23] at [2007-12-24]
# 1

I'm surprised nobody on the official MS forum has not run

into this problem before!

bobbobber23 at 2007-8-31 > top of Msdn Tech,Visual C#,Visual C# General...