zoukankan      html  css  js  c++  java
  • 图片裁剪处理

     (UIImage*)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize)newSize
    {
        // Create a graphics image context
        UIGraphicsBeginImageContext(newSize);
        
        // Tell the old image to draw in this new context, with the desired
        // new size
        [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
        
        // Get the new image from the context
        UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
        
        // End the context
        UIGraphicsEndImageContext();
        
        // Return the new image.
        return newImage;
    }
    -(NSString *)ImageBase64String:(NSString *)path image:(UIImage *)oimage{
        
        UIImage *_originImage = nil;
        if (path) {
            _originImage = [UIImage imageWithContentsOfFile:path];
        }else{
            _originImage = oimage;
        }
        
        NSData *_data = UIImageJPEGRepresentation(_originImage, 1.0f);
        //    NSString *_encodedImageStr = iOS_Agin7?[_data base64Encoding]:[_data base64EncodedDataWithOptions:0];
        
        NSString *_encodedImageStr = nil;
        
        if ([_data respondsToSelector:@selector(base64EncodedDataWithOptions:)])
        {
            // It exists, so let's call it
            _encodedImageStr = [_data base64EncodedStringWithOptions:0];
        }
        else
        {
            // Use the old API
            _encodedImageStr = [_data base64Encoding];
        }
        
        //    NSLog(@"===Encoded image:
    %@", _encodedImageStr);
        return _encodedImageStr;
    }
  • 相关阅读:
    JVM底层原理 内存模型+GC垃圾回收
    新Socket与网络小结
    Redis五大数据结构及基本指令用法
    MySql高级汇总-事务,索引,SQL调优,分库分表,读写分离
    笔试错题整理
    设计模式(思路)
    网络编程
    linux
    基础算法--KMP匹配字符串
    基础算法--整数二分
  • 原文地址:https://www.cnblogs.com/keyan1102/p/4487037.html
Copyright © 2011-2022 走看看