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;
    }
  • 相关阅读:
    浅谈flume
    浅谈storm
    浅谈zookeeper
    IntelliJ IDEA 使用教程
    浅谈spark
    添加本地jar包到maven仓库
    eclipse通过maven进行打编译
    pom.xml中添加远程仓库
    maven编译错误maven-assembly-plugin:2.2-beta-5:assembly (default-cli) on project
    最长上升子序列
  • 原文地址:https://www.cnblogs.com/keyan1102/p/4487037.html
Copyright © 2011-2022 走看看