Sign in to follow this  
acam

getting the print screen image of a graphic view

Recommended Posts

Hello,

 

I have another question regarding Nethook options.

 

I would like to make a printscreen image of a graphic view.

I can succesfully save the image of the entire screen. I use this method for this:

 

        	Rectangle bounds = Screen.GetBounds(Point.Empty);

       	// create the bitmap to copy the screen shot to
       	Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height);

       	// now copy the screen image to the graphics device from the bitmap
       	using (Graphics gr = Graphics.FromImage(bitmap))
       	{
           	gr.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
       	}

       	return bitmap;

 

But the problem is that this method returns image of the entire screen.

 

I would like to get the image of only a graphic window.

 

I see 2 possible solutions to this:

  • get the bounds of the graphic screen and use them in the previously shown method
  • use direct function from mastercam (if it exists) to get the image directly (like the Screen/To clipboard function inside of Mastercam)

I was checking the Nethhok help but I see no option to achieve any of these using nethook functions.

 

Any of the solutions would be greatly appreciated.

 

Thanks

Share this post


Link to post
Share on other sites

Gorazd,

 

Have you tried ...

 

Mastercam.Mastercam.IO.FileManager.SaveToBitmap(String FilePath)

 

"This is used to save the graphics view of the currently opened file to a bitmap file."

 

Parameters: FilePath (String)

This should be the full, backslash-delimited path of the bitmap file you wish to create.

 

Return Value:

True if the bitmap file was created successfully and false if not.

Share this post


Link to post
Share on other sites

yeah, but this one only creates bitmap 256x256 pixels.

 

I would like to have a big image.

 

Regards.

Share this post


Link to post
Share on other sites

Yes, that's it.

 

If the current graphic screen is 1052x897 (it depends on the size of the screen and the number of toolbars the user has ) I want to capture it into the image of the same size.

 

I always wandered why the SaveToBitmap(String FilePath) didn't save to a large image.

Ususaly we need printscreens bigger than 256x256.

 

I want to have the same functionality as "Screen/Copy screen image to clipboard" does (it creates imege of the graphic screen in the original size).

 

Best regards.

Share this post


Link to post
Share on other sites

Hello and a lucky new year to you all,

i have a further question about creating screenshot or better creating a print like File/Print.

Let's assume, that the setup for printer, orientation, color etc. is done.
Is it then possible to control that print function with a chook-function (in MC2019 and above) ?

Maybe the undocumented function "send_file_to_printer(class CStdioFile *, int, wchar_t *)" is the key for that?

Please help.

Best regards

Share this post


Link to post
Share on other sites

Thank you Roger,

 

that works fine.

But now i have found that i cant't store that print in a file without manually enter the path (with an pdf printer driver).  That's what i want to avoid.

Now i think like acam did. Make a printscreen image and than store it as a bmp in the directory where the mc-file lives.

I'm able to store that bmp with "screen_to_bitmap_file(...)"

 That works also. But what if i want to manipulate that image before storing it. Saw the function "screen _to_Bitmap(...)" and got the same problems as acam.

How to get the bitmap-size in "graphic screen in the original size"?

 

Best regards

Norbert

 

 

Share this post


Link to post
Share on other sites

Norbert,

Try this function -

DLLImport bool screen_to_bitmap_file (TCHAR *pFileName, bool thumbnail = true);

It is the native (C++) method that the NET-Hook API is using via -

bool FileManager.SaveToBitmap (string FilePath, bool Thumbnail)

  • Like 1

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us