+class WXDLLEXPORT wxBundleResourceHandler: public wxBitmapHandler
+{
+ DECLARE_ABSTRACT_CLASS(wxPNGResourceHandler)
+
+public:
+ inline wxBundleResourceHandler()
+ {
+ };
+
+ virtual bool LoadFile(wxBitmap *bitmap,
+ const wxString& name,
+ wxBitmapType type,
+ int desiredWidth,
+ int desiredHeight);
+};
+
+IMPLEMENT_ABSTRACT_CLASS(wxBundleResourceHandler, wxBitmapHandler);
+
+class WXDLLEXPORT wxPNGResourceHandler: public wxBundleResourceHandler
+{
+ DECLARE_DYNAMIC_CLASS(wxPNGResourceHandler)
+
+public:
+ inline wxPNGResourceHandler()
+ {
+ SetName(wxT("PNG resource"));
+ SetExtension("PNG");
+ SetType(wxBITMAP_TYPE_PNG_RESOURCE);
+ };
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxPNGResourceHandler, wxBundleResourceHandler)
+
+class WXDLLEXPORT wxJPEGResourceHandler: public wxBundleResourceHandler
+{
+ DECLARE_DYNAMIC_CLASS(wxPNGResourceHandler)
+
+public:
+ inline wxJPEGResourceHandler()
+ {
+ SetName(wxT("JPEG resource"));
+ SetExtension("JPEG");
+ SetType(wxBITMAP_TYPE_JPEG_RESOURCE);
+ };
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxJPEGResourceHandler, wxBundleResourceHandler)
+
+bool wxBundleResourceHandler::LoadFile(wxBitmap *bitmap,
+ const wxString& name,
+ wxBitmapType WXUNUSED(type),
+ int WXUNUSED(desiredWidth),
+ int WXUNUSED(desiredHeight))
+{
+ wxString ext = GetExtension().Lower();
+ wxCFStringRef resname(name);
+ wxCFStringRef restype(ext);
+
+ wxCFRef<CFURLRef> imageURL(CFBundleCopyResourceURL(CFBundleGetMainBundle(), resname, restype, NULL));
+
+ if ( imageURL.get() != NULL )
+ {
+ // Create the data provider object
+ wxCFRef<CGDataProviderRef> provider(CGDataProviderCreateWithURL (imageURL) );
+ CGImageRef image = NULL;
+
+ if ( ext == "jpeg" )
+ image = CGImageCreateWithJPEGDataProvider (provider, NULL, true,
+ kCGRenderingIntentDefault);
+ else if ( ext == "png" )
+ image = CGImageCreateWithPNGDataProvider (provider, NULL, true,
+ kCGRenderingIntentDefault);
+ if ( image != NULL )
+ {
+ bitmap->Create(image);
+ CGImageRelease(image);
+ }
+ }
+
+ return false ;
+}
+
+#if !defined( __LP64__ ) && !defined(__WXOSX_IPHONE__)