//----------------------------------------------------------------------------- IPlatformBitmap* IPlatformBitmap::createFromMemory (const void* ptr, uint32_t memSize) { CGBitmap* bitmap = 0; CFDataRef data = CFDataCreate (0, (const UInt8*)ptr, memSize); if (data) { CGImageSourceRef source = CGImageSourceCreateWithData (data, NULL); if (source) { bitmap = new CGBitmap (); bool result = bitmap->loadFromImageSource (source); if (result == false) { bitmap->forget (); bitmap = 0; } CFRelease (source); } CFRelease (data); } return bitmap; }
//----------------------------------------------------------------------------- IPlatformBitmap* IPlatformBitmap::createFromPath (UTF8StringPtr absolutePath) { CGBitmap* bitmap = 0; CFURLRef url = CFURLCreateFromFileSystemRepresentation (0, (const UInt8*)absolutePath, strlen (absolutePath), false); if (url) { CGImageSourceRef source = CGImageSourceCreateWithURL (url, NULL); if (source) { bitmap = new CGBitmap (); bool result = bitmap->loadFromImageSource (source); if (result == false) { bitmap->forget (); bitmap = 0; } CFRelease (source); } CFRelease (url); } return bitmap; }