Skip to content

Commit

Permalink
Made loadThumbnailForObject return the generated thumbnail image. Thi…
Browse files Browse the repository at this point in the history
…s way the operation can be used from outside iMB, under application specific thread management, to generate thumbnail images.
  • Loading branch information
zykloman committed Aug 2, 2010
1 parent 064fbe0 commit cb36f87
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
6 changes: 4 additions & 2 deletions IMBLightroomParser.m
Expand Up @@ -1127,7 +1127,7 @@ - (NSData*)previewDataForObject:(IMBObject*)inObject
}


- (void) loadThumbnailForObject:(IMBObject*)inObject
- (id) loadThumbnailForObject:(IMBObject*)inObject
{
CGImageRef imageRepresentation = nil;
NSData *jpegData = [self previewDataForObject:inObject];
Expand Down Expand Up @@ -1183,8 +1183,10 @@ - (void) loadThumbnailForObject:(IMBObject*)inObject
modes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
}
else {
[super loadThumbnailForObject:inObject];
imageRepresentation = (CGImageRef) [super loadThumbnailForObject:inObject];
}

return (id) imageRepresentation;
}


Expand Down
2 changes: 1 addition & 1 deletion IMBParser.h
Expand Up @@ -122,7 +122,7 @@

// Called when the thumbnail for an object needs to be loaded lazily. This method will be called on a background thread...

- (void) loadThumbnailForObject:(IMBObject*)inObject;
- (id) loadThumbnailForObject:(IMBObject*)inObject;

// Called when metadata for an object needs to be loaded lazily. This method may be called on a background thread...

Expand Down
4 changes: 3 additions & 1 deletion IMBParser.m
Expand Up @@ -203,7 +203,7 @@ - (IMBObjectPromise*) objectPromiseWithObjects:(NSArray*)inObjects
#pragma mark


- (void) loadThumbnailForObject:(IMBObject*)inObject
- (id) loadThumbnailForObject:(IMBObject*)inObject
{
id imageRepresentation = nil;
NSString* type = inObject.imageRepresentationType;
Expand Down Expand Up @@ -338,6 +338,8 @@ - (void) loadThumbnailForObject:(IMBObject*)inObject
waitUntilDone:NO
modes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
}

return imageRepresentation;
}


Expand Down
9 changes: 7 additions & 2 deletions IMBiPhotoParser.m
Expand Up @@ -344,8 +344,10 @@ - (void) watchedPathDidChange:(NSString*)inWatchedPath
// To speed up thumbnail loading we will not use the generic method of the superclass. Instead we provide an
// implementation here, that uses specific knowledge about iPhoto to load thumbnails as quickly as possible...

- (void) loadThumbnailForObject:(IMBObject*)inObject
- (id) loadThumbnailForObject:(IMBObject*)inObject
{
id imageRepresentation = nil;

// Get path of our object...

NSString* type = inObject.imageRepresentationType;
Expand All @@ -369,6 +371,7 @@ - (void) loadThumbnailForObject:(IMBObject*)inObject

if (image)
{
imageRepresentation = (id) image;
[inObject
performSelectorOnMainThread:@selector(setImageRepresentation:)
withObject:(id)image
Expand All @@ -388,8 +391,10 @@ - (void) loadThumbnailForObject:(IMBObject*)inObject

else if ([type isEqualToString:IKImageBrowserQTMovieRepresentationType])
{
[super loadThumbnailForObject:inObject];
imageRepresentation = [super loadThumbnailForObject:inObject];
}

return imageRepresentation;
}


Expand Down

0 comments on commit cb36f87

Please sign in to comment.