Private void btnSelectImage_Click (object sender, EventArgs e)
{
// Read the image to be stored as a data stream
OpenFileDialog1.Filter = "* jpg | * bmp ";
If (DialogResult. OK = openFileDialog1.ShowDialog ())
{
Foreach (string file in openFileDialog1.FileNames)
{
FileStream fsBLOBFile = new FileStream (file, FileMode. Open, FileAccess. Read );
Byte [] bytBLOBData = new byte [fsBLOBFile. Length];
Buffer = new byte [fsBLOBFile. Length];
FsBLOBFile. Read (bytBLOBData, 0, bytBLOBData. Length );
FsBLOBFile. Close ();
Buffer = bytBLOBData;
}
}
}
Void ShowImage (byte [] imagecode)
{
If (imagecode! = Null)
{
MemoryStream repeated blobdata = new MemoryStream (imagecode );
System. Drawing. Image bmp = System. Drawing. Image. FromStream (batch blobdata );
Rectangle rc = pictureBox1.ClientRectangle;
SizeF size = new SizeF (bmp. Width/bmp. HorizontalResolution, bmp. Height/bmp. VerticalResolution );
Float fScale = Math. Min (rc. Width/size. Width, rc. Height/size. Height );
Size. Width * = fScale;
Size. Height * = fScale;
PictureBox1.Image = new Bitmap (bmp, size. ToSize ());
This. pictureBox1.SizeMode = System. Windows. Forms. PictureBoxSizeMode. AutoSize;
Repeated blobdata. Close ();
}
}
Author: chinaboykai