From e3726ebeb1037a0353844ba80f823a7384960526 Mon Sep 17 00:00:00 2001 From: masakih Date: Sun, 27 Dec 2015 19:03:49 +0900 Subject: [PATCH] =?utf8?q?=E3=83=9E=E3=82=B7=E3=82=99=E3=83=83=E3=82=AF?= =?utf8?q?=E3=83=8A=E3=83=B3=E3=83=8F=E3=82=99=E3=83=BC=E3=82=92=E6=8E=92?= =?utf8?q?=E9=99=A4=E3=80=80=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92?= =?utf8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- KCD/HMScreenshotListWindowController.m | 44 +++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/KCD/HMScreenshotListWindowController.m b/KCD/HMScreenshotListWindowController.m index 4b87c3e3..f9666fac 100644 --- a/KCD/HMScreenshotListWindowController.m +++ b/KCD/HMScreenshotListWindowController.m @@ -391,40 +391,50 @@ if(informations.count == 0) return; - NSInteger col = informations.count == 1 ? 1 : 2; - NSInteger row = informations.count / 2 + informations.count % 2; + // 切り抜き位置とサイズ + const NSPoint origin = {329, 13}; + const NSSize size = {471, 365}; + + NSUInteger imageCount = informations.count; + NSInteger col = imageCount == 1 ? 1 : 2; + NSInteger row = imageCount / 2 + imageCount % 2; dispatch_queue_t queue = dispatch_queue_create("Screenshot queue", DISPATCH_QUEUE_SERIAL); dispatch_async(queue, ^{ NSImage *trimedImage = [[NSImage alloc] initWithSize:NSMakeSize(471 * col, 365 * row)]; - [trimedImage lockFocus]; - { - [[NSColor lightGrayColor] setFill]; - const NSInteger size = 10; - for(NSInteger i = 0; i < (471 * col) / size; i++) { - for(NSInteger j = 0; j < (356 * row) / size; j++) { - if(i % 2 == 0 && j % 2 == 1) continue; - if(i % 2 == 1 && j % 2 == 0) continue; - NSRect rect = NSMakeRect(i * size, j * size, size, size); - NSRectFill(rect); + // 空き枠に市松模様を描画 + if( imageCount % 2 == 1) { + [trimedImage lockFocus]; + { + [[NSColor lightGrayColor] setFill]; + // 市松模様のサイズ + const NSInteger tileSize = 10; + for(NSInteger i = 0; i < (size.width * col) / tileSize; i++) { + for(NSInteger j = 0; j < (size.height * row) / tileSize; j++) { + if(i % 2 == 0 && j % 2 == 1) continue; + if(i % 2 == 1 && j % 2 == 0) continue; + NSRect rect = NSMakeRect(i * tileSize, j * tileSize, tileSize, tileSize); + NSRectFill(rect); + } } } + [trimedImage unlockFocus]; } - [trimedImage unlockFocus]; + // 画像の切り取りと描画 NSEnumerator *reverse = [informations reverseObjectEnumerator]; NSArray *reverseInformations = reverse.allObjects; - for(NSInteger i = 0; i < informations.count; i++) { + for(NSInteger i = 0; i < imageCount; i++) { HMScreenshotInformation *info = reverseInformations[i]; NSImage *originalImage = [[NSImage alloc] initWithContentsOfFile:info.path]; if(!originalImage) continue; - CGFloat x = (i % 2 == 0) ? 0 : 471; - CGFloat y = 365 * row - (i / 2 + 1) * 365; + CGFloat x = (i % 2 == 0) ? 0 : size.width; + CGFloat y = size.height * row - (i / 2 + 1) * size.height; [trimedImage lockFocus]; { [originalImage drawAtPoint:NSMakePoint(x, y) - fromRect:NSMakeRect(329, 13, 471, 365) + fromRect:NSMakeRect(origin.x, origin.y, size.width, size.height) operation:NSCompositeCopy fraction:1.0]; } -- 2.11.0