zoukankan      html  css  js  c++  java
  • iOS 给图片添加水印

    • 给图片添加文字水印
    //添加文字水印到指定图片上
    +(UIImage *)addWaterText:(NSString *)text Attributes:(NSDictionary*)atts toImage:(UIImage *)img rect:(CGRect)rect{
        
        CGFloat height = img.size.height;
        CGFloat width = img.size.width;
        //开启一个图形上下文
        UIGraphicsBeginImageContext(img.size);
        
        //在图片上下文中绘制图片
        [img drawInRect:CGRectMake(0, 0,width,height)];
        
        //在图片的指定位置绘制文字   -- 7.0以后才有这个方法
        [text drawInRect:rect withAttributes:atts];
        
        //从图形上下文拿到最终的图片
        UIImage *newImg = UIGraphicsGetImageFromCurrentImageContext();
        
        //关闭图片上下文
        UIGraphicsEndImageContext();
        
        return newImg;
    }
    
    • 给图片添加图片水印
    +(UIImage *)addWaterImage:(UIImage *)waterImg toImage:(UIImage *)img rect:(CGRect)rect{
        
        CGFloat height = img.size.height;
        CGFloat width = img.size.width;
        //开启一个图形上下文
        UIGraphicsBeginImageContext(img.size);
        
        //在图片上下文中绘制图片
        [img drawInRect:CGRectMake(0, 0,width,height)];
        
        //在图片指定位置绘制图片
        [waterImg drawInRect:rect];
        
        //从图形上下文拿到最终的图片
        UIImage *newImg = UIGraphicsGetImageFromCurrentImageContext();
        
        //关闭图片上下文
        UIGraphicsEndImageContext();
        
        return newImg;
    }
    
  • 相关阅读:
    亚像素
    dmysql 与QT的连接
    opencv中ptr的使用
    对图片对比度和亮度的理解
    opencv中的各种滤波设计
    人脸检测相关介绍
    opencv中相关的矩阵运算
    形态学处理
    阀值化 threshold
    Python深浅拷贝
  • 原文地址:https://www.cnblogs.com/qqcc1388/p/6742260.html
Copyright © 2011-2022 走看看