iOS add watermarks to pictures

Source: Internet
Author: User

/** * Imagewithbackgroundimage:: * * @param backgroundimage background image name * @param logoimage watermark Image Name * * @return Add watermark image */+ (Instancetype) Imagewithbackgroundimage: (NSString *) backgroundimage withlogoimage: (NSString *) logoImage{UIImage        *image = [UIImage imagenamed:backgroundimage];        1. Open a bitmap-based bitmap context uigraphicsbeginimagecontextwithoptions (image.size, NO, 0.0);        2. Draw background [image drawinrect:cgrectmake (0, 0, Image.size.width, image.size.height)];    3. Draw Watermark//3.1 Set watermark picture frame UIImage *log = [UIImage imagenamed:logoimage];    CGFloat margin = 5.0;    CGFloat scale = 0.2;    CGFloat Logow = log.size.width * scale;    CGFloat Logoh = log.size.height * scale;    CGFloat Logox = Image.size.width-logow-margin;    CGFloat Logoy = Image.size.height-logoh-margin;        3.2 Draw Watermark [log drawinrect:cgrectmake (Logox, Logoy, Logow, Logoh)];       4. Remove the picture from the graphics context UIImage *newimage = Uigraphicsgetimagefromcurrentimagecontext (); return newimage;}

iOS add watermarks to pictures

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.