Hi guys,
I have here an already exists code that read an image file from the database which saved into a binary(I think) I'm not familiar with it, now when I try to read the file and put in the picturebox, it shows the image perfectly, now when I try to save it to something like..."C:\blah blah..." it gives a 0 byte which gives a no image at all, now I'm having problem where to trace it since this is not my code.
Here's some code:
Reading from the database
Save and Preview the imageCode:while (dreader.Read()) { Photo =(byte[])dreader["pb1"]; Stream myStream = new MemoryStream(Photo, true); index = int.Parse(dreader["flag"].ToString()); myStream.Write(Photo, 0, Photo.Length); pb[index].Image = new Bitmap(myStream); myStream.Close(); } dreader.Close();
Code:private void b1_Click(object sender, System.EventArgs e) { string flpath = "C:\\Temp\\pct.bmp"; int pcounter = 0; Rectangle rect=new Rectangle(); rect = Screen.GetWorkingArea(this); try { for ( int counter = 0;counter<p.Length; counter++) { pcounter = counter; if (sender.Equals(p[counter])) break; } filename.Text = flpath; pb[pcounter].Image.Save(flpath); System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(flpath); psi.Verb = "Print"; System.Diagnostics.Process.Start(psi); } catch (Exception ex) { MessageBox.Show("Cannot Show an empty Frame.","Warning", MessageBoxButtons.OK,MessageBoxIcon.Warning); } }




Reply With Quote