我希望在向NSMutableData附加额外字节后从NSdata保存图像。以下是我的要求的示例代码。
NSData *sourceData = = UIImageJPEGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"], 1);
NSMutableData *concatenatedData = [NSMutableData data];
[concatenatedData appendData:sourceData];
[concatenatedData appendData:sourceData];
UIImage *myFinalImage = [[UIImage alloc] initWithData:concatenatedData];
UIImageWriteToSavedPhotosAlbum(myFinalImage, self, nil, nil);
我将sourcedata附加了2次,但我的最终图像只保存了一个sourceData字节。
我在这里错过了什么吗?
答案 0 :(得分:1)
以下是样本:
CGSize newSize = CGSizeMake({Here give width}, {Here give height});
UIImage *myFinalImage1 = [[UIImage alloc] initWithData:concatenatedData];
UIImage *myFinalImage2 = [[UIImage alloc] initWithData:concatenatedData];
// Set up width height with values.
CGSize newSize = CGSizeMake(width, height);
UIGraphicsBeginImageContext( newSize );
[myFinalImage1 drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
[myFinalImage2 drawInRect:CGRectMake(newSize.width,newSize.height,newSize.width,newSize.height*2) blendMode:kCGBlendModeNormal alpha:1.0];
UIImage *mergedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();