473,395 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Saving picturebox image with graphics in it

2
Hi,

so yeah. what i'm trying to do is load an image from my database create some graphics to it. probably just some lines and marks and save it back to my database. here's so far what I got.
Expand|Select|Wrap|Line Numbers
  1.  
  2. for creating graphics:
  3.  
  4.  }
  5.         private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
  6.         {
  7.             draw = true;
  8.         }
  9.         private void pictureBox3_MouseMove(object sender, MouseEventArgs e)
  10.         {
  11.             if (draw)
  12.             {
  13.                 Graphics g = Graphics.FromImage(pictureBox3.Image);
  14.                 g.FillEllipse(color, e.X, e.Y, 25, 25);
  15.                 pictureBox3.Invalidate();
  16.             }
  17.         }
  18.         private void pictureBox3_MouseUp(object sender, MouseEventArgs e)
  19.         {
  20.             draw = false;
  21.         }
  22.  
and for saving it:
Expand|Select|Wrap|Line Numbers
  1. }
  2. private void button15_Click(object sender, EventArgs e)
  3.         {
  4.  
  5.             Image img = pictureBox3.Image;
  6.             byte[] byteImg = ImageToByteArray(img);
  7.                     OleDbConnection oleDbConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\Asthred\\Documents\\sad\\Sad.mdb");
  8.             OleDbCommand oleDbCommand = new OleDbCommand();
  9.             oleDbCommand.Connection = oleDbConnection;
  10.             oleDbCommand.CommandText = "UPDATE Patientsinformation SET Toothchart = @image   WHERE Lastname= @tb58 AND Firstname= @tb58 ";
  11.             oleDbCommand.Parameters.AddWithValue("@image", byteImg);
  12.             oleDbCommand.Parameters.AddWithValue("@tb58", tb58.Text);
  13.             oleDbCommand.Parameters.AddWithValue("@tb57", tb57.Text);
  14.             oleDbConnection.Open();
  15.             oleDbCommand.ExecuteNonQuery();
  16.             oleDbConnection.Close();
  17.             MessageBox.Show("Record Updated!");
  18.             this.patientsinformationTableAdapter.Fill(this.sadDataSet.Patientsinformation);
  19.         }
  20.  
but the saving part doesnt work :( I think it only saves the image loaded to the picturebox but not the graphics created to it. how to merge it? i've tried to google it and found some sort of same cases but fails to make it work, something like converting it to bitmap. first time c# user by the way so yeah sort of ahh, having a hard time. thanks by the way in advance. help :((
Aug 23 '13 #1
2 7936
bcarey
5
I am not sure but I think you need to save your Graphics g that was changed and not the original image in the picturebox
Aug 23 '13 #2
Ashiie
2
Got it solved :)) thanks anyway.:)
I finally figured out the converting to bitmap thinggy :D

converted the image from the picturebox to bitmap

Expand|Select|Wrap|Line Numbers
  1. private void pictureBox3_MouseMove(object sender, MouseEventArgs e)
  2.         {
  3.             if (draw)
  4.             {
  5.                 Image pic = pictureBox3.Image;
  6.                 Bitmap bmp = new Bitmap(pic);
  7.                 Graphocs g = Graphics.FromImage(bmp);
  8.                 g.FillEllipse(color, e.X, e.Y, 5, 5);
  9.                 pictureBox3.Image = bmp;
  10.             }
  11.         }
Aug 24 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
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...
0
by: dlamar | last post by:
I'm using VB.NET with 2.0 - I have a number of PictureBoxes in my application - all of which use a context menu to change the associated Image to one of 5 options. I need to maintain the state of...
2
by: Frank | last post by:
For various reasons I want to use a PictureBox to display images. That is I want sometimes to assign an Image to the PictureBox Sometimes I want to draw on that Image. What are the reasons for...
0
by: jamesjames | last post by:
Hello, could anyone tell me how to save a bitmap from picturebox.image as a 24bpprgb bitmap? picturebox.Image.Save(path, ImageFormat.Bmp) saves a 32bpprgb bitmap and Bitmap bmp =...
3
by: Andrzej | last post by:
I have a picturebox on my C# .NET form. The picturebox size mode is set to zoom. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
2
Atran
by: Atran | last post by:
Hello everybody, how I can edit the picturebox image? I want to edit the image using something like "magic wand tool". "Magic Wand Tool" is a tool in photoshop, this tool takes a part of the image...
4
by: Jerry West | last post by:
I have a routine that updates a PictureBox image every x seconds. I do this by first loading an array with the path to all of the images. I then generate a random number to use as the index of the...
0
by: irtehnoob | last post by:
Hi there, I'm pretty new to c# (started up a few days ago) and I'm making a simple program, so far everything is going good except I can't figure somethine out.. hence why I'm here. Anyways, in my...
2
by: keerthisreenu | last post by:
hai to all...!! iam working with Ms Access 2000. iam saving an image in the database. After that i want to retrive the same image from database and displaying it in the picture box. but its not...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
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...

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.