Re: Creating NSmages from NSMovies for display in an NSOutlineView
Re: Creating NSmages from NSMovies for display in an NSOutlineView
- Subject: Re: Creating NSmages from NSMovies for display in an NSOutlineView
- From: j o a r <email@hidden>
- Date: Sat, 7 Dec 2002 10:44:27 +0100
On Saturday, Dec 7, 2002, at 09:55 Europe/Stockholm, Arved von Brasch
wrote:
- (void)makePreview:(OutlineItem *)displayItem {
NSString *path = [folderPath stringByAppendingFormat: @"/%@",
[displayItem fileName]]; // folderPath is the path of the folder
containing the movies
[previews setObject: [self makeThumbnail: path] forKey:
[displayItem fileName]];
}
There is a nice method in NSString, "stringByAppendingPathComponent:",
that's probably safer to use for this purpose.
In the following method I think that you over-release the "image"
variable:
- (NSImage *)makeThumbnail:(NSString *)fromPath {
NSURL *url = [[NSURL alloc] initFileURLWithPath: fromPath];
NSMovie *movie = [[NSMovie alloc] initWithURL: url
byReference:YES]; // Open Movie
[url release];
PicHandle picHandle = (PicHandle)GetMoviePict([movie QTMovie],
GetMovieDuration([movie QTMovie])); // Get last frame of movie
[movie release];
NSData *imageData = [NSData dataWithBytes: (*picHandle) length:
GetHandleSize((Handle)picHandle)];
KillPicture(picHandle);
NSPICTImageRep *imageRep = [NSPICTImageRep imageRepWithData:
imageData];
NSImage *image = [[[NSImage alloc] initWithSize:[imageRep size]]
autorelease];
// Autoreleased here
[image lockFocus];
[imageRep drawAtPoint:NSMakePoint(0,0)]; // Convert frame into a
useable image.
[image unlockFocus]; // For pure images everything below this is
kept, and the image is initWithContentsOfFile here.
float width = [image size].width;
float height = [image size].height;
imageData = [image TIFFRepresentation];
NSBitmapImageRep *imageBitmap = [NSBitmapImageRep
imageRepWithData:imageData];
[image release];
// Released here
j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.