[Date: 2006-2-25 17:48:17] [Source: Original] [Author: Jerry] [font: medium and small]
Generating thumbnails when developing, generating thumbnails is a very common and practical function. It used to be implemented with COM components in ASP. Now you can use the powerful class library of the framework in .NET. (With detailed notes), refer to some articles on the Internet and .NET SDK related content. The image of QQroom Network Home is used to all four ways.
///
OriginalImage.height; y = 0; x = (ORIGINALIMAGE.WIDTH - OW) / 2;} else {OW = OriginalImage.Width; OH = OriginalImage.Width * Height / Towidth; x = 0; y = ORIGINALIMAGE.HEIGHT - OH / 2;} Break; default: Break;} // Newly built a BMP picture image bitmap = new system.drawing.bitmap (towidth, toheight); // Newly built a picture board graphics g = system.drawing. Graphics.FromImage (bitmap); // interpolation g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High quality setting; // set high, low speed exhibits a degree of smoothing g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode .Hquality; // Empty the canvas and populate g.clear (color.Transparent) in a transparent background; / / Draw the specified section of the original picture in the specified position, the specified section of the original picture, G. DrawImage (0, 0, Towidth, ToHeight), New Rectangle (X, Y, OW, OH), GraphicsUnit.pixel; Try {// Save thumbnails Bitmap.Save (thumbnailpath, system.drawing.image.iMage.jpeg) in JPG format;} catch (system.exception e) {throw e;} finally {OriginalImage.dispose (); bitmap. Dispose (); g.dispose ();}}