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;
    }
  • 相关阅读:
    HDU 4901 The Romantic Hero
    COGS8 备用交换机
    POJ 1466 Girls and Boys
    bzoj3442 学习小组
    bzoj2054 疯狂的馒头
    POJ2135 Farm Tour
    POJ 1149 PIGS
    Html5 Canvas学习之路(五)
    关于跨域简单总结
    vue-baidu-map 进入页面自动定位的解决方案!
  • 原文地址:https://www.cnblogs.com/keyan1102/p/4487037.html
Copyright © 2011-2022 走看看