C # ASP. NET image thumbnail and picture clipping processing

Source: Internet
Author: User
Tags bmp image

 Try                        {                            //Get picture sizeSystem.Drawing.Size Size =NewSystem.Drawing.Size (Convert.ToInt32 (w), Convert.ToInt32 (h)); //Create a new BMP imageSystem.Drawing.Image BMP =NewSystem.Drawing.Bitmap (size. Width, size.                            Height); //Create a new artboardg =System.Drawing.Graphics.FromImage (BMP); //setting high-quality interpolation methodsG.interpolationmode =System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear; //set high quality, low speed rendering smoothnessG.smoothingmode =System.Drawing.Drawing2D.SmoothingMode.HighQuality; //clear the canvas .g.clear (System.Drawing.Color.Transparent); //draw at the specified locationG.drawimage (IMG,NewSystem.Drawing.Rectangle (0,0Bmp. Width, BMP. Height),NewSystem.Drawing.Rectangle (Cwidth/2, Cheigh_h/2Img. Width-cwidth, IMG. Height-cheigh_h), System.Drawing.GraphicsUnit.Pixel);//Cwidth to crop the dimensions//save high-definition thumbnail imagesbmp.                        Save (Newmappath, System.Drawing.Imaging.ImageFormat.Jpeg); }                        finally{g.dispose (); }
related parameters:smoothingmode {The edges of lines, curves, and filled areas are aliased, and it does not control the path gradient brush}invalid//an invalid modeDefault//no anti-aliasing, equivalent to Highspeed, NoneHighspeed//no anti-aliasingHighquality//Anti -aliasing, equivalent to AntiAliasNone//no anti-aliasingAntiAlias//Anti- aliasing interpolationmode {interpolation mode determines how intermediate values between two pixel points are calculated}invalid//the Invalid element that is equivalent to the Qualitymode enumeration.Default//The default mode.Low//low quality interpolation method.High//high-quality interpolation method.Bilinear//bilinear interpolation; This mode does not apply when the image is shrunk to the original size of 50%.Bicubic//dual three-time interpolation, no pre-filtering, and shrinking the image to the original size of 25% when this mode does not apply.Nearestneighbor//the nearest interpolation method.Highqualitybilinear//High-quality bilinear interpolation; Perform pre-screening to ensure high-quality shrinkage.Highqualitybicubic//High-quality double three-time interpolation; performs pre-screening to ensure high quality shrinkage and produces the highest quality conversion image.  compositingmode {color compositing mode}sourceover//mixed with background color; The blend is determined by transparencySourceCopy//Overwrite background color  compositingquality {The source pixel and the target pixel and the composition method}invalid when the image is synthesized//Invalid qualityDefault//Default QualityHighspeed//high speed, low qualityHighquality//high-quality, low-speed compoundinggammacorrected//using grayscale correctionAssumelinear//assuming a linear value  pixeloffsetmode {pixel offset mode}invalid//Invalid mode.Default//The default mode.Highspeed//high speed, low quality rendering.Highquality//high-quality, low-speed rendering.None//There is no pixel offset.Half//pixels are offset by 0.5 units at both horizontal and vertical distances for high-speed sawtooth elimination.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.