Solved

printing the object in the opengl window

Posted on 2008-10-23
1
377 Views
Last Modified: 2012-05-05
I am develping an csgl application in csharp........is there any idea to print the object that is displayed in the opengl window........There is an option called print document in the csharp toolbox..........that is not working......

any ideas?
0
Comment
Question by:jsbsudha
1 Comment
 
LVL 3

Accepted Solution

by:
torrie01 earned 500 total points
ID: 22789914
I haven't used OpenGL before, but here is how I print a screenshot of a window:


        private void Print()
        {
            PrintDocument printDoc = new PrintDocument();
            printDoc.PrintPage += new PrintPageEventHandler(printer_PrintPage);
 
            PrintDialog printForm = new PrintDialog();
            printForm.Document = printDoc;
            printForm.UseEXDialog = true;
            DialogResult result = printForm.ShowDialog();
            if (result == DialogResult.OK)
            {
                printDoc.PrinterSettings = printForm.PrinterSettings;
                
                printDoc.Print();
            }
            
            //removing event handler so object will properly dispose
            printDoc.PrintPage -= new PrintPageEventHandler(printer_PrintPage);
            printDoc.Dispose();
            printForm.Dispose();
        }
 
	void printer_PrintPage(object sender, PrintPageEventArgs e)
        {
	    UserControl screen = this; //replace this with wherever your OpenGL window is
 
            using (Bitmap bmp = new Bitmap(screen.Width, screen.Height))
            {
                screen.DrawToBitmap(bmp, new Rectangle(0, 0, screen.Width, screen.Height));
                e.Graphics.DrawImage(bmp, 0, 0);
            }
        }

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 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