summaryrefslogtreecommitdiff
path: root/cocoa/thumbnail.m
diff options
context:
space:
mode:
Diffstat (limited to 'cocoa/thumbnail.m')
-rw-r--r--cocoa/thumbnail.m37
1 files changed, 16 insertions, 21 deletions
diff --git a/cocoa/thumbnail.m b/cocoa/thumbnail.m
index 26f1a7a65..0ec66b52a 100644
--- a/cocoa/thumbnail.m
+++ b/cocoa/thumbnail.m
@@ -28,41 +28,36 @@
bool thumbnail_create(struct hlcache_handle *content, struct bitmap *bitmap,
const char *url)
{
+ int bwidth = bitmap_get_width( bitmap );
+ int bheight = bitmap_get_height( bitmap );
CGColorSpaceRef cspace = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB );
CGContextRef bitmapContext = CGBitmapContextCreate( bitmap_get_buffer( bitmap ),
- bitmap_get_width( bitmap ), bitmap_get_height( bitmap ),
+ bwidth, bheight,
bitmap_get_bpp( bitmap ) * 8 / 4,
bitmap_get_rowstride( bitmap ),
cspace, kCGImageAlphaNoneSkipLast );
CGColorSpaceRelease( cspace );
-
size_t width = MIN( content_get_width( content ), 1024 );
- size_t height = MIN( content_get_height( content ), 768 );
-
- struct rect clip;
- clip.x0 = 0;
- clip.y0 = 0;
- clip.x1 = content_get_width( content );
- clip.y1 = content_get_height( content );
-
- CGContextTranslateCTM( bitmapContext, 0, bitmap_get_height( bitmap ) );
- CGContextScaleCTM( bitmapContext, (CGFloat)bitmap_get_width( bitmap ) / width, -(CGFloat)bitmap_get_height( bitmap ) / height );
+ size_t height = ((width * bheight) + bwidth / 2)) / bwidth;
+ CGContextTranslateCTM( bitmapContext, 0, bheight );
+ CGContextScaleCTM( bitmapContext, (CGFloat)bwidth / width, -(CGFloat)bheight / height );
+
[NSGraphicsContext setCurrentContext: [NSGraphicsContext graphicsContextWithGraphicsPort: bitmapContext flipped: YES]];
-
- content_redraw( content, 0, 0, content_get_width( content ), content_get_height( content ),
- &clip,
- 1.0, 0xFFFFFFFF );
-
+
+ /* todo: ??? set plot scale according to the scale the thumbnail will be
+ * rendered at, by calling thumbnail_get_redraw_scale(). ??? */
+
+ thumbnail_redraw( content, width, height );
+
[NSGraphicsContext setCurrentContext: nil];
CGContextRelease( bitmapContext );
-
+
bitmap_modified( bitmap );
-
+
if (NULL != url) urldb_set_thumbnail( url, bitmap );
-
- return true;
+ return true;
}