X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fwebcollage-helper-cocoa.m;fp=hacks%2Fwebcollage-helper-cocoa.m;h=0a6e9e36be27890cc044bdd5b5b856e0b2102efa;hp=1b5fadfb3daecddedae080d72726b2a02fc52412;hb=d5186197bc394e10a4402f7f6d23fbb14103bc50;hpb=6afd6db0ae9396cd7ff897ade597cd5483f49b0e diff --git a/hacks/webcollage-helper-cocoa.m b/hacks/webcollage-helper-cocoa.m index 1b5fadfb..0a6e9e36 100644 --- a/hacks/webcollage-helper-cocoa.m +++ b/hacks/webcollage-helper-cocoa.m @@ -1,5 +1,5 @@ /* webcollage-helper-cocoa --- scales and pastes one image into another - * xscreensaver, Copyright (c) 2002-2009 Jamie Zawinski + * xscreensaver, Copyright (c) 2002-2014 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -105,7 +105,7 @@ load_image (const char *file) NSImage *image = [[NSImage alloc] initWithContentsOfFile: [NSString stringWithCString: file - encoding: kCFStringEncodingUTF8]]; + encoding: NSUTF8StringEncoding]]; if (! image) image = load_ppm_image (file); @@ -114,6 +114,14 @@ load_image (const char *file) exit (1); } + + // [NSImage size] defaults to the image size in points instead of pixels, + // so if an image file specified "pixels per inch" we can end up with + // absurdly sized images. Set it back to 1:1 pixel:point. + // + NSImageRep *rep = [image.representations firstObject]; + image.size = NSMakeSize (rep.pixelsWide, rep.pixelsHigh); + return image; }