标签:des style blog color io os ar 使用 for
#import <MobileCoreServices/UTCoreTypes.h>
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType]; UIImage *originalImage, /*editedImage,*/ *imageToSave; SQImagePickerController *sqImgPicker = (SQImagePickerController *)picker; // 处理静态照片 if (CFStringCompare ((CFStringRef) mediaType, kUTTypeImage, 0) == kCFCompareEqualTo) { // editedImage = (UIImage *) [info objectForKey:UIImagePickerControllerEditedImage]; originalImage = (UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage]; // if (editedImage) { // imageToSave = editedImage; // } // else { imageToSave = originalImage; // } // 将静态照片(原始的或者被编辑过的)保存到相册(Camera Roll) // UIImageWriteToSavedPhotosAlbum (imageToSave, nil, nil , nil); // 根据图片控件的尺寸缩放照片(只是为了显示效果。实际传输时依然使用原始照片) // UIImage* scaledImage = [self imageWithImage:imageToSave scaledToSize:self.imagePhoto.bounds.size]; //对图片大小进行压缩-- imageToSave = [self imageWithImage:imageToSave scaledToSize:CGSizeMake(158, 100)]; if (_flagType==1) { NSDictionary *data = @{@"paizhaoImage" : imageToSave}; [SQBaseCell sharedInstance].paizhaoImageData = data; // 缓存传输照片 self.imagePicture = imageToSave; [self.allSqInfoView[self.selectedIndex] didrecordValidate:self.tempPaiButton conValue:@"YES" showText:@""]; for (int i=(int)self.imageDicArray.count-1; i>=0; i--) { if ([[self.imageDicArray[i] objectForKey:@"key"] isEqualToString:self.imgButton.accessibilityHint]) { [self.imageDicArray removeObject:self.imageDicArray[i]]; } } NSDictionary *tempDic = [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat:@"%@", self.imgButton.accessibilityHint],@"key", imageToSave,@"imageData", sqImgPicker.fileType, @"fileType", nil]; [self.imageDicArray addObject:tempDic]; } else if(_flagType==2) { NSDictionary *data = @{@"imgData" : imageToSave}; SQInfoView *sqInfoView=self.allSqInfoView[self.selectedIndex]; [sqInfoView insertSubView:[UIButton new] clickView:self.imgButton data:data]; } } [self dismissViewControllerAnimated:YES completion:Nil]; }
//对图片尺寸进行压缩-- -(UIImage*)imageWithImage:(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; }
标签:des style blog color io os ar 使用 for
原文地址:http://www.cnblogs.com/yangmx/p/4047927.html