The validity of these flags depends on the platform and wxWindows configuration.
If all possible wxWindows settings are used, the Windows platform supports BMP file, BMP resource,
XPM data, and XPM. Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file.
-Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.}
+Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.
+
+In addition, wxBitmap can read all formats that \helpref{wxImage}{wximage} can
+(wxBITMAP\_TYPE\_JPEG, wxBITMAP\_TYPE\_PNG, wxBITMAP\_TYPE\_GIF, wxBITMAP\_TYPE\_PCX, wxBITMAP\_TYPE\_PNM).
+(Of course you must have wxImage handlers loaded.) }
\wxheading{Remarks}
\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Load an XPM bitmap file.}
\end{twocollist}
-The validity of these flags depends on the platform and wxWindows configuration.}
+The validity of these flags depends on the platform and wxWindows configuration.
+
+In addition, wxBitmap can read all formats that \helpref{wxImage}{wximage} can
+(wxBITMAP\_TYPE\_JPEG, wxBITMAP\_TYPE\_PNG, wxBITMAP\_TYPE\_GIF, wxBITMAP\_TYPE\_PCX, wxBITMAP\_TYPE\_PNM).
+(Of course you must have wxImage handlers loaded.) }
\wxheading{Return value}
\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Save an XPM bitmap file.}
\end{twocollist}
-The validity of these flags depends on the platform and wxWindows configuration.}
+The validity of these flags depends on the platform and wxWindows configuration.
+
+In addition, wxBitmap can save all formats that \helpref{wxImage}{wximage} can
+(wxBITMAP\_TYPE\_JPEG, wxBITMAP\_TYPE\_PNG).
+(Of course you must have wxImage handlers loaded.) }
\docparam{palette}{An optional palette used for saving the bitmap.}
% TODO: this parameter should
{
wxCHECK_MSG( Ok(), FALSE, wxT("invalid bitmap") );
- if (type == wxBITMAP_TYPE_PNG)
+ // Try to save the bitmap via wxImage handlers:
{
wxImage image( *this );
if (image.Ok()) return image.SaveFile( name, type );
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
}
- else if (type == wxBITMAP_TYPE_PNG)
+ else // try if wxImage can load it
{
wxImage image;
- image.LoadFile( name, type );
+ if (!image.LoadFile( name, type )) return FALSE;
if (image.Ok()) *this = image.ConvertToBitmap();
+ else return FALSE;
}
- else if (type == wxBITMAP_TYPE_BMP)
- {
- wxImage image;
- image.LoadFile( name, type );
- if (image.Ok()) *this = image.ConvertToBitmap();
- }
- else
- return FALSE;
return TRUE;
}
{
wxCHECK_MSG( Ok(), FALSE, wxT("invalid bitmap") );
- if (type == wxBITMAP_TYPE_PNG)
+ // Try to save the bitmap via wxImage handlers:
{
wxImage image( *this );
if (image.Ok()) return image.SaveFile( name, type );
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth;
}
- else if (type == wxBITMAP_TYPE_PNG)
+ else // try if wxImage can load it
{
wxImage image;
- image.LoadFile( name, type );
+ if (!image.LoadFile( name, type )) return FALSE;
if (image.Ok()) *this = image.ConvertToBitmap();
+ else return FALSE;
}
- else if (type == wxBITMAP_TYPE_BMP)
- {
- wxImage image;
- image.LoadFile( name, type );
- if (image.Ok()) *this = image.ConvertToBitmap();
- }
- else
- return FALSE;
return TRUE;
}
#include "wx/log.h"
#include "wx/control.h"
#include "wx/dcmemory.h"
+#include "wx/image.h"
#include <Xm/Xm.h>
wxBitmapHandler *handler = FindHandler(type);
if ( handler == NULL ) {
- wxLogWarning("%s: no bitmap handler for type %d defined.", (const char*) filename, type);
-
- return FALSE;
+ wxImage image;
+ if (!image.LoadFile( filename, type )) return FALSE;
+ if (image.Ok())
+ {
+ *this = image.ConvertToBitmap();
+ return TRUE;
+ }
+ else return FALSE;
}
return handler->LoadFile(this, filename, type, -1, -1);
{
wxBitmapHandler *handler = FindHandler(type);
- if ( handler == NULL ) {
- wxLogWarning("no bitmap handler for type %d defined.", type);
-
- return FALSE;
+ if ( handler == NULL ) { // try wxImage
+ wxImage image( *this );
+ if (image.Ok()) return image.SaveFile( filename, type );
+ else return FALSE;
}
return handler->SaveFile(this, filename, type, palette);
#include "wx/log.h"
#include "wx/msw/dib.h"
+#include "wx/image.h"
// ----------------------------------------------------------------------------
// macros
wxBitmapHandler *handler = FindHandler(type);
if ( handler == NULL ) {
- wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
-
- return FALSE;
+ wxImage image;
+ if (!image.LoadFile( filename, type )) return FALSE;
+ if (image.Ok())
+ {
+ *this = image.ConvertToBitmap();
+ return TRUE;
+ }
+ else return FALSE;
}
return handler->LoadFile(this, filename, type, -1, -1);
{
wxBitmapHandler *handler = FindHandler(type);
- if ( handler == NULL ) {
- wxLogWarning(wxT("no bitmap handler for type %d defined."), type);
-
- return FALSE;
+ if ( handler == NULL ) { // try wxImage
+ wxImage image( *this );
+ if (image.Ok()) return image.SaveFile( filename, type );
+ else return FALSE;
}
return handler->SaveFile(this, filename, type, palette);