Thumbnail generation

xiaoxiao2021-03-06  17

Namespace serverflat.userCtrl {using system; using system.data; using system.drawing; using system.web; using system.web.ui.webcontrols; using system.web.ui.htmlcontrols;

///

/// newfocus's summary description. /// public class Newfocus: System.Web.UI.UserControl {protected System.Data.SqlClient.SqlConnection sqlCon; protected System.Data.SqlClient.SqlCommand sqlCommand1; protected System.Web.UI.WebControls.Image ImageSource ; protected System.Web.UI.WebControls.HyperLink HyperLink1; protected System.Web.UI.WebControls.HyperLink HyperLink2; protected System.Web.UI.WebControls.HyperLink HyperLink3; // define a variable public int Id2; public int Id1; public int Id3; protected string imagename; // protected string mpath; // class object definition image, GDI drawing class System.Drawing.Image Image, newImage; protected System.Web.UI.WebControls.ImageButton ImgBtt1; protected System.Web. UI.WebControls.ImageButton ImgBtt2; protected System.Web.UI.WebControls.ImageButton ImgBtt3; // protected System.Web.UI.WebControls.Label Label1; // a callback method for determining execution Image object generated thumbnail When operating in advance // If this method determines that the getthumbnailimage method should stop execution in advance, return true; otherwise returns false system.drawing.image.getthumbnailimageabort callb = null;

Private void page_load (object sender, system.eventargs e) {// Place user code here to initialize page this.sqlcon.Open (); this.imagesource.visible = false; // Hide original image System.Data.sqlclient . SqlDataReader Dr = SQLCOMMAND1.EXECUTEREADER (); if (DR.READ ()) {for (int i = 0; i <3; i ) {this.imageSource.ImageURL = DR ["PicturePath"]. Tostring (); // Get the picture name imagename = imagesource.imageurl.substring (this.imagesource.imageurl.lastIndexof ("//") 1); // Establish reference to image = system.drawing.image.FROMFile (Server.MAppath this.ImageSource.ImageUrl)); // create thumbnail newImage = Image.GetThumbnailImage (100,100, callb, IntPtr.Zero); // save thumbnail NewImage.Save (Request.PhysicalApplicationPath on the virtual path "small //" ImageName, System.drawing.Image.ImageFormat.jpeg); // Release space image.dispose (); newimage.dispose (); // Display thumbnail if (i == 0) {id1 = system.convert.toint16 ( DR ["ID"]. TOSTRING ()); this.hyperlink1.text = DR ["picDescribe"]. Tostring (); this.hyperlink1.navigateURL = "../ w EBFORM / INFOVIEW.ASPX? ID = " id1; this.imgbtt1.imageURL = Request.PhysicalApplicationPath " small // " imagename;} if (i == 1) {ID2 = system.convert.toint16 (DR [" ID "] .Tostring ()); this.hyperlink2.text = DR [" picDescribe "]. TOSTRING (); this.hyperlink2.navigateURL =" ../ Webform / InfoView.aspx? Id = " ID2; this.imgbt2 .Imageurl = request.physicalApplicationPath "small //" imagename;} if (i == 2) {id3 = system.convert.toint16 (DR ["ID"]. TOSTRING ());

. This.HyperLink3.Text = dr [ "PicDescribe"] ToString (); this.HyperLink3.NavigateUrl = "../ WebForm / infoview.aspx ID =?" Id3; this.ImgBtt3.ImageUrl = Request.PhysicalApplicationPath "small // " ImageName;} Dr.read ();}} Dr.close (); sqlcon.close ();} #Region Web Form Designer Generated Code Override Protected Void OnInit (Eventargs E) {// / / Codegen: This call is required for the ASP.NET Web Form Designer. // initializeComponent (); base.oninit (e);} ///

/// Designer Support required method - Do not use code editor // to modify the contents of this method. /// private void InitializeComponent () {System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader (); this.sqlCon = new System.Data.SqlClient.SqlConnection (); this.sqlCommand1 = new System .Data.SqlClient.SqlCommand (); this.ImgBtt1.Click = new System.Web.UI.ImageClickEventHandler (this.ImageButton1_Click); this.ImgBtt2.Click = new System.Web.UI.ImageClickEventHandler (this.ImgBtt2_Click) ; this.ImgBtt3.Click = new System.Web.UI.ImageClickEventHandler (this.ImgBtt3_Click); // // sqlCon // this.sqlCon.ConnectionString = ((string) (configurationAppSettings.GetValue ( "ConnString", typeof ( string)))); this.sqlCon.InfoMessage = new System.Data.SqlClient.SqlInfoMessageEventHandler (this.sqlCon_InfoMessage); // // sqlCommand1 // this.sqlCommand1.CommandText = "[sp_GetPicture]"; this.sqlCommand1. CommandType = system.data.commandtype.StoredProcedure; this.sqlcommand1.connection = this.sqlcon; THI s.Load = new system.eventhandler (this.page_load);

} #Endregion

private void sqlCon_InfoMessage (object sender, System.Data.SqlClient.SqlInfoMessageEventArgs e) {} private void ImageButton1_Click (object sender, System.Web.UI.ImageClickEventArgs e) {Response.Redirect ( "../ WebForm / infoview.aspx? ID = " ID1);} private void imgbtt2_click (object sender, system.web.ui.ImageClickeventargs e) {response.redirect (" ../ Webform / InfoView.aspx? Id = " id2);}

Private void imgbtt3_click (object sender, system.Web.ui.ImageClickevenTargs e) {response.redirect ("../ Webform / InfoView.aspx? id =" id3);}

}

转载请注明原文地址:https://www.9cbs.com/read-40277.html

New Post(0)