本文整理匯總了C++中CFDataCreateWithBytesNoCopy函數的典型用法代碼示例。如果您正苦於以下問題:C++ CFDataCreateWithBytesNoCopy函數的具體用法?C++ CFDataCreateWithBytesNoCopy怎麽用?C++ CFDataCreateWithBytesNoCopy使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CFDataCreateWithBytesNoCopy函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: DHCPLeaseCopyDictionary
static CFDictionaryRef
DHCPLeaseCopyDictionary(DHCPLeaseRef lease_p)
{
CFDataRef data;
CFDateRef date;
CFMutableDictionaryRef dict;
CFNumberRef num;
CFStringRef str;
dict = CFDictionaryCreateMutable(NULL, 0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
/* set the IP address */
str = CFStringCreateWithFormat(NULL, NULL, CFSTR(IP_FORMAT),
IP_LIST(&lease_p->our_ip));
CFDictionarySetValue(dict, kIPAddress, str);
CFRelease(str);
/* set the lease start date */
date = CFDateCreate(NULL, lease_p->lease_start);
CFDictionarySetValue(dict, kLeaseStartDate, date);
CFRelease(date);
/* set the lease length */
num = CFNumberCreate(NULL, kCFNumberSInt32Type, &lease_p->lease_length);
CFDictionarySetValue(dict, kLeaseLength, num);
CFRelease(num);
/* set the SSID */
if (lease_p->ssid != NULL) {
CFDictionarySetValue(dict, kSSID, lease_p->ssid);
}
/* set the packet data */
data = CFDataCreateWithBytesNoCopy(NULL, lease_p->pkt, lease_p->pkt_length,
kCFAllocatorNull);
CFDictionarySetValue(dict, kPacketData, data);
CFRelease(data);
if (lease_p->router_ip.s_addr != 0) {
/* set the router IP address */
str = CFStringCreateWithFormat(NULL, NULL, CFSTR(IP_FORMAT),
IP_LIST(&lease_p->router_ip));
CFDictionarySetValue(dict, kRouterIPAddress, str);
CFRelease(str);
if (lease_p->router_hwaddr_length > 0) {
/* set the router hardware address */
data = CFDataCreateWithBytesNoCopy(NULL, lease_p->router_hwaddr,
lease_p->router_hwaddr_length,
kCFAllocatorNull);
CFDictionarySetValue(dict, kRouterHardwareAddress, data);
CFRelease(data);
}
}
return (dict);
}
示例2: tests
static void tests(void)
{
CFDataRef attached_signed_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, attached_signed_data_der, attached_signed_data_der_len, kCFAllocatorNull);
CFDataRef detached_signed_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, detached_signed_data_der, detached_signed_data_der_len, kCFAllocatorNull);
CFDataRef attached_no_data_signed_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, attached_no_data_signed_data_der, attached_no_data_signed_data_der_len, kCFAllocatorNull);
CFDataRef detached_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, detached_content, detached_content_len, kCFAllocatorNull);
CFDataRef no_data = CFDataCreate(kCFAllocatorDefault, NULL, 0);
SecPolicyRef policy = SecPolicyCreateBasicX509();
SecTrustRef trust = NULL;
ok_status(SecCMSVerifyCopyDataAndAttributes(attached_signed_data, NULL, policy, &trust, NULL, NULL), "verify attached data");
CFRelease(trust);
ok_status(SecCMSVerifyCopyDataAndAttributes(detached_signed_data, detached_data, policy, &trust, NULL, NULL), "verify detached data");
CFRelease(trust);
ok_status(SecCMSVerifyCopyDataAndAttributes(attached_no_data_signed_data, NULL, policy, &trust, NULL, NULL), "verify attached no data");
CFRelease(trust);
ok_status(SecCMSVerifyCopyDataAndAttributes(attached_no_data_signed_data, no_data, policy, &trust, NULL, NULL), "verify attached no data");
CFRelease(trust);
SecCertificateRef cert = NULL;
SecKeyRef privKey = NULL;
SecIdentityRef identity = NULL;
isnt(cert = SecCertificateCreateWithBytes(NULL, signer_der, signer_der_len), NULL, "create certificate");
isnt(privKey = SecKeyCreateRSAPrivateKey(NULL, privkey_der, privkey_der_len, kSecKeyEncodingPkcs1), NULL, "create private key");
isnt(identity = SecIdentityCreate(NULL, cert, privKey), NULL, "create identity");
CFReleaseSafe(privKey);
CFMutableDataRef cms_data = CFDataCreateMutable(kCFAllocatorDefault, 0);
ok_status(SecCMSCreateSignedData(identity, detached_data, NULL, NULL, cms_data), "create attached data");
//write_data("/var/tmp/attached", cms_data);
CFDataSetLength(cms_data, 0);
CFDictionaryRef detached_cms_dict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&kSecCMSSignDetached, (const void **)&kCFBooleanTrue, 1, NULL, NULL);
ok_status(SecCMSCreateSignedData(identity, detached_data, detached_cms_dict, NULL, cms_data), "create attached data");
CFRelease(detached_cms_dict);
//write_data("/var/tmp/detached", cms_data);
CFDataSetLength(cms_data, 0);
ok_status(SecCMSCreateSignedData(identity, NULL, NULL, NULL, cms_data), "create attached data");
//write_data("/var/tmp/empty_attached", cms_data);
CFReleaseSafe(cms_data);
CFReleaseSafe(cert);
CFReleaseNull(identity);
CFRelease(attached_signed_data);
CFRelease(detached_signed_data);
CFRelease(attached_no_data_signed_data);
CFRelease(detached_data);
CFRelease(no_data);
CFRelease(policy);
}
示例3: mount_developer_image
void mount_developer_image(AMDeviceRef device) {
CFStringRef ds_path = copy_device_support_path(device);
CFStringRef image_path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/DeveloperDiskImage.dmg"), ds_path);
CFStringRef sig_path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/DeveloperDiskImage.dmg.signature"), ds_path);
CFRelease(ds_path);
FILE* sig = fopen(CFStringGetCStringPtr(sig_path, kCFStringEncodingMacRoman), "rb");
void *sig_buf = malloc(128);
assert(fread(sig_buf, 1, 128, sig) == 128);
fclose(sig);
CFDataRef sig_data = CFDataCreateWithBytesNoCopy(NULL, sig_buf, 128, NULL);
CFRelease(sig_path);
CFTypeRef keys[] = { CFSTR("ImageSignature"), CFSTR("ImageType") };
CFTypeRef values[] = { sig_data, CFSTR("Developer") };
CFDictionaryRef options = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFRelease(sig_data);
int result = AMDeviceMountImage(device, image_path, options, &mount_callback, 0);
if (result == 0 || result == 0xe8000076 /* already mounted */) {
printf("[ 95%%] Developer disk image mounted successfully\n");
} else {
printf("[ !! ] Unable to mount developer disk image. (%x)\n", result);
exit(1);
}
CFRelease(image_path);
CFRelease(options);
}
示例4: mach_reply_func
static void mach_reply_func(struct ReplyAddress * addr, char* msg, int size)
{
CFMessagePortRef replyPort = (CFMessagePortRef) addr->mSocket;
CFDataRef data = CFDataCreateWithBytesNoCopy(NULL, (const UInt8*)msg, size, kCFAllocatorNull);
CFMessagePortSendRequest(replyPort, 0, data, 0, 0, NULL, NULL);
CFRelease(data);
}
示例5: SecEncodeTransformCreate
TagLib::ByteVector TagLib::EncodeBase64(const TagLib::ByteVector& input)
{
ByteVector result;
CFErrorRef error;
SFB::SecTransform encoder = SecEncodeTransformCreate(kSecBase64Encoding, &error);
if(nullptr == encoder) {
LOGGER_WARNING("org.sbooth.AudioEngine", "SecEncodeTransformCreate failed: " << error);
return TagLib::ByteVector::null;
}
SFB::CFData sourceData = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, (const UInt8 *)input.data(), (CFIndex)input.size(), kCFAllocatorNull);
if(!sourceData)
return TagLib::ByteVector::null;
if(!SecTransformSetAttribute(encoder, kSecTransformInputAttributeName, sourceData, &error)) {
LOGGER_WARNING("org.sbooth.AudioEngine", "SecTransformSetAttribute failed: " << error);
return TagLib::ByteVector::null;
}
SFB::CFData encodedData = (CFDataRef)SecTransformExecute(encoder, &error);
if(!encodedData) {
LOGGER_WARNING("org.sbooth.AudioEngine", "SecTransformExecute failed: " << error);
return TagLib::ByteVector::null;
}
result.setData((const char *)CFDataGetBytePtr((CFDataRef)encodedData), (TagLib::uint)CFDataGetLength((CFDataRef)encodedData));
return result;
}
示例6: CFDataCreateWithBytesNoCopy
void GL::Image::load(const unsigned char *buf, size_t bufSize)
{
CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, (const UInt8*)buf, (CFIndex)bufSize, kCFAllocatorNull);
if (data != NULL) {
CGImageSourceRef imageSource = CGImageSourceCreateWithData(data, NULL);
if (imageSource != NULL) {
CGImageRef img = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL);
if (img != NULL) {
width_ = (int)CGImageGetWidth(img);
height_ = (int)CGImageGetHeight(img);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
if (colorSpace != NULL) {
char *texData = (char*)calloc(width_ * height_ * 4, sizeof(char));
CGContextRef ctx = CGBitmapContextCreate(texData, width_, height_, 8, width_ * 4, colorSpace, kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst);
if (ctx != NULL) {
CGContextDrawImage(ctx, CGRectMake(0.0, 0.0, width_, height_), img);
CGContextRelease(ctx);
loadTextureData_(texData);
}
free(texData);
CGColorSpaceRelease(colorSpace);
}
CGImageRelease(img);
}
CFRelease(imageSource);
}
CFRelease(data);
}
}
示例7: Clear
bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf )
{
Clear();
if ((pBuf == NULL) || (nSize == 0))
return false;
Handle picHandle = NewHandle( nSize );
memcpy( *picHandle, pBuf, nSize );
m_pictHandle = picHandle;
CGImageRef cgImageRef = 0;
CFDataRef data = CFDataCreateWithBytesNoCopy( kCFAllocatorDefault, (const UInt8*) pBuf, nSize, kCFAllocatorNull);
CGImageSourceRef source = CGImageSourceCreateWithData( data, NULL );
if ( source )
{
cgImageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL);
CFRelease( source );
}
CFRelease( data );
if ( cgImageRef )
{
m_bitmap.Create( cgImageRef );
CGImageRelease(cgImageRef);
cgImageRef = NULL;
}
return m_bitmap.IsOk();
}
示例8: _SecIdentityCopyPreferenceMatchingName
static
OSStatus _SecIdentityCopyPreferenceMatchingName(
CFStringRef name,
CSSM_KEYUSE keyUsage,
CFArrayRef validIssuers,
SecIdentityRef *identity)
{
// this is NOT exported, and called only from SecIdentityCopyPreference (below), so no BEGIN/END macros here;
// caller must handle exceptions
StorageManager::KeychainList keychains;
globals().storageManager.getSearchList(keychains);
KCCursor cursor(keychains, kSecGenericPasswordItemClass, NULL);
char idUTF8[MAXPATHLEN];
Required(name);
if (!CFStringGetCString(name, idUTF8, sizeof(idUTF8)-1, kCFStringEncodingUTF8))
idUTF8[0] = (char)'\0';
CssmData service(const_cast<char *>(idUTF8), strlen(idUTF8));
FourCharCode itemType = 'iprf';
cursor->add(CSSM_DB_EQUAL, Schema::attributeInfo(kSecServiceItemAttr), service);
cursor->add(CSSM_DB_EQUAL, Schema::attributeInfo(kSecTypeItemAttr), itemType);
if (keyUsage)
cursor->add(CSSM_DB_EQUAL, Schema::attributeInfo(kSecScriptCodeItemAttr), (sint32)keyUsage);
Item prefItem;
if (!cursor->next(prefItem))
return errSecItemNotFound;
// get persistent certificate reference
SecKeychainAttribute itemAttrs[] = { { kSecGenericItemAttr, 0, NULL } };
SecKeychainAttributeList itemAttrList = { sizeof(itemAttrs) / sizeof(itemAttrs[0]), itemAttrs };
prefItem->getContent(NULL, &itemAttrList, NULL, NULL);
// find certificate, given persistent reference data
CFDataRef pItemRef = CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)itemAttrs[0].data, itemAttrs[0].length, kCFAllocatorNull);
SecKeychainItemRef certItemRef = nil;
OSStatus status = SecKeychainItemCopyFromPersistentReference(pItemRef, &certItemRef); //%%% need to make this a method of ItemImpl
prefItem->freeContent(&itemAttrList, NULL);
if (pItemRef)
CFRelease(pItemRef);
if (status)
return status;
// filter on valid issuers, if provided
if (validIssuers) {
//%%%TBI
}
// create identity reference, given certificate
Item certItem = ItemImpl::required(SecKeychainItemRef(certItemRef));
SecPointer<Certificate> certificate(static_cast<Certificate *>(certItem.get()));
SecPointer<Identity> identity_ptr(new Identity(keychains, certificate));
if (certItemRef)
CFRelease(certItemRef);
Required(identity) = identity_ptr->handle();
return status;
}
示例9: my_CFPropertyListCreateFromFile
PRIVATE_EXTERN CFPropertyListRef
my_CFPropertyListCreateFromFile(const char * filename)
{
void * buf;
size_t bufsize;
CFDataRef data = NULL;
CFPropertyListRef plist = NULL;
buf = read_file(filename, &bufsize);
if (buf == NULL) {
return (NULL);
}
data = CFDataCreateWithBytesNoCopy(NULL, buf, bufsize, kCFAllocatorNull);
if (data == NULL) {
goto done;
}
plist = CFPropertyListCreateWithData(NULL,
data,
kCFPropertyListImmutable,
NULL,
NULL);
done:
if (data)
CFRelease(data);
if (buf)
free(buf);
return (plist);
}
示例10: Clear
bool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf )
{
Clear();
if ((pBuf == NULL) || (nSize == 0))
return false;
Handle picHandle = NewHandle( nSize );
memcpy( *picHandle, pBuf, nSize );
m_pictHandle = picHandle;
CGImageRef cgImageRef = 0;
CFDataRef data = CFDataCreateWithBytesNoCopy( kCFAllocatorDefault, (const UInt8*) pBuf, nSize, kCFAllocatorNull);
CGImageSourceRef source = CGImageSourceCreateWithData( data, NULL );
if ( source )
{
cgImageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL);
CFRelease( source );
}
CFRelease( data );
if ( cgImageRef )
{
m_bitmap.Create( CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) );
CGRect r = CGRectMake( 0 , 0 , CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) );
// since our context is upside down we dont use CGContextDrawImage
wxMacDrawCGImage( (CGContextRef) m_bitmap.GetHBITMAP() , &r, cgImageRef ) ;
CGImageRelease(cgImageRef);
cgImageRef = NULL;
}
return m_bitmap.IsOk();
}
示例11: encodeSessionHistoryEntryData
static RetainPtr<CFDataRef> encodeSessionHistoryEntryData(const FrameState& frameState)
{
static CFAllocatorRef fastMallocDeallocator;
static std::once_flag onceFlag;
std::call_once(onceFlag, [] {
CFAllocatorContext context = {
0, // version
nullptr, // info
nullptr, // retain
nullptr, // release
nullptr, // copyDescription
nullptr, // allocate
nullptr, // reallocate
[](void *ptr, void *info) {
WTF::fastFree(ptr);
},
nullptr, // preferredSize
};
fastMallocDeallocator = CFAllocatorCreate(kCFAllocatorDefault, &context);
});
size_t bufferSize;
auto buffer = encodeSessionHistoryEntryData(frameState, bufferSize);
return adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, buffer.leakPtr(), bufferSize, fastMallocDeallocator));
}
示例12: device_info
CFDictionaryRef device_info(int socket, CFDictionaryRef request)
{
uint8_t dkey[40]={0};
uint8_t emf[36]={0};
struct HFSInfos hfsinfos={0};
CFMutableDictionaryRef out = CFDictionaryCreateMutable(kCFAllocatorDefault,
0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
get_device_infos(out);
getHFSInfos(&hfsinfos);
/*
printf("NAND block size : %x\n", hfsinfos.blockSize);
printf("Data volume UUID : %llx\n", CFSwapInt64BigToHost(hfsinfos.volumeUUID));
printf("Data volume offset : %x\n", hfsinfos.dataVolumeOffset);
*/
uint8_t* key835 = IOAES_key835();
uint8_t* key89B = IOAES_key89B();
if (!AppleEffaceableStorage__getBytes(lockers, 960))
{
CFDataRef lockersData = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, lockers, 960, kCFAllocatorNull);
CFDictionaryAddValue(out, CFSTR("lockers"), lockersData);
CFRelease(lockersData);
if (!AppleEffaceableStorage__getLockerFromBytes(LOCKER_DKEY, lockers, 960, dkey, 40))
{
aes_key_wrap_ctx ctx;
aes_key_wrap_set_key(&ctx, key835, 16);
if(aes_key_unwrap(&ctx, dkey, dkey, 32/8))
printf("FAIL unwrapping DKey with key 0x835\n");
}
if (!AppleEffaceableStorage__getLockerFromBytes(LOCKER_EMF, lockers, 960, emf, 36))
{
doAES(&emf[4], &emf[4], 32, kIOAESAcceleratorCustomMask, key89B, NULL, kIOAESAcceleratorDecrypt, 128);
}
else if (!AppleEffaceableStorage__getLockerFromBytes(LOCKER_LWVM, lockers, 960, lwvm, 0x50))
{
doAES(lwvm, lwvm, 0x50, kIOAESAcceleratorCustomMask, key89B, NULL, kIOAESAcceleratorDecrypt, 128);
memcpy(&emf[4], &lwvm[32+16], 32);
}
}
CFNumberRef n = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &hfsinfos.dataVolumeOffset);
CFDictionaryAddValue(out, CFSTR("dataVolumeOffset"), n);
CFRelease(n);
addHexaString(out, CFSTR("dataVolumeUUID"), (uint8_t*) &hfsinfos.volumeUUID, 8);
addHexaString(out, CFSTR("key835"), key835, 16);
addHexaString(out, CFSTR("key89B"), key89B, 16);
addHexaString(out, CFSTR("EMF"), &emf[4], 32);
addHexaString(out, CFSTR("DKey"), dkey, 32);
return out;
}
示例13: CFDataCreateWithBytesNoCopy
bool Image::setData(bool allDataReceived)
{
int length = m_data.size();
if (!length)
return true;
#ifdef kImageBytesCutoff
// This is a hack to help with testing display of partially-loaded images.
// To enable it, define kImageBytesCutoff to be a size smaller than that of the image files
// being loaded. They'll never finish loading.
if (length > kImageBytesCutoff) {
length = kImageBytesCutoff;
allDataReceived = false;
}
#endif
#if __APPLE__
// Avoid the extra copy of bytes by just handing the byte array directly to a CFDataRef.
CFDataRef data = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(m_data.data()), length, kCFAllocatorNull);
bool result = setNativeData(data, allDataReceived);
CFRelease(data);
#else
bool result = setNativeData(&m_data, allDataReceived);
#endif
return result;
}
示例14: OT_ASSERT
// static
bool OTKeyring::IOS_StoreSecret(const OTString& strUser,
const OTPassword& thePassword,
const std::string& str_display)
{
OT_ASSERT(strUser.Exists());
OT_ASSERT(thePassword.getMemorySize() > 0);
CFStringRef service_name = CFSTR("opentxs");
CFStringRef account_name = CFStringCreateWithCString(nullptr, strUser.Get(),
kCFStringEncodingUTF8);
CFDataRef vData = CFDataCreateWithBytesNoCopy(
nullptr, thePassword.getMemory_uint8(), thePassword.getMemorySize(),
kCFAllocatorNull);
const void* keys[] = {kSecClass, kSecAttrService, kSecAttrAccount,
kSecValueData};
const void* values[] = {kSecClassGenericPassword, service_name,
account_name, vData};
CFDictionaryRef item =
CFDictionaryCreate(nullptr, keys, values, 4, nullptr, nullptr);
OSStatus theError = SecItemAdd(item, nullptr);
CFRelease(item);
CFRelease(vData);
CFRelease(account_name);
if (theError != noErr) {
otErr << "OTKeyring::IOS_StoreSecret: Error in SecItemAdd.\n";
return false;
}
return true;
}
示例15: os_image_load_from_file
unsigned char* os_image_load_from_file(const char* filename, int* outWidth, int* outHeight, int* outChannels, int unused) {
const int fileHandle = open(filename, O_RDONLY);
struct stat statBuffer;
fstat(fileHandle, &statBuffer);
const size_t bytesInFile = (size_t)(statBuffer.st_size);
uint8_t* fileData = (uint8_t*)(mmap(NULL, bytesInFile, PROT_READ, MAP_SHARED, fileHandle, 0));
if (fileData == MAP_FAILED) {
fprintf(stderr, "Couldn't open file '%s' with mmap\n", filename);
return NULL;
}
CFDataRef fileDataRef = CFDataCreateWithBytesNoCopy(NULL, fileData, bytesInFile, kCFAllocatorNull);
CGDataProviderRef imageProvider = CGDataProviderCreateWithCFData(fileDataRef);
const char* suffix = strrchr(filename, '.');
if (!suffix || suffix == filename) {
suffix = "";
}
CGImageRef image;
if (strcasecmp(suffix, ".png") == 0) {
image = CGImageCreateWithPNGDataProvider(imageProvider, NULL, true, kCGRenderingIntentDefault);
} else if ((strcasecmp(suffix, ".jpg") == 0) ||
(strcasecmp(suffix, ".jpeg") == 0)) {
image = CGImageCreateWithJPEGDataProvider(imageProvider, NULL, true, kCGRenderingIntentDefault);
} else {
munmap(fileData, bytesInFile);
close(fileHandle);
CFRelease(imageProvider);
CFRelease(fileDataRef);
fprintf(stderr, "Unknown suffix for file '%s'\n", filename);
return NULL;
}
const int width = (int)CGImageGetWidth(image);
const int height = (int)CGImageGetHeight(image);
const int channels = 4;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
const int bytesPerRow = (width * channels);
const int bytesInImage = (bytesPerRow * height);
uint8_t* result = (uint8_t*)(malloc(bytesInImage));
const int bitsPerComponent = 8;
CGContextRef context = CGBitmapContextCreate(result, width, height,
bitsPerComponent, bytesPerRow, colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
CGContextDrawImage(context, CGRectMake(0, 0, width, height), image);
CGContextRelease(context);
CFRelease(image);
munmap(fileData, bytesInFile);
close(fileHandle);
CFRelease(imageProvider);
CFRelease(fileDataRef);
*outWidth = width;
*outHeight = height;
*outChannels = channels;
return result;
}