C # Picture processing pixel quality code issues

Source: Internet
Author: User
Private byte[] Putlogoinimage (image commodityimage, image priceimage, string activeprice, bool Checked11, imag

            e brandlogoimage = null) {byte[] result = NULL;
            Image im = Commodityimage; using (Image mypriceimage = Priceimage.clone () as Image) {logopriceimage (Mypriceimage, active

                Price, CHECKED11); Create a brush using (Graphics g = graphics.fromimage (IM)) {G.interpolationmo
                    de = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                    G.pixeloffsetmode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

                    g.compositingquality = System.Drawing.Drawing2D.CompositingQuality.Default;
                        if (brandlogoimage!= null) {using (Bitmap BM = new Bitmap (brandlogoimage))
                {//hit upper left corner            G.drawimage (BM, new System.Drawing.Rectangle (0, 0, BM.) Width, BM. Height), 0, 0, BM. Width, BM.
                        Height, GraphicsUnit.Pixel);
                        The using (Bitmap BM = new Bitmap (mypriceimage)) { #region thumbnail//var tempimg= BM.
                        Getthumbnailimage ((), INTPTR, NULL, New ()); G.drawimage (tempimg, new Rectangle (IM). Width-tempimg.width, im.  
                        Height-tempimg.height, Tempimg.width, tempimg.height)); #endregion//BM. Maketransparent (Color.White); Comment out, otherwise the bottom chart will have an effect on the icon ZHJW 20151102//hit to the lower right corner of G.drawimage (BM, new Rectangle (IM.W IDTH-BM. Width, im. HEIGHT-BM. Height, BM. Width, BM.
                    Height));
 }///will save the picture byte[] using (MemoryStream ms = new MemoryStream ())           {using (Bitmap BMP = new Bitmap (IM))//must create a new object {var ici
                    = Getimageencoder (IM); if (ici = null) {BMP. Save (MS, im.
                    Rawformat);
                        else {using (var EP = new EncoderParameters {Param = new encoderparameter[] {new encoderpa
                            Rameter (System.Drawing.Imaging.Encoder.Quality, 100L)}}) { Bmp.
                        Save (MS, ICI, EP); result = Ms.
                ToArray ();
        } return result; private static ImageCodecInfo Getimageencoder (Image img) {//Critical quality control//Get the number of system encoding types
            Group that contains the Jpeg,bmp,png,gif,tiffvar icis = Imagecodecinfo.getimageencoders ();
            ImageCodecInfo ici = null; foreach (ImageCodecInfo i in ICIS) {if (IMG).
                    Rawformat.guid = = I.formatid)//Picture format consistent//if (I.mimetype = = "Image/png")//default fetch PNG encoder {
                    ICI = i;
                Break
        } return ICI; }

Related Article

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.