+// ----------------------------------------------------------------------------
+// PNG handler
+// ----------------------------------------------------------------------------
+
+bool wxPNGResourceHandler::LoadFile(wxBitmap *bitmap,
+ const wxString& name,
+ wxBitmapType WXUNUSED(flags),
+ int WXUNUSED(desiredWidth),
+ int WXUNUSED(desiredHeight))
+{
+ const void* pngData = NULL;
+ size_t pngSize = 0;
+
+ // Currently we hardcode RCDATA resource type as this is what is usually
+ // used for the embedded images. We could allow specifying the type as part
+ // of the name in the future (e.g. "type:name" or something like this) if
+ // really needed.
+ if ( !wxLoadUserResource(&pngData, &pngSize,
+ name,
+ RT_RCDATA,
+ wxGetInstance()) )
+ {
+ // Notice that this message is not translated because only the
+ // programmer (and not the end user) can make any use of it.
+ wxLogError(wxS("Bitmap in PNG format \"%s\" not found, check ")
+ wxS("that the resource file contains \"RCDATA\" ")
+ wxS("resource with this name."),
+ name);
+
+ return false;
+ }
+
+ *bitmap = wxBitmap::NewFromPNGData(pngData, pngSize);
+ if ( !bitmap->IsOk() )
+ {
+ wxLogError(wxS("Couldn't load resource bitmap \"%s\" as a PNG. "),
+ wxS("Have you registered PNG image handler?"),
+ name);
+
+ return false;
+ }
+
+ return true;