?
Solved

Convert a Graphics object into Bitmap

Posted on 2005-04-06
4
Medium Priority
?
2,123 Views
Last Modified: 2008-02-01
Hi,

    I need to create a image using the Graphics Object. That means, in my system i'm drawing few lines and i want load it into a picture box. What i thaught was to convert the Graphics object into a bitmap and include the bitmap in the picture box. but i'm not sure how to do this. Can please tell me how to do this?

Thanks
0
Comment
Question by:lilanw
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
RomanPetrenko earned 375 total points
ID: 13721578
Try something like this:
====
int width = 100,height=100;
Bitmap YourBMP = new Bitmap(width,height);
Graphics g = Graphics.FromImage(YourBMP);
///Draw anything you want on g
pictureBox1.Image = YourBMP;
====
0
 
LVL 10

Expert Comment

by:ptmcomp
ID: 13767179
The Graphics object is a drawing adapter to a device or image. The Graphics object does not contain an image. It's only a adapter to the screen buffer or a bitmap.
For your case it would be the easiest to paint on the bitmap like RomanPetrenko showed you above and then Draw the bitmap on your form or display it in a picture box. (Then the picture box does the drawing for you.)
0
 
LVL 8

Expert Comment

by:RomanPetrenko
ID: 13942821
I think the answer I gave is complete. Can it be graded?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

840 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