473,714 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Save lines drawn in the picturebox as an lmage

Have used DrawLine() method to draw some lines in the picturebox (sort
of a barcode) in the picturebox paint event.
This diagram has to be saved as an image in bmp or tiff format.
But the problem is that these lines are not recognized as the image of
the picturebox.
It shows picturebox.imag e = nothing.

How do we convert these lines drawn as the image of the picturebox so
that it can be saved.

Thanks for any help.

Jan 20 '06 #1
4 10231
Hi, you need to draw to a bitmap's Graphics object:

Dim b As Bitmap = New Bitmap(100,100)
Dim g As Graphics = Graphics.FromIm age(b)

g.DrawLine(Pens .Black, 5,5,50,5)
g.Dispose()

picturebox1.ima ge = b
b.Save(...)

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Yash" <de*********@gm ail.com> schreef in bericht
news:11******** *************@f 14g2000cwb.goog legroups.com...
Have used DrawLine() method to draw some lines in the picturebox (sort
of a barcode) in the picturebox paint event.
This diagram has to be saved as an image in bmp or tiff format.
But the problem is that these lines are not recognized as the image of
the picturebox.
It shows picturebox.imag e = nothing.

How do we convert these lines drawn as the image of the picturebox so
that it can be saved.

Thanks for any help.

Jan 20 '06 #2

Thanks Peter
The saving part is working perfectly.
The preview also shows the image properly.

But there's another problem
The image contains Black and colored lines.
So if we open this image in Paint to change some colors,
the background shown is black -- which hides the black lines totally.

I tried Bitmap.MakeTran sparent but still the same.
The image is transparent but still the background is black.
Is this a .NET problem or Paint problem.
Any idea how to change this.
Peter Proost wrote:
Hi, you need to draw to a bitmap's Graphics object:

Dim b As Bitmap = New Bitmap(100,100)
Dim g As Graphics = Graphics.FromIm age(b)

g.DrawLine(Pens .Black, 5,5,50,5)
g.Dispose()

picturebox1.ima ge = b
b.Save(...)

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Yash" <de*********@gm ail.com> schreef in bericht
news:11******** *************@f 14g2000cwb.goog legroups.com...
Have used DrawLine() method to draw some lines in the picturebox (sort
of a barcode) in the picturebox paint event.
This diagram has to be saved as an image in bmp or tiff format.
But the problem is that these lines are not recognized as the image of
the picturebox.
It shows picturebox.imag e = nothing.

How do we convert these lines drawn as the image of the picturebox so
that it can be saved.

Thanks for any help.


Jan 20 '06 #3
Hi,

add
g.Clear(Color.W hite) before g.DrawLine(Pens .Black, 5,5,50,5)
this clears the drawing surface and should do the trick for you

Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Yash" <de*********@gm ail.com> schreef in bericht
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .

Thanks Peter
The saving part is working perfectly.
The preview also shows the image properly.

But there's another problem
The image contains Black and colored lines.
So if we open this image in Paint to change some colors,
the background shown is black -- which hides the black lines totally.

I tried Bitmap.MakeTran sparent but still the same.
The image is transparent but still the background is black.
Is this a .NET problem or Paint problem.
Any idea how to change this.
Peter Proost wrote:
Hi, you need to draw to a bitmap's Graphics object:

Dim b As Bitmap = New Bitmap(100,100)
Dim g As Graphics = Graphics.FromIm age(b)

g.DrawLine(Pens .Black, 5,5,50,5)
g.Dispose()

picturebox1.ima ge = b
b.Save(...)

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook)

"Yash" <de*********@gm ail.com> schreef in bericht
news:11******** *************@f 14g2000cwb.goog legroups.com...
Have used DrawLine() method to draw some lines in the picturebox (sort
of a barcode) in the picturebox paint event.
This diagram has to be saved as an image in bmp or tiff format.
But the problem is that these lines are not recognized as the image of
the picturebox.
It shows picturebox.imag e = nothing.

How do we convert these lines drawn as the image of the picturebox so
that it can be saved.

Thanks for any help.

Jan 20 '06 #4
"Yash" <de*********@gm ail.com> schrieb:
Have used DrawLine() method to draw some lines in the picturebox (sort
of a barcode) in the picturebox paint event.
This diagram has to be saved as an image in bmp or tiff format.


<URL:http://www.dotnetrix.c o.uk/misc.html>
-> "Save the Image currently displayed in a PictureBox."

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Jan 20 '06 #5

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

Similar topics

8
31521
by: Pavan Arise | last post by:
Dear all.. I have a picturebox filled on a form. The picturebox has some graphics displayed on it.I was trying to save the picturebox, but continuesly failed to do so. I am clueless of why it is happening. I tried to save the image of the form & also the picturebox, but always, i see a blank file saved. Is there a way to save whatever is displayed on the picturebox, to a file?? Thanks for any suggestions and help. Regards,
2
16406
by: Michael Lehar | last post by:
Hallo I have a pictureBox with a picture loaded from file, then I draw some lines on the picture, and then I want to save the new picture. Befor I can draw lines I have to create a Graphics object, with g = pictureBox.CreateGraphic, and draw lines g.drawLines(....) But when saving the picture, the new picture have no lines, it is only a copy.
2
20946
by: Tomomichi Amano | last post by:
Hello How can I delete (clear) lines that were made useing Graphics.DrawLine() ? Thanks in advance! Have a nice day!
5
2734
by: Brian | last post by:
Hello all.. Am working on an Air Hockey game... have an table loaded into a picture box. The borders of the table are slightly slanted. Am using hit testing lines with GDI+ to manipulate the puck moving around. I want the puck is bounce when it hits a border (specified by the hitlines). Retreieved some info on hit testing lines from Bob Powell's GDI+ FAQ (very useful!) but i'm fairly new at the idea of hit testing and am
12
57294
by: yaya via DotNetMonster.com | last post by:
Hi, I have a picture box with circles and rectangles, and I wana save all the images into a jpg file, i tried pictureBox1.Image.Save(@"c:\1.jpg"); but I got and error "System.NullReferenceException: Object reference not set to an instance of an object." Can anyone help? Thanks... --
0
1123
by: melanieab | last post by:
Hi, I'm trying to get a clock to run. What I have is this: private void toggleOnOff_Click(object sender, System.EventArgs e){} which looks to see which picture to load in a picturebox. It then says to either go to this.notPolar(); or this.Polar(); of which I have:
9
3180
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I want to be able to draw lines in a picturebox based upon certain data points I have received. I dragged a picturebox from the toolbar onto my form, but after having gone through the help files, looking online and trying a variety of things, I...
12
4035
by: Lee | last post by:
I have the following code using System; using System.Windows.Forms; using System.Drawing; using System.Collections; namespace FINN {
10
7419
by: eddie tan | last post by:
Hi, I have a picturebox with graphics drawn from different objects. In one object I used Pen P1; P1 = new Pen(Color.Blue, 3); Graphics g = null; g = Graphics.FromImage(image.Image); g.DrawPath(P1, Wirepath);
0
8707
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9074
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
7953
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
6634
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
5947
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4464
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...
0
4725
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3158
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

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.