Jump to content

How to programmatically take screenshots?


lxr

Recommended Posts

Hi all,

 

I'm looking for a way to programmatically take a number of screenshots within GTA IV, with the player or camera positioned at specific x,y,z coordinates, with specific rotation, and so on.

 

I have installed SparkIV and the .Net ScriptHook, I can parse the game's .nod files to find coordinates, and I'm pretty sure I'll manage to control settings like time, weather, peds, and vehicles. But browsing the .Net ScriptHook documentation, I haven't found a way to render screenshots from a given point. How can this be done?

 

Thanks much for your help!

 

lxr

Link to comment
Share on other sites

Do you want to make a radar like these detailed from SA?

Link to comment
Share on other sites

 

d3d9 for screens should do it

Hey, thanks for your reply. Can you be a tiny bit more specific though? How exactly do I use d3d9 to get access to the DirectX device from within a C# script?

Link to comment
Share on other sites

Use the "System.Drawing" namespaces like "Image/Bitmap", search google for "C# Screenshot CaptureWindow" or something like it.

Link to comment
Share on other sites

 

Use the "System.Drawing" namespaces like "Image/Bitmap", search google for "C# Screenshot CaptureWindow" or something like it.

Hey, thanks for your help. The approach you're suggesting is actually what I tried first, but it only works for regular windows, not for DirectX. The following will just dump a black PNG:

 

 

Size size = Screen.PrimaryScreen.Bounds.Size;Bitmap bImage = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb);System.Drawing.Graphics gImage = System.Drawing.Graphics.FromImage(bImage);gImage.CopyFromScreen(Point.Empty, Point.Empty, size);bImage.Save(filename, ImageFormat.Png);bImage.Dispose();

 

 

I guess I might have to do something like this instead (but I haven't figured out how to get access to the device):

 

 

// Device device = ???Surface renderTarget = device.GetRenderTarget(0);SurfaceLoader.Save(filename, ImageFileFormat.Png, renderTarget);

 

Edited by lxr
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.