即時通訊試圖合併Cocoa中的2個不同圖像,並將結果圖像保存在我的應用程序中。我所做的迄今爲止是這樣的:可可合併2圖像並保存它們
-(void)mergeImage:(NSImage*)target withImage:(NSImage*)source {
[target lockFocus];
NSPoint aPoint;
aPoint.x = 1;
aPoint.y = 1;
[source drawAtPoint:aPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
[target unlockFocus];
NSBitmapImageRep *bmpImageRep = [[NSBitmapImageRep alloc]initWithData:[target TIFFRepresentation]];
[target addRepresentation:bmpImageRep];
NSData *data = [bmpImageRep representationUsingType: NSPNGFileType
properties: nil];
NSURL* aURL = [[NSBundle mainBundle] bundleURL];
NSString *tmpPathToFile = [[NSString alloc] initWithString:[NSString stringWithFormat:@"%@/tempImage.png", aURL]];
[data writeToFile:tmpPathToFile atomically:YES];
}
我沒有得到任何錯誤,網站的網址似乎是正確的。並且「數據」保留〜2,9MB 2985448
您沒有(或不應該)被允許寫入應用程序包。他們被密封的原因 – CodaFi