commit 68bb0cb407bd94be22e849392bb121019950cfac from: Matthias L. Jugel date: Sat Jan 24 11:02:23 2015 UTC initial commit commit - 70ee04fcea14037723fde895fef5a81362fce70c commit + 68bb0cb407bd94be22e849392bb121019950cfac blob - /dev/null blob + 62ebe0575fee7d7abe32d37247262bf874970de0 (mode 644) --- /dev/null +++ ComicSaver/ComicSaverView.h @@ -0,0 +1,17 @@ +// +// ComicSaverView.h +// ComicSaver +// +// Created by Matthias Jugel on 24/01/15. +// Copyright (c) 2015 Matthias Jugel. All rights reserved. +// + +#import + +@interface ComicSaverView : ScreenSaverView +{ + CGPDFDocumentRef document; + CGPDFPageRef page; +} + +@end blob - /dev/null blob + faf4005511f8098b5ebd951912af067b1aed3892 (mode 644) --- /dev/null +++ ComicSaver/ComicSaverView.m @@ -0,0 +1,94 @@ +// +// ComicSaverView.m +// ComicSaver +// +// Created by Matthias Jugel on 24/01/15. +// Copyright (c) 2015 Matthias Jugel. All rights reserved. +// + +#import "ComicSaverView.h" + +@implementation ComicSaverView + +- (instancetype)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview +{ + self = [super initWithFrame:frame isPreview:isPreview]; + + if (self) { + // [self setAnimationTimeInterval:1/30.0]; + } + return self; +} + +- (void)startAnimation +{ + document = MyGetPDFDocumentRef ("/Users/leo/Documents/Shared/Comics/Letter 44/letter44_vol1_1412097863.pdf"); + long numberOfPages = CGPDFDocumentGetNumberOfPages (document); + page = CGPDFDocumentGetPage (document, (random()%numberOfPages)+1); + [super startAnimation]; +} + +- (void)stopAnimation +{ + [super stopAnimation]; + CGPDFDocumentRelease (document); +} + +- (void)drawRect:(NSRect)rect +{ + CGRect cropBox = CGPDFPageGetBoxRect(page, kCGPDFCropBox); + + CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort]; + CGRect clip = CGContextGetClipBoundingBox(context); + + CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0); + CGContextFillRect(context, clip); + CGContextTranslateCTM(context, 0.0, -(clip.size.height + cropBox.size.height)); + CGContextScaleCTM(context, 1.0, 1.0); + + CGFloat xScale = clip.size.width / cropBox.size.width; + CGFloat yScale = clip.size.height / cropBox.size.height; + CGFloat scaleToApply = xScale < yScale ? yScale : xScale; + CGContextConcatCTM(context, CGAffineTransformMakeScale(scaleToApply, scaleToApply)); + // CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, clip, 0, true)); + CGContextDrawPDFPage (context, page); +} + +- (void)animateOneFrame +{ + [self setNeedsDisplay:YES]; +} + +- (BOOL)hasConfigureSheet +{ + return NO; +} + +- (NSWindow*)configureSheet +{ + return nil; +} + +CGPDFDocumentRef MyGetPDFDocumentRef (const char *filename) +{ + CFStringRef path; + CFURLRef url; + CGPDFDocumentRef document; + size_t count; + + path = CFStringCreateWithCString (NULL, filename, + kCFStringEncodingUTF8); + url = CFURLCreateWithFileSystemPath (NULL, path, // 1 + kCFURLPOSIXPathStyle, 0); + CFRelease (path); + document = CGPDFDocumentCreateWithURL (url);// 2 + CFRelease(url); + count = CGPDFDocumentGetNumberOfPages (document);// 3 + if (count == 0) { + printf("`%s' needs at least one page!", filename); + return NULL; + } + return document; +} + +@end \ No newline at end of file blob - /dev/null blob + bbe370546639fcdccf20cf877909213a3a46172e (mode 644) --- /dev/null +++ ComicSaver/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + com.thinkberg.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + NSHumanReadableCopyright + Copyright © 2015 Matthias Jugel. All rights reserved. + NSPrincipalClass + ComicSaverView + + blob - /dev/null blob + 59f411988d0114241f4c63a11c715c5a888aaf67 (mode 644) --- /dev/null +++ ComicSaver.xcodeproj/project.pbxproj @@ -0,0 +1,279 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + B37E01071A73B0BD00160F0A /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = B37E01051A73B0BD00160F0A /* LICENSE */; }; + B37E01081A73B0BD00160F0A /* README.md in Sources */ = {isa = PBXBuildFile; fileRef = B37E01061A73B0BD00160F0A /* README.md */; }; + B3FC103A1A73B03900FA93DF /* ComicSaverView.h in Headers */ = {isa = PBXBuildFile; fileRef = B3FC10391A73B03900FA93DF /* ComicSaverView.h */; }; + B3FC103C1A73B03900FA93DF /* ComicSaverView.m in Sources */ = {isa = PBXBuildFile; fileRef = B3FC103B1A73B03900FA93DF /* ComicSaverView.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + B37E01051A73B0BD00160F0A /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE; path = ../comicsaver/LICENSE; sourceTree = ""; }; + B37E01061A73B0BD00160F0A /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../comicsaver/README.md; sourceTree = ""; }; + B3FC10341A73B03900FA93DF /* ComicSaver.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ComicSaver.saver; sourceTree = BUILT_PRODUCTS_DIR; }; + B3FC10381A73B03900FA93DF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B3FC10391A73B03900FA93DF /* ComicSaverView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ComicSaverView.h; sourceTree = ""; }; + B3FC103B1A73B03900FA93DF /* ComicSaverView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ComicSaverView.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B3FC10301A73B03900FA93DF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B3FC102A1A73B03900FA93DF = { + isa = PBXGroup; + children = ( + B37E01051A73B0BD00160F0A /* LICENSE */, + B37E01061A73B0BD00160F0A /* README.md */, + B3FC10361A73B03900FA93DF /* ComicSaver */, + B3FC10351A73B03900FA93DF /* Products */, + ); + sourceTree = ""; + }; + B3FC10351A73B03900FA93DF /* Products */ = { + isa = PBXGroup; + children = ( + B3FC10341A73B03900FA93DF /* ComicSaver.saver */, + ); + name = Products; + sourceTree = ""; + }; + B3FC10361A73B03900FA93DF /* ComicSaver */ = { + isa = PBXGroup; + children = ( + B3FC10391A73B03900FA93DF /* ComicSaverView.h */, + B3FC103B1A73B03900FA93DF /* ComicSaverView.m */, + B3FC10371A73B03900FA93DF /* Supporting Files */, + ); + path = ComicSaver; + sourceTree = ""; + }; + B3FC10371A73B03900FA93DF /* Supporting Files */ = { + isa = PBXGroup; + children = ( + B3FC10381A73B03900FA93DF /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + B3FC10311A73B03900FA93DF /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + B3FC103A1A73B03900FA93DF /* ComicSaverView.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + B3FC10331A73B03900FA93DF /* ComicSaver */ = { + isa = PBXNativeTarget; + buildConfigurationList = B3FC103F1A73B03900FA93DF /* Build configuration list for PBXNativeTarget "ComicSaver" */; + buildPhases = ( + B3FC102F1A73B03900FA93DF /* Sources */, + B3FC10301A73B03900FA93DF /* Frameworks */, + B3FC10311A73B03900FA93DF /* Headers */, + B3FC10321A73B03900FA93DF /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ComicSaver; + productName = ComicSaver; + productReference = B3FC10341A73B03900FA93DF /* ComicSaver.saver */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B3FC102B1A73B03900FA93DF /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0610; + ORGANIZATIONNAME = "Matthias Jugel"; + TargetAttributes = { + B3FC10331A73B03900FA93DF = { + CreatedOnToolsVersion = 6.1; + }; + }; + }; + buildConfigurationList = B3FC102E1A73B03900FA93DF /* Build configuration list for PBXProject "ComicSaver" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = B3FC102A1A73B03900FA93DF; + productRefGroup = B3FC10351A73B03900FA93DF /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B3FC10331A73B03900FA93DF /* ComicSaver */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + B3FC10321A73B03900FA93DF /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B37E01071A73B0BD00160F0A /* LICENSE in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + B3FC102F1A73B03900FA93DF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B37E01081A73B0BD00160F0A /* README.md in Sources */, + B3FC103C1A73B03900FA93DF /* ComicSaverView.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + B3FC103D1A73B03900FA93DF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + B3FC103E1A73B03900FA93DF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + B3FC10401A73B03900FA93DF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = ComicSaver/Info.plist; + INSTALL_PATH = "$(HOME)/Library/Screen Savers"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = saver; + }; + name = Debug; + }; + B3FC10411A73B03900FA93DF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = ComicSaver/Info.plist; + INSTALL_PATH = "$(HOME)/Library/Screen Savers"; + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = saver; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B3FC102E1A73B03900FA93DF /* Build configuration list for PBXProject "ComicSaver" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B3FC103D1A73B03900FA93DF /* Debug */, + B3FC103E1A73B03900FA93DF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B3FC103F1A73B03900FA93DF /* Build configuration list for PBXNativeTarget "ComicSaver" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B3FC10401A73B03900FA93DF /* Debug */, + B3FC10411A73B03900FA93DF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B3FC102B1A73B03900FA93DF /* Project object */; +} blob - /dev/null blob + 1422b1c6b4ef34dc55176f1b9bd75a01c93e7618 (mode 644) --- /dev/null +++ ComicSaver.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + +