From ecf1978a52d96a424ad4092f7481f767a80eb516 Mon Sep 17 00:00:00 2001 From: BiFive Date: Sat, 1 Oct 2011 15:41:18 +0400 Subject: [PATCH] In case, when height or width is 1 (it is needs for resource, that uses for patern image in UIColor), this dimension don't division by 2, and save value at 1. --- Unretiner.xcodeproj/project.pbxproj | 6 +++--- Unretiner/Classes/Utilities/NSURL+Unretina.m | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Unretiner.xcodeproj/project.pbxproj b/Unretiner.xcodeproj/project.pbxproj index 1bc695b..05fd2ed 100644 --- a/Unretiner.xcodeproj/project.pbxproj +++ b/Unretiner.xcodeproj/project.pbxproj @@ -52,7 +52,7 @@ 1713EFAE13E57A310019EA65 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 1713EFB313E588740019EA65 /* NSDroppableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSDroppableView.h; sourceTree = ""; }; 1713EFB413E588740019EA65 /* NSDroppableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSDroppableView.m; sourceTree = ""; }; - 1713EFB613E58E800019EA65 /* NSBitmapImageRep+Resizing.h */ = {isa = PBXFileReference; fileEncoding = 4; path = "NSBitmapImageRep+Resizing.h"; sourceTree = ""; }; + 1713EFB613E58E800019EA65 /* NSBitmapImageRep+Resizing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSBitmapImageRep+Resizing.h"; sourceTree = ""; }; 1713EFB713E58E800019EA65 /* NSBitmapImageRep+Resizing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSBitmapImageRep+Resizing.m"; sourceTree = ""; }; 17C3A36F13E3FF1600294FBE /* Unretiner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Unretiner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 17C3A37313E3FF1600294FBE /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; @@ -404,9 +404,9 @@ GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.7; + MACOSX_DEPLOYMENT_TARGET = 10.6; ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; + SDKROOT = ""; }; name = Debug; }; diff --git a/Unretiner/Classes/Utilities/NSURL+Unretina.m b/Unretiner/Classes/Utilities/NSURL+Unretina.m index bbd65a6..e5afe46 100644 --- a/Unretiner/Classes/Utilities/NSURL+Unretina.m +++ b/Unretiner/Classes/Utilities/NSURL+Unretina.m @@ -37,15 +37,21 @@ - (BOOL)unretina:(NSURL*)folder errors:(NSMutableArray*)errors warnings:(NSMutab [sourceImage setSize:NSMakeSize([rep pixelsWide], [rep pixelsHigh])]; // Warn if either dimension is odd - if (((int)[sourceImage size].width) % 2 != 0 || ((int)[sourceImage size].height) % 2 != 0) { + if (((((int)[sourceImage size].width) % 2 != 0) && (((int)[sourceImage size].width) != 1)) || + ((((int)[sourceImage size].height) % 2 != 0) && (((int)[sourceImage size].height) != 1))) + { [warnings addObject:[NSString stringWithFormat:@"%@ : has dimensions not divisible by 2", [[self absoluteString] lastPathComponent]]]; } // Determine the image type NSBitmapImageFileType imageType = [self imageType]; if ((int)imageType >= 0) { - // Create a bitmap representation - NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithWidth:[sourceImage size].width / 2.0 andHeight:[sourceImage size].height / 2.0]; + + CGFloat _newWidth = ((((int)[sourceImage size].width) == 1) ? 1 : ([sourceImage size].width / 2.0)); + CGFloat _newHeight = ((((int)[sourceImage size].height) == 1) ? 1 : ([sourceImage size].height / 2.0)); + + // Create a bitmap representation + NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithWidth:_newWidth andHeight:_newHeight]; [imageRep setImage:sourceImage]; // Write out the new image