Hallo,
ich will gern per nstask einen bald converter anstreben -
mein problem ist wie ich die images richtig rein gebe - hat hier jemand einen tipp oder ein Idee ?
Danke
Alles anzeigen
ich will gern per nstask einen bald converter anstreben -
mein problem ist wie ich die images richtig rein gebe - hat hier jemand einen tipp oder ein Idee ?
Danke
C-Quellcode
- -(id)init
- {
- if ([super init])
- {
- NSString* bundlePath = [[NSBundle mainBundle] bundlePath];
- NSString* imageMagickPath = [bundlePath stringByAppendingPathComponent:@"/Contents/Resources/ImageMagick"];
- NSString* imageMagickLibraryPath = [imageMagickPath stringByAppendingPathComponent:@"/lib"];
- MAGICK_HOME = imageMagickPath;
- DYLD_LIBRARY_PATH = imageMagickLibraryPath;
- }
- return self;
- }
- -(void)composite
- {
- NSTask *task = [[NSTask alloc] init];
- NSLog(@"start");
- // the ImageMagick library needs these two environment variables.
- NSMutableDictionary* environment = [[NSMutableDictionary alloc] init];
- [environment setValue:MAGICK_HOME forKey:@"MAGICK_HOME"];
- [environment setValue:DYLD_LIBRARY_PATH forKey:@"DYLD_LIBRARY_PATH"];
- NSString* pwd = [[self class] pathFromUserLibraryPath:@"Moenster"];
- // executable binary path
- NSString* exe = [MAGICK_HOME stringByAppendingPathComponent:@"/bin/convert"];
- [task setEnvironment:environment];
- [task setCurrentDirectoryPath:pwd]; // pwd
- [task setLaunchPath:exe]; // the path to composite binary
- // these are just example arguments
- [task setArguments:[NSArray arrayWithObjects: @"/Users/michael/Downloads/big/001.png", @"/001.dds", nil]];
- [task launch];
- [task waitUntilExit];
- NSLog(@"end");
- }
- - (NSString *) pathFromUserLibraryPath:(NSString *)inSubPath
- {
- NSArray *domains = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES);
- NSString *baseDir= [domains objectAtIndex:0];
- NSString *result = [baseDir stringByAppendingPathComponent:inSubPath];
- return result;
- }