Code segment 1 ========================= System.drawing.Image Image = system.drawing.image.FromFile (originalFileName); System.drawing. size size = getImageSize (image.Width, image.Height, information.MaximumDimension); System.Drawing.Image bitmap = new System.Drawing.Bitmap (size.Width, size.Height); System.Drawing.Graphics graphics = System. Drawing.Graphics.FromImage (bitmap); graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; graphics.Clear (information.BackgroundColor); graphics.DrawImage ( Image, new system.drawing.Rectangle (0, 0, Bitmap.width, Bitmap.Height), New System.drawing.Rectangle (0, 0, Image.width, Image.Height), System.drawing.graphicsUnit.pixel) Graphics.Dispose (); code segment 2 ===================================== // Original picture name string OriginalFileName = "C: / /222.jpg";/ generated high quality picture name String strgoodfile = "c: //222-small-good.jpg"; // Generated low quality picture name string strbadfile = "C: // 222-small -bad.jpg "; // Reduced multiple int IScale = 3; // Net the image object from the file system.drawing .Image image = system.drawing.image.Fromfile (OriginalFileName); // Number of picture size system.drawing.size size = new size (image.width / iscale, image.Height / Iscale); // New a BMP picture system .Drawing.image bitmap = new system.drawing.bitmap (size.width, size.height); // Newly built a pictureboard system.drawing.graphics g =
System.drawing.graphics.dromimage (bitmap); // Set high quality interpolation g.interpolationmode = system.drawing.drawing2d.interpolationmode.high; // Set high quality, low speed rendering smoothing G.SMoothingMode = system.drawing .Drawing2d.smoothingmode.highquaital; // Clear a picture g.clear (color.blue); // Draw G. DrawImage (image, new system.drawing.Rectangle (0, 0, Bitmap.width, Bitmap) at the specified location. Height), new system.drawing.Rectangle (0, 0, Image.width, Image.Height), System.drawing.graphicsUnit.pixel); // Save high definition thumbnails Bitmap.SAVE (StrGoodFile, System.drawing .Imaging.imageformat.jpeg); // Normal thumbnail of the original image system.drawing.image img = image.dthumbnailimage (image.width / iscale, image.Height / Iscale, Null, INTPTR.ZERO); // Save Ordinary thumbnail img.save (strbadfile, system.drawing.Imaging.imageformat.jpeg); g.dispose (); messagebox.show ("Generated"); 俺 自己 自己 写 图 代 代 === ======================================Bollections; use system.componentmodel; use system.configuration; use system.data Using system.drawing; using system.drawing.imaging; using system.web; using system.web.sessionState; using System.Web.ui; use system.web.ui.webcontrols; using system.web.ui.htmlControls; Namespace bscrm.SHANGPIN {///
IF (Request ["H"]! = NULL && Request ["H"]. TOSTRING (). Trim ()! = "") {height = int.parse (Request ["h"]. TOSTRING () Trim () );} If (Request ["W"]! = NULL && Request ["h"]. TOSTRING (). Trim ()! = "") {Width = int.parse (Request ["W"]. Tostring (). Trim ());} f (Request ["src"]! = Null) {src = imagePath Request ["src"]. ToString (); try {system.drawing.image img = system.drawing.image.fromfile (src);
IF (Height> 0 || Width> 0) {if (Height == 0) Height = img.height; if (width == 0) width = img.width; system.drawing.img2 = img.getthumbnailImage (Width , Height, Null, INTPTR.ZERO; img2.save (response.outputstream, img.rawformat); img2.dispose ();} else {img.save (response.outputstream, IMG.RawFormat);}
Img.dispose ();} catch {error = true;}} else {error = true;
IF (error) {response.statuscode = 404; response.write ("
#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} ///