Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
142 views
in Technique[技术] by (71.8m points)

ios - How to create CGColorSpace from EXIF number?

I have a CGImageSourceRef with a following metadata:

// CGImageSourceCopyMetadataAtIndex
<CGImageMetadata 0x10225ed50> (
    exif:SubsecTimeDigitized = 000
    exif:ColorSpace = 1
    // and more ... 
)


// CGImageSourceCopyPropertiesAtIndex
{
    ProfileName = "sRGB IEC61966-2.1";
    "{Exif}" =     {
        ColorSpace = 1;
    };
    // and more ...
} 

"ColorSpace" here is "1". I've seen all constructors of CGColorSpaceRef, none of them creates a color space from a number.

CGColorSpaceCreateWithName(CFStringRef name) takes a name, which isn't enum, just a bunch of hardcoded strings like kCGColorSpaceDisplayP3.

How to create a CGColorSpace from this 1 magic number?

question from:https://stackoverflow.com/questions/65937002/how-to-create-cgcolorspace-from-exif-number

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Well, currently I'm using CoreImage approach because it's simple and fast:

CIImage* ciImage = [CIImage imageWithData:rawData];
CGColorSpaceRef cs = ciImage.colorSpace;

CIImage doesn't have memory overhead if created with pre-allocated bytes. It also doesn't have performance overhead if not rendered e.g. with [CIContext render].


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...