forked from alexzielenski/Mousecape
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OS X changed default colorspace settings for reading images it seems
- Loading branch information
1 parent
5411d09
commit b570903
Showing
8 changed files
with
97 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// NSBitmapImageRep+ColorSpace.h | ||
// mousecloak | ||
// | ||
// Created by Alexander Zielenski on 12/30/18. | ||
// Copyright © 2018 Alex Zielenski. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface NSBitmapImageRep (ColorSpace) | ||
|
||
- (NSBitmapImageRep *)ensuredSRGBSpace; | ||
- (CGImageRef)copyEnsuredCGImage; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// NSBitmapImageRep+ColorSpace.m | ||
// mousecloak | ||
// | ||
// Created by Alexander Zielenski on 12/30/18. | ||
// Copyright © 2018 Alex Zielenski. All rights reserved. | ||
// | ||
|
||
#import "NSBitmapImageRep+ColorSpace.h" | ||
|
||
@implementation NSBitmapImageRep (ColorSpace) | ||
- (NSBitmapImageRep *)ensuredSRGBSpace { | ||
NSColorSpace *targetSpace = [NSColorSpace sRGBColorSpace]; | ||
if (self.colorSpace != NULL) { | ||
if (self.colorSpace.numberOfColorComponents == 1) { | ||
targetSpace = [NSColorSpace genericGamma22GrayColorSpace]; | ||
} | ||
} | ||
return [self bitmapImageRepByRetaggingWithColorSpace:targetSpace]; | ||
} | ||
- (CGImageRef)copyEnsuredCGImage { | ||
CGImageRef ref = self.ensuredSRGBSpace.CGImage; | ||
CGColorSpaceRef space = CGImageGetColorSpace(ref); | ||
NSColorSpace *targetSpace = [NSColorSpace sRGBColorSpace]; | ||
if (space != NULL) { | ||
if (CGColorSpaceGetNumberOfComponents(space) == 1) { | ||
targetSpace = [NSColorSpace genericGamma22GrayColorSpace]; | ||
} | ||
} | ||
|
||
return CGImageCreateCopyWithColorSpace(ref, space); | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters