?
Solved

printing the object in the opengl window

Posted on 2008-10-23
1
Medium Priority
?
391 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
torrie01 earned 2000 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

Technology Partners: 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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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