.net 加浮水印 圖片變大很多 解決方案

來源:互聯網
上載者:User

標籤:c   style   class   code   a   http   

 /// 給圖片加浮水印 中國紅木網 

        /// </summary>        /// <param name="originalImg"></param>        /// <param name="waterImg"></param>        /// <param name="trbl"></param>        /// <returns></returns>        public static Image WatermarkImage(Image originalImg, Image waterImg, WatermarkTRBL trbl)        {             Image image = (Image)originalImg.Clone();            using (Graphics g = Graphics.FromImage(image))            {                Rectangle r = new Rectangle();                r.Height = waterImg.Height;                r.Width = waterImg.Width;                if (trbl.Top != null)                {                    r.Y = (int)trbl.Top;                }                 if (trbl.Right != null)                {                    r.X = originalImg.Width - waterImg.Width - (int)trbl.Right;                }                 if (trbl.Bottom != null)                {                    r.Y = originalImg.Height - waterImg.Height - (int)trbl.Bottom;                }                 if (trbl.Left != null)                {                    r.X = (int)trbl.Left;                }                 g.DrawImage(waterImg, r, 0, 0, waterImg.Width, waterImg.Height, GraphicsUnit.Pixel);            }             return image;        }

Bitmap b = new Bitmap(image.Width, image.Height,PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(b);

g.Clear(Color.White);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;
g.DrawImage(image, 0, 0, image.Width, image.Height);

 

高品質 用普通模式

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.