Two-dimensional Code business card

Source: Internet
Author: User

 <summary>///Image Watermark (Image center)///</summary>//<param name= "Srcimgpath" > Original picture path </param>//<param name= "Waterpath" > Watermark image Path </param>//<param name= "waterwidth" > Watermark Area Width of the field </param>///<param Name= "waterheight" > Height of Watermark area </param>//<param name= "waterstring "> Watermark character </param>//<param name=" markposition "> Watermark location </param> public static void Makewat Erpic (String Srcimgpath, string waterpath, int waterwidth, int waterheight, string waterstring, String markposition = "in the picture                ") {//1. Create an Image object using from the original image (Image img = image.fromfile (srcimgpath)) { 2. Initializes a new instance of the Bitmap class using (Bitmap map = new Bitmap (IMG) in the specified size and format. Width, IMG.                     Height, Pixelformat.format32bppargb)) {//3. Create a new Graphics object from the specified Image object using (Graphics g = graphics.fromimage (Map) {//4. Draws the original picture object at the specified position and at the specified size G.drawimage (IMG, new R Ectangle (0, 0, IMG. Width, IMG. Height), new RectangleF (0, 0, IMG. Width, IMG.                        Height), GraphicsUnit.Pixel); G.drawimage (Map2,new Rectangle (0, 0, map2. Width, Map2.                        Height)); Set the watermark font int fheight = img.                        HEIGHT/5;                        if (Fheight >) fheight = 16;                        Font drawfont = new Font ("Arial", fheight);                        Sets the watermark text position int disx = 0, Disy = 0; if (markposition = = "Picture middle") {DISX = (img.                            Width-waterwidth)/2; Disy = (img.                        Height-waterheight)/2;                        } StringFormat Drawformat = new StringFormat ();                 Drawformat.formatflags = Stringformatflags.nowrap;       Text centered display drawformat.alignment = Stringalignment.center;                        Drawformat.linealignment = Stringalignment.center;                        SolidBrush Drawbrush = new SolidBrush (color.white);                        Fill Rectangle G.fillrectangle (drawbrush, New Rectangle (DISX, Disy, Waterwidth, waterheight));                        Drawbrush.color = Color.Black;                        g.DrawString (waterstring, Drawfont, Drawbrush, New RectangleF (DISX, Disy, Waterwidth, waterheight), DrawFormat); Map.                    Save (Waterpath, imageformat.jpeg); }                }            }        }

  

Two-dimensional Code business card

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.