Avoid sharing gdicmn for just bitmaps

This commit is contained in:
Marek Roszko 2021-06-03 01:46:04 -04:00
parent 8ea180c6b7
commit b5b76eedf7
5 changed files with 23 additions and 5 deletions

View File

@ -25,6 +25,7 @@
#include <wx/image.h> #include <wx/image.h>
#include <wx/bitmap.h> #include <wx/bitmap.h>
#include <wx/gdicmn.h>
#include <wx/mstream.h> #include <wx/mstream.h>
#include <wx/menu.h> #include <wx/menu.h>
#include <wx/menuitem.h> #include <wx/menuitem.h>
@ -201,7 +202,7 @@ wxBitmap* KiBitmapNew( BITMAPS aBitmap )
bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName, bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName,
wxBitmapType aBitmapType ) BITMAP_TYPE aBitmapType )
{ {
wxCHECK( aFrame != nullptr, false ); wxCHECK( aFrame != nullptr, false );
@ -220,7 +221,15 @@ bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName,
wxImage image = bitmap.ConvertToImage(); wxImage image = bitmap.ConvertToImage();
if( !image.SaveFile( aFileName, aBitmapType ) ) wxBitmapType type = wxBITMAP_TYPE_PNG;
switch( aBitmapType )
{
case BITMAP_TYPE::PNG: type = wxBITMAP_TYPE_PNG; break;
case BITMAP_TYPE::BMP: type = wxBITMAP_TYPE_BMP; break;
case BITMAP_TYPE::JPG: type = wxBITMAP_TYPE_JPEG; break;
}
if( !image.SaveFile( aFileName, type ) )
retv = false; retv = false;
image.Destroy(); image.Destroy();

View File

@ -22,6 +22,7 @@
*/ */
#include <bitmaps.h> #include <bitmaps.h>
#include <cstddef>
#include <core/arraydim.h> #include <core/arraydim.h>
#include <lib_pin.h> #include <lib_pin.h>
#include <pin_type.h> #include <pin_type.h>

View File

@ -403,7 +403,7 @@ int SYMBOL_EDITOR_CONTROL::ExportView( const TOOL_EVENT& aEvent )
// to refresh the screen before creating the PNG or JPEG image from screen // to refresh the screen before creating the PNG or JPEG image from screen
wxYield(); wxYield();
if( !SaveCanvasImageToFile( editFrame, dlg.GetPath(), wxBITMAP_TYPE_PNG ) ) if( !SaveCanvasImageToFile( editFrame, dlg.GetPath(), BITMAP_TYPE::PNG ) )
{ {
wxMessageBox( wxString::Format( _( "Can't save file \"%s\"." ), dlg.GetPath() ) ); wxMessageBox( wxString::Format( _( "Can't save file \"%s\"." ), dlg.GetPath() ) );
} }

View File

@ -28,6 +28,8 @@
#include <vector> #include <vector>
#include <bitmaps/bitmaps_list.h> #include <bitmaps/bitmaps_list.h>
#include <wx/string.h> // wxT
struct BITMAP_INFO struct BITMAP_INFO
{ {
BITMAPS id; BITMAPS id;

View File

@ -32,12 +32,18 @@
class wxBitmap; // only to define wxBitmap class wxBitmap; // only to define wxBitmap
class EDA_DRAW_FRAME; class EDA_DRAW_FRAME;
class wxWindow; class wxWindow;
class wxString;
struct BITMAP_OPAQUE; struct BITMAP_OPAQUE;
class BITMAP_STORE; class BITMAP_STORE;
enum class BITMAPS : unsigned int; enum class BITMAPS : unsigned int;
#include <wx/gdicmn.h> // wxBitmapType enum class BITMAP_TYPE
{
PNG,
JPG,
BMP
};
BITMAP_STORE* GetBitmapStore(); BITMAP_STORE* GetBitmapStore();
@ -103,6 +109,6 @@ wxBitmap* KiBitmapNew( BITMAPS aBitmap );
* @return True if the file was successfully saved or false if the file failed to be saved. * @return True if the file was successfully saved or false if the file failed to be saved.
*/ */
bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName, bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName,
wxBitmapType aBitmapType = wxBITMAP_TYPE_PNG ); BITMAP_TYPE aBitmapType = BITMAP_TYPE::PNG );
#endif // BITMAP_TYPES_H_ #endif // BITMAP_TYPES_H_