Re: How to properly display small, high resolution images?
Re: How to properly display small, high resolution images?
- Subject: Re: How to properly display small, high resolution images?
- From: Nik Youdale <email@hidden>
- Date: Sun, 16 Dec 2007 11:05:39 +1100
Perhaps try using core graphics:
CGRect drawingRect;
NSImage *yourImage;
// Get the CGImageRef from the image....
NSBitmapImageRep *rep = (NSBitmapImageRep *)[yourImage
bestRepresentationForDevice: nil]; // is there a better way to get the
nsbitmapimagerep out of an nsimage?
CGImageRef cgImage = [rep CGImage];
// Draw the image
CGContextDrawImage ([[NSGraphicsContext currentContext] graphicsPort],
drawingRect, cgImage);
CoreGraphics automatically scales the image to the specified size
(smoothly).
Cheers
Nik
On 16/12/2007, at 6:33 AM, that guy wrote:
Hey all - I'm trying to display a bunch of very small high
resolution images, and I'm confused. They render perfectly well
(full screen) in Preview or iPhoto, and yet when I do the standard
NSImage* tempImage = [[NSImage alloc]
initWithContentsOfFile:filename];
NSSize newSize;
//snip - just sets the dimensions of newSize properly
NSImage *scaleImage = [[NSImage alloc] initWithSize:newSize];
[scaleImage lockFocus];
[[NSGraphicsContext currentContext]
setImageInterpolation:NSImageInterpolationHigh];
[tempImage drawInRect:NSMakeRect(0, 0, newSize.width,
newSize.height) fromRect:NSZeroRect operation:NSCompositeSourceOver
fraction:1.0];
[scaleImage unlockFocus];
[scaleImage drawInRect:NSMakeRect(screenSize.width/2-newSize.width/
2, screenSize.height/2-newSize.height/2, newSize.width,
newSize.height) fromRect:NSZeroRect operation:NSCompositeSourceOver
fraction:1.0];
, everything ends up horrendously pixellated. The "actual" size of
these images is tiny (like 150x150) and yet, as I said, they render
in full screen perfectly well.
I also tried "NSImageInterpolationNone" on a lark - no luck. Can
anyone give me a hint?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden