add
This commit is contained in:
@@ -20,6 +20,33 @@
|
||||
|
||||
}
|
||||
|
||||
+(void)savaShareImange:(NSString *)fileName image:(UIImage *)image{
|
||||
|
||||
NSData*imageData=UIImageJPEGRepresentation(image,1.0f);
|
||||
NSString *fullPath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:fileName];
|
||||
[imageData writeToFile:fullPath atomically:YES];
|
||||
|
||||
}
|
||||
|
||||
+(void)delectShareImage:(NSString *)imageName{
|
||||
|
||||
//删除文件夹及文件级内的文件:
|
||||
NSString *fullPath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:imageName];
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];[fileManager removeItemAtPath:fullPath error:nil];
|
||||
|
||||
}
|
||||
|
||||
+(UIImage *)getUserShareImage:(NSString *)imageName{
|
||||
|
||||
|
||||
NSString*fullpath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:imageName];
|
||||
UIImage*saveImage=[[UIImage alloc]initWithContentsOfFile:fullpath];
|
||||
if (!saveImage) {
|
||||
saveImage = [UIImage imageNamed:@"sharebg_1"];
|
||||
}
|
||||
return saveImage;
|
||||
}
|
||||
|
||||
+ (UIImage *)getUserAvatorWith:(NSString *)userId{
|
||||
|
||||
if (!userId) {
|
||||
@@ -81,4 +108,65 @@
|
||||
return newimage;
|
||||
|
||||
}
|
||||
|
||||
+(UIImage *)zipScaleWithImage:(UIImage *)sourceImage{
|
||||
//进行图像尺寸的压缩
|
||||
CGSize imageSize = sourceImage.size;
|
||||
//取出要压缩的image尺寸
|
||||
CGFloat width = imageSize.width;
|
||||
//图片宽度
|
||||
CGFloat height = imageSize.height;
|
||||
//图片高度 //1.宽高大于1280(宽高比不按照2来算,按照1来算)
|
||||
if (width>1280||height>1280) { if (width>height) { CGFloat scale = height/width; width = 1280; height = width*scale;
|
||||
|
||||
}else{ CGFloat scale = width/height;
|
||||
height = 1280; width = height*scale;
|
||||
|
||||
}
|
||||
//2.宽大于1280高小于1280
|
||||
|
||||
}else if(width>1280||height<1280){
|
||||
CGFloat scale = height/width;
|
||||
width = 1280;
|
||||
height = width*scale;
|
||||
//3.宽小于1280高大于1280
|
||||
|
||||
}else if(width<1280||height>1280){
|
||||
CGFloat scale = width/height; height = 1280; width = height*scale;
|
||||
//4.宽高都小于1280
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
//进行尺寸重绘
|
||||
UIGraphicsBeginImageContext(CGSizeMake(width, height));
|
||||
[sourceImage drawInRect:CGRectMake(0,0,width,height)]; UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
|
||||
return newImage;
|
||||
|
||||
}
|
||||
|
||||
+(void)saveUserFeedbackImag:(NSString *)imagename image:(UIImage *)image
|
||||
{
|
||||
|
||||
|
||||
NSData*imageData=UIImagePNGRepresentation(image);
|
||||
NSString *fullPath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:[NSString stringWithFormat:@"gigafeed/%@.png",imagename]];
|
||||
NSLog(@"fullPath%@",fullPath);
|
||||
[imageData writeToFile:fullPath atomically:YES];
|
||||
}
|
||||
|
||||
+(UIImage *)getUserFeedbackImag:(NSString *)imageName{
|
||||
NSString*fullpath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:[NSString stringWithFormat:@"gigafeed/%@.png",imageName]];
|
||||
UIImage*saveImage=[[UIImage alloc]initWithContentsOfFile:fullpath];
|
||||
|
||||
return saveImage;
|
||||
}
|
||||
|
||||
+(void)delectAllfeedimages{
|
||||
|
||||
NSString *fullPath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:[NSString stringWithFormat:@"gigafeed/"]];
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];[fileManager removeItemAtPath:fullPath error:nil];
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user