├── .gitignore ├── English.lproj └── InfoPlist.strings ├── Info.plist ├── QuickLookASE.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── README.md ├── example1.png ├── example2.png └── src ├── DataReader.h ├── DataReader.m ├── GeneratePreviewForURL.m ├── GenerateThumbnailForURL.m ├── SwatchDocument.h ├── SwatchDocument.m └── main.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsodre/QuickLookASE/930d7ccf59a86ecbb42220e676ab80d20c3d3bcc/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDocumentTypes 8 | 9 | 10 | CFBundleTypeRole 11 | QLGenerator 12 | LSItemContentTypes 13 | 14 | dyn.ah62d4rv4ge80c65f 15 | 16 | 17 | 18 | CFBundleExecutable 19 | ${EXECUTABLE_NAME} 20 | CFBundleName 21 | ${PRODUCT_NAME} 22 | CFBundleIconFile 23 | 24 | CFBundleIdentifier 25 | com.studioavante.quicklookase 26 | CFBundleInfoDictionaryVersion 27 | 6.0 28 | CFBundleVersion 29 | 1.0 30 | CFPlugInDynamicRegisterFunction 31 | 32 | CFPlugInDynamicRegistration 33 | NO 34 | CFPlugInFactories 35 | 36 | 660EBE04-BCB7-46E1-B107-88FBB16EE5AF 37 | QuickLookGeneratorPluginFactory 38 | 39 | CFPlugInTypes 40 | 41 | 5E2D9680-5022-40FA-B806-43349622E5B9 42 | 43 | 660EBE04-BCB7-46E1-B107-88FBB16EE5AF 44 | 45 | 46 | CFPlugInUnloadFunction 47 | 48 | QLThumbnailMinimumSize 49 | 17 50 | QLPreviewWidth 51 | 600 52 | QLPreviewHeight 53 | 800 54 | QLSupportsConcurrentRequests 55 | 56 | QLNeedsToBeRunInMainThread 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /QuickLookASE.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 42; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 440BBDE80B0537AC0075B7E5 /* QuickLookASE.qlgenerator in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8D576316048677EA00EA77CD /* QuickLookASE.qlgenerator */; }; 11 | 627414860B4EEC0B0069E3AD /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 627414850B4EEC0B0069E3AD /* ApplicationServices.framework */; }; 12 | 6274148C0B4EED590069E3AD /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6274148B0B4EED590069E3AD /* CoreServices.framework */; }; 13 | 8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8D5B49A704867FD3000E48DA /* InfoPlist.strings */; }; 14 | DBAD62E41D3C63B9005EA523 /* DataReader.h in Headers */ = {isa = PBXBuildFile; fileRef = DBAD62DD1D3C63B9005EA523 /* DataReader.h */; }; 15 | DBAD62E51D3C63B9005EA523 /* DataReader.m in Sources */ = {isa = PBXBuildFile; fileRef = DBAD62DE1D3C63B9005EA523 /* DataReader.m */; }; 16 | DBAD62E61D3C63B9005EA523 /* GeneratePreviewForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = DBAD62DF1D3C63B9005EA523 /* GeneratePreviewForURL.m */; }; 17 | DBAD62E71D3C63B9005EA523 /* GenerateThumbnailForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = DBAD62E01D3C63B9005EA523 /* GenerateThumbnailForURL.m */; }; 18 | DBAD62E81D3C63B9005EA523 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = DBAD62E11D3C63B9005EA523 /* main.c */; }; 19 | DBAD62E91D3C63B9005EA523 /* SwatchDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = DBAD62E21D3C63B9005EA523 /* SwatchDocument.h */; }; 20 | DBAD62EA1D3C63B9005EA523 /* SwatchDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = DBAD62E31D3C63B9005EA523 /* SwatchDocument.m */; }; 21 | F23287A00A761867004F5233 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F232879F0A761867004F5233 /* Cocoa.framework */; }; 22 | F28CFC030A3EC0C6000ABFF5 /* QuickLook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F28CFC020A3EC0C6000ABFF5 /* QuickLook.framework */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXCopyFilesBuildPhase section */ 26 | 440BBDFA0B0537B10075B7E5 /* CopyFiles */ = { 27 | isa = PBXCopyFilesBuildPhase; 28 | buildActionMask = 2147483647; 29 | dstPath = "~/Library/QuickLook"; 30 | dstSubfolderSpec = 0; 31 | files = ( 32 | 440BBDE80B0537AC0075B7E5 /* QuickLookASE.qlgenerator in CopyFiles */, 33 | ); 34 | runOnlyForDeploymentPostprocessing = 0; 35 | }; 36 | /* End PBXCopyFilesBuildPhase section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; 40 | 622150340BBDD60C00126F4B /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 41 | 627414850B4EEC0B0069E3AD /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = ""; }; 42 | 6274148B0B4EED590069E3AD /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = ""; }; 43 | 8D576316048677EA00EA77CD /* QuickLookASE.qlgenerator */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QuickLookASE.qlgenerator; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | DB57D0DB1D0DB18600490A66 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 45 | DBAD62DD1D3C63B9005EA523 /* DataReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DataReader.h; path = src/DataReader.h; sourceTree = ""; }; 46 | DBAD62DE1D3C63B9005EA523 /* DataReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DataReader.m; path = src/DataReader.m; sourceTree = ""; }; 47 | DBAD62DF1D3C63B9005EA523 /* GeneratePreviewForURL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GeneratePreviewForURL.m; path = src/GeneratePreviewForURL.m; sourceTree = ""; }; 48 | DBAD62E01D3C63B9005EA523 /* GenerateThumbnailForURL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GenerateThumbnailForURL.m; path = src/GenerateThumbnailForURL.m; sourceTree = ""; }; 49 | DBAD62E11D3C63B9005EA523 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = main.c; path = src/main.c; sourceTree = ""; }; 50 | DBAD62E21D3C63B9005EA523 /* SwatchDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SwatchDocument.h; path = src/SwatchDocument.h; sourceTree = ""; }; 51 | DBAD62E31D3C63B9005EA523 /* SwatchDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SwatchDocument.m; path = src/SwatchDocument.m; sourceTree = ""; }; 52 | F232879F0A761867004F5233 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 53 | F28CFC020A3EC0C6000ABFF5 /* QuickLook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLook.framework; path = /System/Library/Frameworks/QuickLook.framework; sourceTree = ""; }; 54 | /* End PBXFileReference section */ 55 | 56 | /* Begin PBXFrameworksBuildPhase section */ 57 | 8D576313048677EA00EA77CD /* Frameworks */ = { 58 | isa = PBXFrameworksBuildPhase; 59 | buildActionMask = 2147483647; 60 | files = ( 61 | F28CFC030A3EC0C6000ABFF5 /* QuickLook.framework in Frameworks */, 62 | F23287A00A761867004F5233 /* Cocoa.framework in Frameworks */, 63 | 627414860B4EEC0B0069E3AD /* ApplicationServices.framework in Frameworks */, 64 | 6274148C0B4EED590069E3AD /* CoreServices.framework in Frameworks */, 65 | ); 66 | runOnlyForDeploymentPostprocessing = 0; 67 | }; 68 | /* End PBXFrameworksBuildPhase section */ 69 | 70 | /* Begin PBXGroup section */ 71 | 089C166AFE841209C02AAC07 /* QuickLookSketch */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 08FB77AFFE84173DC02AAC07 /* Quick Look Generator */, 75 | 089C167CFE841241C02AAC07 /* Resources */, 76 | 089C1671FE841209C02AAC07 /* External Frameworks and Libraries */, 77 | 19C28FB6FE9D52B211CA2CBB /* Products */, 78 | ); 79 | name = QuickLookSketch; 80 | sourceTree = ""; 81 | }; 82 | 089C1671FE841209C02AAC07 /* External Frameworks and Libraries */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 6274148B0B4EED590069E3AD /* CoreServices.framework */, 86 | F232879F0A761867004F5233 /* Cocoa.framework */, 87 | F28CFC020A3EC0C6000ABFF5 /* QuickLook.framework */, 88 | 627414850B4EEC0B0069E3AD /* ApplicationServices.framework */, 89 | ); 90 | name = "External Frameworks and Libraries"; 91 | sourceTree = ""; 92 | }; 93 | 089C167CFE841241C02AAC07 /* Resources */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | DB57D0DB1D0DB18600490A66 /* README.md */, 97 | 622150340BBDD60C00126F4B /* Info.plist */, 98 | 8D5B49A704867FD3000E48DA /* InfoPlist.strings */, 99 | ); 100 | name = Resources; 101 | sourceTree = ""; 102 | }; 103 | 08FB77AFFE84173DC02AAC07 /* Quick Look Generator */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | DBAD62E11D3C63B9005EA523 /* main.c */, 107 | DBAD62DF1D3C63B9005EA523 /* GeneratePreviewForURL.m */, 108 | DBAD62E01D3C63B9005EA523 /* GenerateThumbnailForURL.m */, 109 | DBAD62E21D3C63B9005EA523 /* SwatchDocument.h */, 110 | DBAD62E31D3C63B9005EA523 /* SwatchDocument.m */, 111 | DBAD62DD1D3C63B9005EA523 /* DataReader.h */, 112 | DBAD62DE1D3C63B9005EA523 /* DataReader.m */, 113 | ); 114 | name = "Quick Look Generator"; 115 | sourceTree = ""; 116 | }; 117 | 19C28FB6FE9D52B211CA2CBB /* Products */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 8D576316048677EA00EA77CD /* QuickLookASE.qlgenerator */, 121 | ); 122 | name = Products; 123 | sourceTree = ""; 124 | }; 125 | /* End PBXGroup section */ 126 | 127 | /* Begin PBXHeadersBuildPhase section */ 128 | 8D57630E048677EA00EA77CD /* Headers */ = { 129 | isa = PBXHeadersBuildPhase; 130 | buildActionMask = 2147483647; 131 | files = ( 132 | DBAD62E41D3C63B9005EA523 /* DataReader.h in Headers */, 133 | DBAD62E91D3C63B9005EA523 /* SwatchDocument.h in Headers */, 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | /* End PBXHeadersBuildPhase section */ 138 | 139 | /* Begin PBXNativeTarget section */ 140 | 8D57630D048677EA00EA77CD /* QuickLookASE */ = { 141 | isa = PBXNativeTarget; 142 | buildConfigurationList = 2CA3261E0896AD4900168862 /* Build configuration list for PBXNativeTarget "QuickLookASE" */; 143 | buildPhases = ( 144 | 8D57630E048677EA00EA77CD /* Headers */, 145 | 8D57630F048677EA00EA77CD /* Resources */, 146 | 8D576311048677EA00EA77CD /* Sources */, 147 | 8D576313048677EA00EA77CD /* Frameworks */, 148 | 8D576315048677EA00EA77CD /* Rez */, 149 | 440BBDFA0B0537B10075B7E5 /* CopyFiles */, 150 | ); 151 | buildRules = ( 152 | ); 153 | dependencies = ( 154 | ); 155 | name = QuickLookASE; 156 | productInstallPath = /Library/Spotlight; 157 | productName = QuickLookSketch; 158 | productReference = 8D576316048677EA00EA77CD /* QuickLookASE.qlgenerator */; 159 | productType = "com.apple.product-type.bundle"; 160 | }; 161 | /* End PBXNativeTarget section */ 162 | 163 | /* Begin PBXProject section */ 164 | 089C1669FE841209C02AAC07 /* Project object */ = { 165 | isa = PBXProject; 166 | attributes = { 167 | }; 168 | buildConfigurationList = 2CA326220896AD4900168862 /* Build configuration list for PBXProject "QuickLookASE" */; 169 | compatibilityVersion = "Xcode 2.4"; 170 | developmentRegion = English; 171 | hasScannedForEncodings = 1; 172 | knownRegions = ( 173 | en, 174 | ); 175 | mainGroup = 089C166AFE841209C02AAC07 /* QuickLookSketch */; 176 | projectDirPath = ""; 177 | projectRoot = ""; 178 | targets = ( 179 | 8D57630D048677EA00EA77CD /* QuickLookASE */, 180 | ); 181 | }; 182 | /* End PBXProject section */ 183 | 184 | /* Begin PBXResourcesBuildPhase section */ 185 | 8D57630F048677EA00EA77CD /* Resources */ = { 186 | isa = PBXResourcesBuildPhase; 187 | buildActionMask = 2147483647; 188 | files = ( 189 | 8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */, 190 | ); 191 | runOnlyForDeploymentPostprocessing = 0; 192 | }; 193 | /* End PBXResourcesBuildPhase section */ 194 | 195 | /* Begin PBXRezBuildPhase section */ 196 | 8D576315048677EA00EA77CD /* Rez */ = { 197 | isa = PBXRezBuildPhase; 198 | buildActionMask = 2147483647; 199 | files = ( 200 | ); 201 | runOnlyForDeploymentPostprocessing = 0; 202 | }; 203 | /* End PBXRezBuildPhase section */ 204 | 205 | /* Begin PBXSourcesBuildPhase section */ 206 | 8D576311048677EA00EA77CD /* Sources */ = { 207 | isa = PBXSourcesBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | DBAD62E51D3C63B9005EA523 /* DataReader.m in Sources */, 211 | DBAD62E81D3C63B9005EA523 /* main.c in Sources */, 212 | DBAD62E71D3C63B9005EA523 /* GenerateThumbnailForURL.m in Sources */, 213 | DBAD62EA1D3C63B9005EA523 /* SwatchDocument.m in Sources */, 214 | DBAD62E61D3C63B9005EA523 /* GeneratePreviewForURL.m in Sources */, 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | }; 218 | /* End PBXSourcesBuildPhase section */ 219 | 220 | /* Begin PBXVariantGroup section */ 221 | 8D5B49A704867FD3000E48DA /* InfoPlist.strings */ = { 222 | isa = PBXVariantGroup; 223 | children = ( 224 | 089C167EFE841241C02AAC07 /* English */, 225 | ); 226 | name = InfoPlist.strings; 227 | sourceTree = ""; 228 | }; 229 | /* End PBXVariantGroup section */ 230 | 231 | /* Begin XCBuildConfiguration section */ 232 | 2CA3261F0896AD4900168862 /* Debug */ = { 233 | isa = XCBuildConfiguration; 234 | buildSettings = { 235 | COPY_PHASE_STRIP = NO; 236 | FRAMEWORK_SEARCH_PATHS = ( 237 | "$(inherited)", 238 | "$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)", 239 | ); 240 | FRAMEWORK_SEARCH_PATHS_QUOTED_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks\""; 241 | GCC_DYNAMIC_NO_PIC = NO; 242 | GCC_ENABLE_FIX_AND_CONTINUE = YES; 243 | GCC_MODEL_TUNING = G5; 244 | GCC_OPTIMIZATION_LEVEL = 0; 245 | GCC_PRECOMPILE_PREFIX_HEADER = NO; 246 | INFOPLIST_FILE = Info.plist; 247 | INSTALL_PATH = /Library/QuickLook; 248 | LIBRARY_STYLE = Bundle; 249 | PRODUCT_NAME = QuickLookASE; 250 | WRAPPER_EXTENSION = qlgenerator; 251 | ZERO_LINK = YES; 252 | }; 253 | name = Debug; 254 | }; 255 | 2CA326200896AD4900168862 /* Release */ = { 256 | isa = XCBuildConfiguration; 257 | buildSettings = { 258 | FRAMEWORK_SEARCH_PATHS = ( 259 | "$(inherited)", 260 | "$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)", 261 | ); 262 | FRAMEWORK_SEARCH_PATHS_QUOTED_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks\""; 263 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO; 264 | GCC_MODEL_TUNING = G5; 265 | GCC_PRECOMPILE_PREFIX_HEADER = NO; 266 | INFOPLIST_FILE = Info.plist; 267 | INSTALL_PATH = /Library/QuickLook; 268 | LIBRARY_STYLE = Bundle; 269 | PRODUCT_NAME = QuickLookASE; 270 | WRAPPER_EXTENSION = qlgenerator; 271 | }; 272 | name = Release; 273 | }; 274 | 2CA326230896AD4900168862 /* Debug */ = { 275 | isa = XCBuildConfiguration; 276 | buildSettings = { 277 | GCC_C_LANGUAGE_STANDARD = c99; 278 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 279 | GCC_WARN_UNUSED_VARIABLE = YES; 280 | MACOSX_DEPLOYMENT_TARGET = 10.6; 281 | PREBINDING = NO; 282 | }; 283 | name = Debug; 284 | }; 285 | 2CA326240896AD4900168862 /* Release */ = { 286 | isa = XCBuildConfiguration; 287 | buildSettings = { 288 | GCC_C_LANGUAGE_STANDARD = c99; 289 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 290 | GCC_WARN_UNUSED_VARIABLE = YES; 291 | MACOSX_DEPLOYMENT_TARGET = 10.6; 292 | PREBINDING = NO; 293 | }; 294 | name = Release; 295 | }; 296 | /* End XCBuildConfiguration section */ 297 | 298 | /* Begin XCConfigurationList section */ 299 | 2CA3261E0896AD4900168862 /* Build configuration list for PBXNativeTarget "QuickLookASE" */ = { 300 | isa = XCConfigurationList; 301 | buildConfigurations = ( 302 | 2CA3261F0896AD4900168862 /* Debug */, 303 | 2CA326200896AD4900168862 /* Release */, 304 | ); 305 | defaultConfigurationIsVisible = 0; 306 | defaultConfigurationName = Release; 307 | }; 308 | 2CA326220896AD4900168862 /* Build configuration list for PBXProject "QuickLookASE" */ = { 309 | isa = XCConfigurationList; 310 | buildConfigurations = ( 311 | 2CA326230896AD4900168862 /* Debug */, 312 | 2CA326240896AD4900168862 /* Release */, 313 | ); 314 | defaultConfigurationIsVisible = 0; 315 | defaultConfigurationName = Release; 316 | }; 317 | /* End XCConfigurationList section */ 318 | }; 319 | rootObject = 089C1669FE841209C02AAC07 /* Project object */; 320 | } 321 | -------------------------------------------------------------------------------- /QuickLookASE.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QuickLookASE 2 | 3 | Mac QuickLook for ASE files (Adobe Swatch Exchange) 4 | 5 | ASE are color palettes that can be exported from Adobe Photoshop, Adobe Illustrator, [Adobe Color CC](https://color.adobe.com/), [Spectrum](http://www.eigenlogik.com/spectrum/mac), [COLOURlovers](http://www.colourlovers.com/), [Prisma](http://www.codeadventure.com/), among many others. 6 | 7 | Based on Apple's [QuickLookSketch](https://developer.apple.com/library/prerelease/content/samplecode/QuickLookSketch/Introduction/Intro.html). 8 | 9 | ASE format Reference: 10 | 11 | # Installation 12 | 13 | If you want to skip compilation and just install it, [download Release 1.0](https://github.com/rsodre/QuickLookASE/releases), unzip and copy `QuickLookASE.qlgenerator` to `~/Library/QuickLook/`. To reach that folder in Finder, go to your Home, click on the Go menu on the top bar, hold the Option key and `Library` will magically appear. 14 | 15 | Or copy it from a terminal: 16 | 17 |
18 | cp -R QuickLookASE.qlgenerator ~/Library/QuickLook/
19 | 
20 | 21 | Alternatively, if you use [Homebrew-Cask](https://github.com/caskroom/homebrew-cask), install with: 22 | 23 |
24 | brew cask install quicklookase
25 | 
26 | 27 | # Notes 28 | 29 | How to find the UTI of a file: 30 | 31 |
32 | mdls -name kMDItemContentType MySwatch.ase
33 | 
34 | 35 | 36 | # How It Looks: 37 | 38 | ![](https://raw.githubusercontent.com/rsodre/QuickLookASE/master/example1.png) 39 | 40 | ![](https://raw.githubusercontent.com/rsodre/QuickLookASE/master/example2.png) 41 | 42 | -------------------------------------------------------------------------------- /example1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsodre/QuickLookASE/930d7ccf59a86ecbb42220e676ab80d20c3d3bcc/example1.png -------------------------------------------------------------------------------- /example2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsodre/QuickLookASE/930d7ccf59a86ecbb42220e676ab80d20c3d3bcc/example2.png -------------------------------------------------------------------------------- /src/DataReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | File: SKTDrawDocument.h 4 | 5 | Abstract: Part of the Sketch Sample Code 6 | 7 | Version: 1.0 8 | 9 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 10 | Computer, Inc. ("Apple") in consideration of your agreement to the 11 | following terms, and your use, installation, modification or 12 | redistribution of this Apple software constitutes acceptance of these 13 | terms. If you do not agree with these terms, please do not use, 14 | install, modify or redistribute this Apple software. 15 | 16 | In consideration of your agreement to abide by the following terms, and 17 | subject to these terms, Apple grants you a personal, non-exclusive 18 | license, under Apple's copyrights in this original Apple software (the 19 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 20 | Software, with or without modifications, in source and/or binary forms; 21 | provided that if you redistribute the Apple Software in its entirety and 22 | without modifications, you must retain this notice and the following 23 | text and disclaimers in all such redistributions of the Apple Software. 24 | Neither the name, trademarks, service marks or logos of Apple Computer, 25 | Inc. may be used to endorse or promote products derived from the Apple 26 | Software without specific prior written permission from Apple. Except 27 | as expressly stated in this notice, no other rights or licenses, express 28 | or implied, are granted by Apple herein, including but not limited to 29 | any patent rights that may be infringed by your derivative works or by 30 | other works in which the Apple Software may be incorporated. 31 | 32 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 33 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 34 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 35 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 36 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 37 | 38 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 39 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 40 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 41 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 42 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 43 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 44 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 45 | POSSIBILITY OF SUCH DAMAGE. 46 | 47 | Copyright (C) 2007 Apple Inc. All Rights Reserved. 48 | 49 | */ 50 | 51 | #import 52 | 53 | @interface DataReader : NSObject { 54 | @private 55 | 56 | NSData * _fileData; 57 | unsigned char * _buffer; 58 | int _length; 59 | int _position; 60 | 61 | } 62 | 63 | - (int)remaining; 64 | - (int)length; 65 | 66 | - (BOOL)readFromURL:(NSURL *)url; 67 | //- (unsigned char *)GetChunk:(int)size; 68 | - (unsigned char *)GetBytes:(int)size; 69 | - (NSString*)GetString:(int)size; 70 | - (int)GetInt; 71 | - (int)GetIntOfSize:(int)size; 72 | - (float)GetFloat; 73 | - (float)GetFloatOfSize:(int)size; 74 | 75 | @end 76 | -------------------------------------------------------------------------------- /src/DataReader.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | File: SwatchDocument.m 4 | 5 | Abstract: Part of the Sketch Sample Code 6 | 7 | Version: 1.0 8 | 9 | Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple 10 | Computer, Inc. ("Apple") in consideration of your agreement to the 11 | following terms, and your use, installation, modification or 12 | redistribution of this Apple software constitutes acceptance of these 13 | terms. If you do not agree with these terms, please do not use, 14 | install, modify or redistribute this Apple software. 15 | 16 | In consideration of your agreement to abide by the following terms, and 17 | subject to these terms, Apple grants you a personal, non-exclusive 18 | license, under Apple's copyrights in this original Apple software (the 19 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 20 | Software, with or without modifications, in source and/or binary forms; 21 | provided that if you redistribute the Apple Software in its entirety and 22 | without modifications, you must retain this notice and the following 23 | text and disclaimers in all such redistributions of the Apple Software. 24 | Neither the name, trademarks, service marks or logos of Apple Computer, 25 | Inc. may be used to endorse or promote products derived from the Apple 26 | Software without specific prior written permission from Apple. Except 27 | as expressly stated in this notice, no other rights or licenses, express 28 | or implied, are granted by Apple herein, including but not limited to 29 | any patent rights that may be infringed by your derivative works or by 30 | other works in which the Apple Software may be incorporated. 31 | 32 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 33 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 34 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 35 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 36 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 37 | 38 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 39 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 40 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 41 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 42 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 43 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 44 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 45 | POSSIBILITY OF SUCH DAMAGE. 46 | 47 | Copyright (C) 2007 Apple Inc. All Rights Reserved. 48 | 49 | */ 50 | 51 | 52 | #import 53 | #import "DataReader.h" 54 | 55 | @implementation DataReader 56 | 57 | - (BOOL)readFromURL:(NSURL *)url { 58 | 59 | _fileData = [[NSData alloc] initWithContentsOfURL:(NSURL*)url]; 60 | if (_fileData == NULL) 61 | return false; 62 | 63 | _buffer = (unsigned char*)[_fileData bytes]; 64 | _length = [_fileData length]; 65 | _position = 0; 66 | 67 | return true; 68 | } 69 | 70 | - (int)length { 71 | return _length; 72 | } 73 | 74 | - (int)remaining { 75 | return (_length - _position); 76 | } 77 | 78 | - (unsigned char *)GetChunk:(int)size 79 | { 80 | if (size <= 0 || size > [self remaining]) 81 | return NULL; 82 | unsigned char * chunk = &(_buffer[_position]); 83 | _position += size; 84 | return chunk; 85 | } 86 | - (unsigned char *)GetBytes:(int)size 87 | { 88 | unsigned char * chunk = [self GetChunk:size]; 89 | if (chunk == NULL) 90 | { 91 | NSLog(@"SwatchPalette.Reader.GetBytes(): Invalid chunk size [%d] remaining [%d]",size,[self remaining]); 92 | return NULL; 93 | } 94 | return chunk; 95 | } 96 | - (NSString*)GetString:(int)size 97 | { 98 | unsigned char * chunk = [self GetChunk:size]; 99 | if (chunk == NULL) 100 | { 101 | NSLog(@"SwatchPalette.Reader.GetString(): Invalid chunk size [%d] remaining [%d]",size,[self remaining]); 102 | return NULL; 103 | } 104 | NSString *s = [[NSString alloc] initWithBytes:chunk 105 | length:size 106 | encoding:NSUTF8StringEncoding]; 107 | return s; 108 | } 109 | - (int)GetInt 110 | { 111 | return [self GetIntOfSize:4]; 112 | } 113 | - (int)GetIntOfSize:(int)size 114 | { 115 | if (size > 4) 116 | { 117 | NSLog(@"SwatchPalette.Reader.GetInt(): Invalid int size [%d], expecting <= 4",size); 118 | return -1; 119 | } 120 | unsigned char * chunk = [self GetChunk:size]; 121 | if (chunk == NULL) 122 | { 123 | NSLog(@"SwatchPalette.Reader.GetInt(): Invalid chunk size [%d] remaining [%d]",size,[self remaining]); 124 | return -1; 125 | } 126 | unsigned int res; 127 | NSString *hex = [self ChunkToHex:chunk size:size]; 128 | NSScanner* scanner = [NSScanner scannerWithString:hex]; 129 | [scanner scanHexInt:&res]; 130 | return (int)res; 131 | } 132 | - (float)GetFloat 133 | { 134 | return [self GetFloatOfSize:4]; 135 | } 136 | - (float)GetFloatOfSize:(int)size 137 | { 138 | if (size > 4) 139 | { 140 | NSLog(@"SwatchPalette.Reader.GetFloat(): Invalid int size [%d], expecting <= 4",size); 141 | return -1; 142 | } 143 | unsigned char * chunk = [self GetChunk:size]; 144 | if (chunk == NULL) 145 | { 146 | NSLog(@"SwatchPalette.Reader.GetFloat(): Invalid chunk size [%d] remaining [%d]",size,[self remaining]); 147 | return -1; 148 | } 149 | union { 150 | float f; 151 | unsigned int i; 152 | } res; 153 | NSString *hex = [self ChunkToHex:chunk size:size]; 154 | NSScanner* scanner = [NSScanner scannerWithString:hex]; 155 | [scanner scanHexInt:&res.i]; 156 | return res.f; 157 | } 158 | 159 | - (NSString*) ChunkToHex:(unsigned char *)chunk size:(int)size 160 | { 161 | NSMutableString * result = [[NSMutableString alloc] init]; 162 | for (int i=0; i 51 | #include 52 | #include 53 | #import 54 | #import "SwatchDocument.h" 55 | 56 | 57 | /* ----------------------------------------------------------------------------- 58 | Generate a preview for file 59 | 60 | This function's job is to create preview for designated file 61 | ----------------------------------------------------------------------------- */ 62 | 63 | OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options) 64 | { 65 | NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 66 | 67 | SwatchDocument* document = [[SwatchDocument alloc] init]; 68 | 69 | if(![document readFromURL:(NSURL *)url]) { 70 | [document release]; 71 | [pool release]; 72 | return noErr; 73 | } 74 | 75 | NSSize canvasSize = [document canvasSize]; 76 | 77 | // Preview will be drawn in a vectorized context 78 | // Here we create a graphics context to draw the Quick Look Preview in 79 | CGContextRef cgContext = QLPreviewRequestCreateContext(preview, *(CGSize *)&canvasSize, false, NULL); 80 | if(cgContext) { 81 | NSGraphicsContext* context = [NSGraphicsContext graphicsContextWithGraphicsPort:(void *)cgContext flipped:YES]; 82 | if(context) { 83 | //These two lines of code are just good safe programming... 84 | [NSGraphicsContext saveGraphicsState]; 85 | [NSGraphicsContext setCurrentContext:context]; 86 | 87 | [document drawDocumentInContext:context]; 88 | 89 | //This line sets the context back to what it was when we're done 90 | [NSGraphicsContext restoreGraphicsState]; 91 | } 92 | 93 | // When we are done with our drawing code QLPreviewRequestFlushContext() is called to flush the context 94 | QLPreviewRequestFlushContext(preview, cgContext); 95 | 96 | CFRelease(cgContext); 97 | } 98 | 99 | [pool release]; 100 | return noErr; 101 | } 102 | 103 | void CancelPreviewGeneration(void* thisInterface, QLPreviewRequestRef preview) 104 | { 105 | // implement only if supported 106 | } 107 | 108 | -------------------------------------------------------------------------------- /src/GenerateThumbnailForURL.m: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | File: GenerateThumbnailForURL.m 4 | 5 | Abstract: This is the code to generate Quick Look thumbnails for Sketch documents 6 | 7 | Version: 1.0 8 | 9 | Disclaimer: IMPORTANT: This Apple software is supplied to you by 10 | Apple Inc. ("Apple") in consideration of your agreement to the 11 | following terms, and your use, installation, modification or 12 | redistribution of this Apple software constitutes acceptance of these 13 | terms. If you do not agree with these terms, please do not use, 14 | install, modify or redistribute this Apple software. 15 | 16 | In consideration of your agreement to abide by the following terms, and 17 | subject to these terms, Apple grants you a personal, non-exclusive 18 | license, under Apple's copyrights in this original Apple software (the 19 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 20 | Software, with or without modifications, in source and/or binary forms; 21 | provided that if you redistribute the Apple Software in its entirety and 22 | without modifications, you must retain this notice and the following 23 | text and disclaimers in all such redistributions of the Apple Software. 24 | Neither the name, trademarks, service marks or logos of Apple Inc. 25 | may be used to endorse or promote products derived from the Apple 26 | Software without specific prior written permission from Apple. Except 27 | as expressly stated in this notice, no other rights or licenses, express 28 | or implied, are granted by Apple herein, including but not limited to 29 | any patent rights that may be infringed by your derivative works or by 30 | other works in which the Apple Software may be incorporated. 31 | 32 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 33 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 34 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 35 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 36 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 37 | 38 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 39 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 40 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 41 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 42 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 43 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 44 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 45 | POSSIBILITY OF SUCH DAMAGE. 46 | 47 | Copyright (C) 2009 Apple Inc. All Rights Reserved. 48 | */ 49 | 50 | #include 51 | #include 52 | #include 53 | #import 54 | #import "SwatchDocument.h" 55 | 56 | OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize) 57 | { 58 | NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; 59 | 60 | SwatchDocument* document = [[SwatchDocument alloc] init]; 61 | 62 | if(![document readFromURL:(NSURL *)url]) { 63 | [document release]; 64 | [pool release]; 65 | return noErr; 66 | } 67 | 68 | NSSize canvasSize = [document canvasSize]; 69 | 70 | // Thumbnail will be drawn with maximum resolution for desired thumbnail request 71 | // Here we create a graphics context to draw the Quick Look Thumbnail in. 72 | CGContextRef cgContext = QLThumbnailRequestCreateContext(thumbnail, *(CGSize *)&canvasSize, false, NULL); 73 | if(cgContext) { 74 | NSGraphicsContext* context = [NSGraphicsContext graphicsContextWithGraphicsPort:(void *)cgContext flipped:YES]; 75 | if(context) { 76 | //These two lines of code are just good safe programming... 77 | [NSGraphicsContext saveGraphicsState]; 78 | [NSGraphicsContext setCurrentContext:context]; 79 | 80 | //Normally you'd want to do something much more lightweight for a thumbnail, 81 | //like load an pre-generated image embedded in the document or something 82 | //but for a quick and dirty sample, we'll just render the document here 83 | [document drawDocumentInContext:context]; 84 | 85 | //This line sets the context back to what it was when we're done 86 | [NSGraphicsContext restoreGraphicsState]; 87 | } 88 | 89 | // When we are done with our drawing code QLThumbnailRequestFlushContext() is called to flush the context 90 | QLThumbnailRequestFlushContext(thumbnail, cgContext); 91 | 92 | CFRelease(cgContext); 93 | } 94 | 95 | [pool release]; 96 | return noErr; 97 | } 98 | 99 | void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail) 100 | { 101 | // implement only if supported 102 | } 103 | 104 | -------------------------------------------------------------------------------- /src/SwatchDocument.h: -------------------------------------------------------------------------------- 1 | // 2 | // File: SwatchDocument.h 3 | // Version: 1.0 4 | // 5 | 6 | #import 7 | 8 | @interface SwatchDocument : NSObject { 9 | @private 10 | 11 | NSMutableArray *colors; 12 | 13 | } 14 | 15 | // Return the current value of the property. 16 | - (NSSize)canvasSize; 17 | 18 | // Added for Quick Look generator 19 | - (void)drawDocumentInContext:(NSGraphicsContext *)context; 20 | - (BOOL)readFromURL:(NSURL *)url; 21 | 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /src/SwatchDocument.m: -------------------------------------------------------------------------------- 1 | // 2 | // File: SwatchDocument.m 3 | // Version: 1.0 4 | // 5 | 6 | #import 7 | #import "SwatchDocument.h" 8 | #import "DataReader.h" 9 | 10 | #define HEIGHT 600 11 | #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) 12 | 13 | const int BLOCK_GROUP_START = 0xc001; 14 | const int BLOCK_GROUP_END = 0xc002; 15 | const int BLOCK_COLOR = 0x0001; 16 | 17 | enum ColorMode 18 | { 19 | ColorModeUndefined = -1, 20 | ColorModeCMYK, 21 | ColorModeRGB, 22 | ColorModeLAB, 23 | ColorModeGray 24 | }; 25 | 26 | enum ColorType 27 | { 28 | ColorTypeUndefined = -1, 29 | ColorTypeGlobal, 30 | ColorTypeSpot, 31 | ColorTypeNormal 32 | }; 33 | 34 | struct SwatchColor 35 | { 36 | NSString * name; 37 | NSString * group; 38 | enum ColorMode mode; 39 | enum ColorType type; 40 | NSColor * color; 41 | float rawValues[4]; 42 | int rawValuesCount; 43 | }; 44 | 45 | @implementation SwatchDocument 46 | 47 | - (BOOL)readFromURL:(NSURL *)url { 48 | // [self redirectConsoleLogToDocumentFolder]; 49 | 50 | // Create colors array 51 | colors = [[NSMutableArray alloc]init]; 52 | 53 | // Open data reader 54 | DataReader* reader = [[DataReader alloc] init]; 55 | [reader readFromURL:url]; 56 | NSLog(@"SwatchPalette: File size [%d]",[reader length]); 57 | if ([reader length] < 12) 58 | { 59 | NSLog(@"SwatchPalette: Invalid asset size [%d]",[reader length]); 60 | return false; 61 | } 62 | 63 | // Get Header 64 | NSString * signature = [reader GetString:4]; 65 | int v1 = [reader GetIntOfSize:2]; 66 | int v2 = [reader GetIntOfSize:2]; 67 | NSLog(@"SwatchPalette: signature [%@] version [%d.%d]",signature,v1,v2); 68 | if (![signature isEqualToString:@"ASEF"]) 69 | { 70 | NSLog(@"SwatchPalette: Wrong signature [%@]. Must be [ASEF].",signature); 71 | return false; 72 | } 73 | 74 | // Get blocks 75 | NSString * groupName = @""; 76 | int blockCount = [reader GetInt]; 77 | NSLog(@"SwatchPalette: Block count [%d]",blockCount); 78 | for (int b = 0 ; b < blockCount ; b++) 79 | { 80 | int type = [reader GetIntOfSize:2]; 81 | int blockSize = [reader GetInt]; 82 | NSLog(@"SwatchPalette: Block [%d] type [%d] size [%d]",b,type,blockSize); 83 | 84 | struct SwatchColor color; 85 | 86 | // Color 87 | if (type == BLOCK_GROUP_START || type == BLOCK_COLOR) 88 | { 89 | // Group/Colro name 90 | int nameSize = [reader GetIntOfSize:2]; 91 | NSLog(@"SwatchPalette: nameSize [%d]",nameSize); 92 | if (nameSize > 0) 93 | { 94 | // 0-terminated string of length (uint16) double-byte characters 95 | unsigned char * bs = [reader GetBytes:nameSize*2]; 96 | color.name = @""; 97 | for (int i = 0 ; i < nameSize-1 ; i++) 98 | { 99 | NSString *ch = [NSString stringWithFormat:@"%c", bs[(i*2)+1]]; 100 | color.name = [color.name stringByAppendingString:ch]; 101 | } 102 | NSLog(@"SwatchPalette: Name (%d) [%@]",nameSize,color.name); 103 | } 104 | 105 | if (type == BLOCK_GROUP_START) 106 | { 107 | groupName = color.name; 108 | NSLog(@"SwatchPalette: Group Start [%@]",groupName); 109 | } 110 | else //if (type == BLOCK_COLOR) 111 | { 112 | color.group = groupName; 113 | 114 | NSString * colorMode = [reader GetString:4]; 115 | NSLog(@"SwatchPalette: Color mode [%@]",colorMode); 116 | if ([colorMode isEqualToString:@"CMYK"]) 117 | { 118 | color.mode = ColorModeCMYK; 119 | color.rawValuesCount = 4; 120 | float C = color.rawValues[0] = [reader GetFloat]; 121 | float M = color.rawValues[1] = [reader GetFloat]; 122 | float Y = color.rawValues[2] = [reader GetFloat]; 123 | float K = color.rawValues[3] = [reader GetFloat]; 124 | float R = (1-C) * (1-K); 125 | float G = (1-M) * (1-K); 126 | float B = (1-Y) * (1-K); 127 | color.color = [NSColor colorWithRed:R green:G blue:B alpha:1]; 128 | [colors addObject:color.color]; 129 | // palette.Add(color); 130 | } 131 | else if ([colorMode isEqualToString:@"RGB "]) 132 | { 133 | color.mode = ColorModeRGB; 134 | color.rawValuesCount = 3; 135 | float R = color.rawValues[0] = [reader GetFloat]; 136 | float G = color.rawValues[1] = [reader GetFloat]; 137 | float B = color.rawValues[2] = [reader GetFloat]; 138 | color.color = [NSColor colorWithRed:R green:G blue:B alpha:1]; 139 | [colors addObject:color.color]; 140 | // palette.Add(color); 141 | } 142 | 143 | else if ([colorMode isEqualToString:@"LAB "]) 144 | { 145 | color.mode = ColorModeLAB; 146 | color.rawValuesCount = 3; 147 | float L = color.rawValues[0] = [reader GetFloat]; 148 | float A = color.rawValues[1] = [reader GetFloat]; 149 | float B = color.rawValues[2] = [reader GetFloat]; 150 | // color.color = [NSColor colorWithRed:R green:G blue:B alpha:1]; 151 | // [colors addObject:color.color]; 152 | // palette.Add(color); 153 | // No idea what LAB is !!! 154 | NSLog(@"SwatchPalette: LAB color not supportted (%.3f,%.3f,%.3f)",L,A,B); 155 | } 156 | else if ([colorMode isEqualToString:@"Gray"]) 157 | { 158 | color.mode = ColorModeGray; 159 | color.rawValuesCount = 1; 160 | float G = color.rawValues[0] = [reader GetFloat]; 161 | color.color = [NSColor colorWithWhite:G alpha:1]; 162 | [colors addObject:color.color]; 163 | // palette.Add(color); 164 | } 165 | 166 | // Color type 167 | color.type = [reader GetIntOfSize:2]; 168 | } 169 | } 170 | else if (type == BLOCK_GROUP_END) 171 | { 172 | NSLog(@"SwatchPalette: Group End"); 173 | } 174 | else 175 | { 176 | NSLog(@"SwatchPalette: Invalid type [%d]",type); 177 | } 178 | } 179 | 180 | return ([colors count] > 0); 181 | } 182 | 183 | - (void) dealloc 184 | { 185 | if (colors) 186 | [colors dealloc]; 187 | [super dealloc]; 188 | } 189 | 190 | 191 | - (NSSize)canvasSize { 192 | NSSize size = { CLAMP(colors.count, 2, 4)*(HEIGHT/2), HEIGHT }; 193 | return size; 194 | } 195 | 196 | 197 | // Added for Quick Look generator 198 | - (void)drawDocumentInContext:(NSGraphicsContext *)context 199 | { 200 | // Init 201 | [NSGraphicsContext saveGraphicsState]; 202 | [NSGraphicsContext setCurrentContext:context]; 203 | [context saveGraphicsState]; 204 | 205 | // Draw! 206 | { 207 | NSSize size = [self canvasSize]; 208 | 209 | int w = size.width / colors.count; 210 | for (int i = 0 ; i < colors.count ; ++i) 211 | { 212 | [colors[i] setFill]; 213 | NSRect aRect = NSMakeRect(w*i, 0.0, w, size.height); 214 | NSRectFill(aRect); 215 | } 216 | } 217 | 218 | // Finalize 219 | [context restoreGraphicsState]; 220 | [NSGraphicsContext restoreGraphicsState]; 221 | } 222 | 223 | - (void) redirectConsoleLogToDocumentFolder 224 | { 225 | NSString *logPath = [NSHomeDirectory() stringByAppendingPathComponent:@"console.txt"]; 226 | freopen([logPath fileSystemRepresentation],"a+",stderr); 227 | } 228 | 229 | 230 | @end 231 | 232 | 233 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | File: main.c 4 | 5 | Abstract: This is the CFPlug-in boilerplate code for a Quick Look preview generator 6 | 7 | Version: 1.0 8 | 9 | Disclaimer: IMPORTANT: This Apple software is supplied to you by 10 | Apple Inc. ("Apple") in consideration of your agreement to the 11 | following terms, and your use, installation, modification or 12 | redistribution of this Apple software constitutes acceptance of these 13 | terms. If you do not agree with these terms, please do not use, 14 | install, modify or redistribute this Apple software. 15 | 16 | In consideration of your agreement to abide by the following terms, and 17 | subject to these terms, Apple grants you a personal, non-exclusive 18 | license, under Apple's copyrights in this original Apple software (the 19 | "Apple Software"), to use, reproduce, modify and redistribute the Apple 20 | Software, with or without modifications, in source and/or binary forms; 21 | provided that if you redistribute the Apple Software in its entirety and 22 | without modifications, you must retain this notice and the following 23 | text and disclaimers in all such redistributions of the Apple Software. 24 | Neither the name, trademarks, service marks or logos of Apple Inc. 25 | may be used to endorse or promote products derived from the Apple 26 | Software without specific prior written permission from Apple. Except 27 | as expressly stated in this notice, no other rights or licenses, express 28 | or implied, are granted by Apple herein, including but not limited to 29 | any patent rights that may be infringed by your derivative works or by 30 | other works in which the Apple Software may be incorporated. 31 | 32 | The Apple Software is provided by Apple on an "AS IS" basis. APPLE 33 | MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION 34 | THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS 35 | FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND 36 | OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. 37 | 38 | IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL 39 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 40 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 41 | INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, 42 | MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED 43 | AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), 44 | STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE 45 | POSSIBILITY OF SUCH DAMAGE. 46 | 47 | Copyright (C) 2007 Apple Inc. All Rights Reserved. 48 | */ 49 | 50 | //============================================================================== 51 | // 52 | // DO NO MODIFY THE CONTENT OF THIS FILE 53 | // 54 | // This file contains the generic CFPlug-in code necessary for your generator 55 | // To complete your generator implement the function in GenerateThumbnailForURL/GeneratePreviewForURL.c 56 | // 57 | //============================================================================== 58 | 59 | 60 | 61 | 62 | 63 | 64 | #include 65 | #include 66 | #include 67 | #include 68 | 69 | // ----------------------------------------------------------------------------- 70 | // constants 71 | // ----------------------------------------------------------------------------- 72 | 73 | // Don't modify this line 74 | #define PLUGIN_ID "660EBE04-BCB7-46E1-B107-88FBB16EE5AF" 75 | 76 | // 77 | // Below is the generic glue code for all plug-ins. 78 | // 79 | // You should not have to modify this code aside from changing 80 | // names if you decide to change the names defined in the Info.plist 81 | // 82 | 83 | 84 | // ----------------------------------------------------------------------------- 85 | // typedefs 86 | // ----------------------------------------------------------------------------- 87 | 88 | // The thumbnail generation function to be implemented in GenerateThumbnailForURL.c 89 | OSStatus GenerateThumbnailForURL(void *thisInterface, QLThumbnailRequestRef thumbnail, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options, CGSize maxSize); 90 | void CancelThumbnailGeneration(void* thisInterface, QLThumbnailRequestRef thumbnail); 91 | 92 | // The preview generation function to be implemented in GeneratePreviewForURL.c 93 | OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options); 94 | void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview); 95 | 96 | // The layout for an instance of QuickLookGeneratorPlugIn 97 | typedef struct __QuickLookGeneratorPluginType 98 | { 99 | void *conduitInterface; 100 | CFUUIDRef factoryID; 101 | UInt32 refCount; 102 | } QuickLookGeneratorPluginType; 103 | 104 | // ----------------------------------------------------------------------------- 105 | // prototypes 106 | // ----------------------------------------------------------------------------- 107 | // Forward declaration for the IUnknown implementation. 108 | // 109 | 110 | QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID); 111 | void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance); 112 | HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv); 113 | void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID); 114 | ULONG QuickLookGeneratorPluginAddRef(void *thisInstance); 115 | ULONG QuickLookGeneratorPluginRelease(void *thisInstance); 116 | 117 | // ----------------------------------------------------------------------------- 118 | // myInterfaceFtbl definition 119 | // ----------------------------------------------------------------------------- 120 | // The QLGeneratorInterfaceStruct function table. 121 | // 122 | static QLGeneratorInterfaceStruct myInterfaceFtbl = { 123 | NULL, 124 | QuickLookGeneratorQueryInterface, 125 | QuickLookGeneratorPluginAddRef, 126 | QuickLookGeneratorPluginRelease, 127 | NULL, 128 | NULL, 129 | NULL, 130 | NULL 131 | }; 132 | 133 | 134 | // ----------------------------------------------------------------------------- 135 | // AllocQuickLookGeneratorPluginType 136 | // ----------------------------------------------------------------------------- 137 | // Utility function that allocates a new instance. 138 | // You can do some initial setup for the generator here if you wish 139 | // like allocating globals etc... 140 | // 141 | QuickLookGeneratorPluginType *AllocQuickLookGeneratorPluginType(CFUUIDRef inFactoryID) 142 | { 143 | QuickLookGeneratorPluginType *theNewInstance; 144 | 145 | theNewInstance = (QuickLookGeneratorPluginType *)malloc(sizeof(QuickLookGeneratorPluginType)); 146 | memset(theNewInstance,0,sizeof(QuickLookGeneratorPluginType)); 147 | 148 | /* Point to the function table Malloc enough to store the stuff and copy the filler from myInterfaceFtbl over */ 149 | theNewInstance->conduitInterface = malloc(sizeof(QLGeneratorInterfaceStruct)); 150 | memcpy(theNewInstance->conduitInterface,&myInterfaceFtbl,sizeof(QLGeneratorInterfaceStruct)); 151 | 152 | /* Retain and keep an open instance refcount for each factory. */ 153 | theNewInstance->factoryID = CFRetain(inFactoryID); 154 | CFPlugInAddInstanceForFactory(inFactoryID); 155 | 156 | /* This function returns the IUnknown interface so set the refCount to one. */ 157 | theNewInstance->refCount = 1; 158 | return theNewInstance; 159 | } 160 | 161 | // ----------------------------------------------------------------------------- 162 | // DeallocQuickLookGeneratorPluginType 163 | // ----------------------------------------------------------------------------- 164 | // Utility function that deallocates the instance when 165 | // the refCount goes to zero. 166 | // In the current implementation generator interfaces are never deallocated 167 | // but implement this as this might change in the future 168 | // 169 | void DeallocQuickLookGeneratorPluginType(QuickLookGeneratorPluginType *thisInstance) 170 | { 171 | CFUUIDRef theFactoryID; 172 | 173 | theFactoryID = thisInstance->factoryID; 174 | /* Free the conduitInterface table up */ 175 | free(thisInstance->conduitInterface); 176 | 177 | /* Free the instance structure */ 178 | free(thisInstance); 179 | if (theFactoryID){ 180 | CFPlugInRemoveInstanceForFactory(theFactoryID); 181 | CFRelease(theFactoryID); 182 | } 183 | } 184 | 185 | // ----------------------------------------------------------------------------- 186 | // QuickLookGeneratorQueryInterface 187 | // ----------------------------------------------------------------------------- 188 | // Implementation of the IUnknown QueryInterface function. 189 | // 190 | HRESULT QuickLookGeneratorQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv) 191 | { 192 | CFUUIDRef interfaceID; 193 | 194 | interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); 195 | 196 | if (CFEqual(interfaceID,kQLGeneratorCallbacksInterfaceID)){ 197 | /* If the Right interface was requested, bump the ref count, 198 | * set the ppv parameter equal to the instance, and 199 | * return good status. 200 | */ 201 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GenerateThumbnailForURL = GenerateThumbnailForURL; 202 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelThumbnailGeneration = CancelThumbnailGeneration; 203 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->GeneratePreviewForURL = GeneratePreviewForURL; 204 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType *)thisInstance)->conduitInterface)->CancelPreviewGeneration = CancelPreviewGeneration; 205 | ((QLGeneratorInterfaceStruct *)((QuickLookGeneratorPluginType*)thisInstance)->conduitInterface)->AddRef(thisInstance); 206 | *ppv = thisInstance; 207 | CFRelease(interfaceID); 208 | return S_OK; 209 | }else{ 210 | /* Requested interface unknown, bail with error. */ 211 | *ppv = NULL; 212 | CFRelease(interfaceID); 213 | return E_NOINTERFACE; 214 | } 215 | } 216 | 217 | // ----------------------------------------------------------------------------- 218 | // QuickLookGeneratorPluginAddRef 219 | // ----------------------------------------------------------------------------- 220 | // Implementation of reference counting for this type. Whenever an interface 221 | // is requested, bump the refCount for the instance. NOTE: returning the 222 | // refcount is a convention but is not required so don't rely on it. 223 | // 224 | ULONG QuickLookGeneratorPluginAddRef(void *thisInstance) 225 | { 226 | ((QuickLookGeneratorPluginType *)thisInstance )->refCount += 1; 227 | return ((QuickLookGeneratorPluginType*) thisInstance)->refCount; 228 | } 229 | 230 | // ----------------------------------------------------------------------------- 231 | // QuickLookGeneratorPluginRelease 232 | // ----------------------------------------------------------------------------- 233 | // When an interface is released, decrement the refCount. 234 | // If the refCount goes to zero, deallocate the instance. 235 | // 236 | ULONG QuickLookGeneratorPluginRelease(void *thisInstance) 237 | { 238 | ((QuickLookGeneratorPluginType*)thisInstance)->refCount -= 1; 239 | if (((QuickLookGeneratorPluginType*)thisInstance)->refCount == 0){ 240 | DeallocQuickLookGeneratorPluginType((QuickLookGeneratorPluginType*)thisInstance ); 241 | return 0; 242 | }else{ 243 | return ((QuickLookGeneratorPluginType*) thisInstance )->refCount; 244 | } 245 | } 246 | 247 | // ----------------------------------------------------------------------------- 248 | // QuickLookGeneratorPluginFactory 249 | // ----------------------------------------------------------------------------- 250 | void *QuickLookGeneratorPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID) 251 | { 252 | QuickLookGeneratorPluginType *result; 253 | CFUUIDRef uuid; 254 | 255 | /* If correct type is being requested, allocate an 256 | * instance of kQLGeneratorTypeID and return the IUnknown interface. 257 | */ 258 | if (CFEqual(typeID,kQLGeneratorTypeID)){ 259 | uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID)); 260 | result = AllocQuickLookGeneratorPluginType(uuid); 261 | CFRelease(uuid); 262 | return result; 263 | } 264 | /* If the requested type is incorrect, return NULL. */ 265 | return NULL; 266 | } 267 | --------------------------------------------------------------------------------