How to create a CGImageSourceRef
from raw data?
I have one file that consists only of the pixel information of an image. I know the resolution and the depth and so on (e.g. 640x860, RGB, 8bit, orientation = 1, DPI = 300). These informations aren't stored inside the file. As I already wrote, this file just stores the raw pixel information.
Now I tried the following:
NSString *path = @"/Users/.../Desktop/image";
NSData *data = [NSData dataWithContentsOfFile: path];
CFDataRef cfdata = CFDataCreate(NULL, [data bytes], [data length]);
CFDictionaryRef options;
CGImageSourceRef imageSource = CGImageSourceCreateWithData(cfdata, nil);
The image is not created correctly, because of the undefined image dimensions. I have no idea how to define the image informations (resolution and so on) for this CFImageSourceRef
. Think I have to initialize the CFDictionaryRef options
and deliver it to
CGImageSourceRef imageSource = CGImageSourceCreateWithData(cfdata, options);
How can I create a CFDictionaryRef
that it is usable for the method CGImageSourceCreateWithData
?