/**/ /// <Summary>
/// Processed to obtain the thumbnail
/// </Summary>
/// <Param name = "Ms"> </param>
/// <Param name = "height"> </param>
/// <Returns> </returns>
Private Byte [] Lessonpicautowidth (memorystream MS, Int Height)
{
Byte [] Chagedbyte;
System. Drawing. Image originalimage = System. Drawing. image. fromstream (MS, True );
System. Drawing. Bitmap originalpic, newpic;
Originalpic = New System. Drawing. Bitmap (originalimage );
Int Width = Height * Originalpic. Width / Originalpic. height;
If (Width > 280 )
{
Width= 280;
}
Newpic = New Bitmap (originalpic, width, height );
Memorystream newms = New Memorystream ();
Newpic. Save (newms, system. Drawing. imaging. imageformat. JPEG );
Chagedbyte = Newms. getbuffer ();
Originalpic. Dispose ();
Newpic. Dispose ();
Newms. Close ();
Return Chagedbyte;
}
/**//// <Summary>
///Show Image
/// </Summary>
/// <Param name = "employeeid"> </param>
Public Void Getphoto ( String Employeeid, Int Height)
{
Bitmap BMP;
Byte [] Photobyte;
String Cnstr;
String SQL;
Cnstr = " Data Source = localhost; database = northwind; uid = sa; Pwd = 123 " ;
SQL = " Select photo from employees where emplyeeid = " + Employeeid;
Using (Sqlconnection CN = New Sqlconnection (cnstr ))
{
Using (Sqlcommand cmd = CN. createcommand ())
{
CN. open ();
Cmd. commandtext = SQL;
Using (Sqldatareader Reader = Cmd. executereader (commandbehavior. sequentialaccess ))
{
Reader. Read ();
Photobyte=(Byte[]) Reader. getvalue (0);
}
}
}
If (Photobyte = Null | Photobyte. Length = 0 ) Return ;
Memorystream tempstream= NewMemorystream (photobyte );
Photobyte = Lessonpicautowidth (tempstream, height );
BMP = New Bitmap (tempstream );
Response. contenttype = " Image/GIF " ;
BMP. Save (response. outputstream, system. Drawing. imaging. imageformat. GIF );
Response. End ();
}