A simple implementation of the iOS watermark

Source: Internet
Author: User

-(void) Watermark {

UIImage *oldimage = [UIImage imagenamed:@ "pre-prepared picture, you will be on this account image to add a watermark"];

Uigraphicsbeginimagecontextwithoptions (Oldimage.size, NO, 0.0);

[Oldimage drawinrect:cgrectmake (0, 0, OldImage.size.width, oldImage.size.height)];

UIImage *waterimage = [UIImage imagenamed:@ "This is the logo you are going to place on the pre-prepared image"];

CGFloat waterw = 50;

CGFloat waterh = 25;

CGFloat Waterx = oldimage.size.width-waterw-5;

CGFloat watery = oldimage.size.height-waterh-5;

CGRect waterrect = CGRectMake (Waterx, watery, waterw, waterh);

[Waterimage Drawinrect:waterrect];

Get the final picture

UIImage *newimage = Uigraphicsgetimagefromcurrentimagecontext ();

Uigraphicsendimagecontext ();

Self.imageView.image = NewImage;

NSData *data = uiimagepngrepresentation (newimage);

[Data writetofile:@] Save the finished picture to the file path/Picture name. png "Atomically:yes";

}

A simple implementation of the iOS watermark

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.