sir,
i want to save water marked image to database.i have done watermarking,but save the image it does not save to database.i don't know what happend.
following are my code,
Bitmap original_image = new Bitmap(FileUpload1.FileContent);
string sWaterMark = "reshu";//String to be watermarked
int fontsize = ((original_image.Width * 2) / (sWaterMark.Length * 3));
int x = original_image.Width / 2;
int y = original_image.Height * 9 / 20;
StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Center;
drawFormat.FormatFlags = StringFormatFlags.NoWrap;
//drawing string on Image
Graphics graphic = Graphics.FromImage(original_image);
graphic.DrawString(sWaterMark, new Font("Verdana", fontsize, FontStyle.Bold), new SolidBrush(Color.FromArgb(80, 255, 255, 255)), x, y, drawFormat);
original_image.Save(MapPath("~/" +"/" + FileUpload1.PostedFile.FileName));
if (original_image != null) original_image.Dispose();
if (graphic != null) graphic.Dispose();
string image_name = FileUpload1.PostedFile.FileName;
con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\website\MapExtractor\App_Data\MapDB.mdf;Integrated Security=True;User Instance=True");
con.Open();
cmd = new SqlCommand("insert into Table1(name,image) values('"+TextBox3.Text+"','"+image_name+"')", con);
// cmd.Parameters.AddWithValue("@name", TextBox3.Text);
// int img = FileUpload1.PostedFile.ContentLength;
//byte[] msdata = new byte[img];
//FileUpload1.PostedFile.InputStream.Read(msdata, 0, img);
// cmd.Parameters.AddWithValue("@image", bmp);
cmd.ExecuteNonQuery();
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('Image Added')", true);
con.Close();
sir please check it and help me...