473,796 Members | 2,495 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Save GDI+ as image

MAY
Hi,

I drew some lines on a form and i want convert these lines into a bitmap.
How can i do that?
MAY


Nov 16 '05 #1
4 8059
it's actually best to draw on a Image/Bitmap and put that image on the form.

pictureBox1.Ima ge = new Bitmap(pictureB ox1.Width, pictureBox1.Hei ght);
Image bmp = pictureBox1.Ima ge;
Graphics g = Graphics.FromIm age(bmp);

//Edit bmp
g.FillRectangle (new SolidBrush(Colo r.White), 0, 0, pictureBox1.Wid th,
pictureBox1.Hei ght);
for(int I=0; I < pictureBox1.Wid th; I+)
g.DrawLine(new Pen(Color.Black ), pictureBox1.Wid th - I, 0, 0, I);

//Display bmp
pictureBox1.Ima ge = bmp;
then to save the image all you'd have to do is make the image public or
something and

bmp.SaveTo("C:\ stuff.png");

Hope that helps
On 06/05/2004 "MAY" <pa****@hotmail .com> wrote:
Hi,

I drew some lines on a form and i want convert these lines into a bitmap.
How can i do that?
MAY

Nov 16 '05 #2
MAY
Thx for help..

as this form will dynamic create drawing stuffs in run time thus cant change
picturebox.img. is there have other alternatives?
MAY
"Scatropoli s" <ch*****@frayed .net> ???
news:Ol******** ******@TK2MSFTN GP11.phx.gbl ???...
it's actually best to draw on a Image/Bitmap and put that image on the form.

pictureBox1.Ima ge =ew Bitmap(pictureB ox1.Width, pictureBox1.Hei ght);
Image bmp =ictureBox1.Ima ge;
Graphics g =raphics.FromIm age(bmp);

//Edit bmp
g.FillRectangle (new SolidBrush(Colo r.White), 0, 0, pictureBox1.Wid th,
pictureBox1.Hei ght);
for(int I= I < pictureBox1.Wid th; I+)
g.DrawLine(new Pen(Color.Black ), pictureBox1.Wid th - I, 0, 0, I);

//Display bmp
pictureBox1.Ima ge =mp;
then to save the image all you'd have to do is make the image public or
something and

bmp.SaveTo("C:\ stuff.png");

Hope that helps
On 06/05/2004 "MAY" <pa****@hotmail .com> wrote:
Hi,

I drew some lines on a form and i want convert these lines into a bitmap.
How can i do that?
MAY

Nov 16 '05 #3
MAY wrote:
Thx for help..

as this form will dynamic create drawing stuffs in run time thus cant change
picturebox.img. is there have other alternatives?

// Create an image 100 x 100 pixels
Image image = new Bitmap(100, 100);

// Get the Graphics object
using (Graphics g = Graphics.FromIm age(image))
{
// Do your drawing here....
}
image.Save(file name, System.Drawing. Imaging.ImageFo rmat.Gif);

MAY
"Scatropoli s" <ch*****@frayed .net> ???
news:Ol******** ******@TK2MSFTN GP11.phx.gbl ???...
it's actually best to draw on a Image/Bitmap and put that image on the form.

pictureBox1.Ima ge =ew Bitmap(pictureB ox1.Width, pictureBox1.Hei ght);
Image bmp =ictureBox1.Ima ge;
Graphics g =raphics.FromIm age(bmp);

//Edit bmp
g.FillRectangle (new SolidBrush(Colo r.White), 0, 0, pictureBox1.Wid th,
pictureBox1.Hei ght);
for(int I= I < pictureBox1.Wid th; I+)
g.DrawLine(new Pen(Color.Black ), pictureBox1.Wid th - I, 0, 0, I);

//Display bmp
pictureBox1.Ima ge =mp;
then to save the image all you'd have to do is make the image public or
something and

bmp.SaveTo("C:\ stuff.png");

Hope that helps
On 06/05/2004 "MAY" <pa****@hotmail .com> wrote:
Hi,

I drew some lines on a form and i want convert these lines into a bitmap.
How can i do that?
MAY


--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk
Nov 16 '05 #4
MAY
Thx guys..... i got it!

"Ed Courtenay" <re************ *************** **@edcourtenay. co.uk> ???
news:uk******** ******@TK2MSFTN GP12.phx.gbl ???...
MAY wrote:
Thx for help..

as this form will dynamic create drawing stuffs in run time thus cant change picturebox.img. is there have other alternatives?


// Create an image 100 x 100 pixels
Image image = new Bitmap(100, 100);

// Get the Graphics object
using (Graphics g = Graphics.FromIm age(image))
{
// Do your drawing here....
}
image.Save(file name, System.Drawing. Imaging.ImageFo rmat.Gif);

MAY
"Scatropoli s" <ch*****@frayed .net> ???
news:Ol******** ******@TK2MSFTN GP11.phx.gbl ???...
it's actually best to draw on a Image/Bitmap and put that image on the form.
pictureBox1.Ima ge =ew Bitmap(pictureB ox1.Width, pictureBox1.Hei ght);
Image bmp =ictureBox1.Ima ge;
Graphics g =raphics.FromIm age(bmp);

//Edit bmp
g.FillRectangle (new SolidBrush(Colo r.White), 0, 0, pictureBox1.Wid th,
pictureBox1.Hei ght);
for(int I= I < pictureBox1.Wid th; I+)
g.DrawLine(new Pen(Color.Black ), pictureBox1.Wid th - I, 0, 0, I);

//Display bmp
pictureBox1.Ima ge =mp;
then to save the image all you'd have to do is make the image public or
something and

bmp.SaveTo("C:\ stuff.png");

Hope that helps
On 06/05/2004 "MAY" <pa****@hotmail .com> wrote:
Hi,

I drew some lines on a form and i want convert these lines into a bitmap.How can i do that?
MAY


--

Ed Courtenay
[MCP, MCSD]
http://www.edcourtenay.co.uk

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3519
by: Bassem | last post by:
Hi all I saved my imaged in SQL 2000 server database and now I want to get the values of the columns to text or xml file. The field I didn't could get it to the text file is the Image column (binary array value). Is there any solution to be able to save the binary array to a text or xml file?
3
11660
by: Alexli | last post by:
I got the error ================= An unhandled exception of typ 'System.Runtime.InteropServices.ExternalException' occurred i system.drawing.dl Additional information: A generic error occurred in GDI+ ================= the code like this
2
3863
by: Barry | last post by:
Hi Does anyone know why i am getting the following error message (line 64) , if i change to objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg) i do not get this error Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
3
2341
by: Rob Willaar | last post by:
Hi All, I try to draw text on a picturebox. The text appears but it is drawn on top of the picture. when i try to save the result the text is gone.
1
1706
by: DSchlichte | last post by:
Hello ' I need some help. I've created a little application to paint, save and load pictures (Bitmap-graphics) into ' a picturebox-object on the desktop. There's no problem to paint or to load pictures, but how can I save the image? ' My load-routine is the following (if I click on the file-menu and chose File open...):
1
6496
by: WB | last post by:
Hi, I have a helper class that has a method to resize images. It takes the virtual path of an image and resize it to a specified dimension like this. public void ResizeImageTest(string pathImage, int newDimension) { string pathImageOnDisk = System.Web.HttpContext.Current.Server.MapPath(pathImage); System.IO.FileStream fs = new System.IO.FileStream(pathImageOnDisk,
2
2652
by: Ada | last post by:
First of all, I thought this might be a directory security issue but it's not. I was able to upload the file to the directory via HTTP. Here's the situation. I have a JPG file on my server. ..../images/myPIC.jpg I wanted to draw a box or line using GDI+ on top of myPIC.jpg and then save the new image to the server.
15
8345
by: Sharon | last post by:
Hello gurus, I have a System.IntPtr pointing to the memory address of my image (not a ..NET image). I wish to save this image data pointed by the IntPtr to a raw data file. The way I now to that is: System.IO.FileStream file = new System.IO.FileStream(fileName, System.IO.FileMode.Create); file.Write(byte, 0, ...);
12
4047
by: Lee | last post by:
I have the following code using System; using System.Windows.Forms; using System.Drawing; using System.Collections; namespace FINN {
0
9683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10457
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10013
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9054
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5443
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4119
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2927
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.