From b5b76eedf767fdd6520cd9ab3bf0bd99d18b1a65 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Thu, 3 Jun 2021 01:46:04 -0400 Subject: [PATCH] Avoid sharing gdicmn for just bitmaps --- common/bitmap.cpp | 13 +++++++++++-- eeschema/pin_type.cpp | 1 + eeschema/tools/symbol_editor_control.cpp | 2 +- include/bitmaps/bitmap_info.h | 2 ++ include/bitmaps/bitmap_types.h | 10 ++++++++-- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/common/bitmap.cpp b/common/bitmap.cpp index f6eca539d9..1cf8ba4a4a 100644 --- a/common/bitmap.cpp +++ b/common/bitmap.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -201,7 +202,7 @@ wxBitmap* KiBitmapNew( BITMAPS aBitmap ) bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName, - wxBitmapType aBitmapType ) + BITMAP_TYPE aBitmapType ) { wxCHECK( aFrame != nullptr, false ); @@ -220,7 +221,15 @@ bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName, 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; image.Destroy(); diff --git a/eeschema/pin_type.cpp b/eeschema/pin_type.cpp index 0e80599724..ba8b2ab184 100644 --- a/eeschema/pin_type.cpp +++ b/eeschema/pin_type.cpp @@ -22,6 +22,7 @@ */ #include +#include #include #include #include diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index 2aa0ad15c1..654aad7b3f 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -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 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() ) ); } diff --git a/include/bitmaps/bitmap_info.h b/include/bitmaps/bitmap_info.h index 2f8c58535f..e8e590fde7 100644 --- a/include/bitmaps/bitmap_info.h +++ b/include/bitmaps/bitmap_info.h @@ -28,6 +28,8 @@ #include #include +#include // wxT + struct BITMAP_INFO { BITMAPS id; diff --git a/include/bitmaps/bitmap_types.h b/include/bitmaps/bitmap_types.h index 9a2a0d5f9e..277bcfb9ac 100644 --- a/include/bitmaps/bitmap_types.h +++ b/include/bitmaps/bitmap_types.h @@ -32,12 +32,18 @@ class wxBitmap; // only to define wxBitmap class EDA_DRAW_FRAME; class wxWindow; +class wxString; struct BITMAP_OPAQUE; class BITMAP_STORE; enum class BITMAPS : unsigned int; -#include // wxBitmapType +enum class BITMAP_TYPE +{ + PNG, + JPG, + BMP +}; 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. */ bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName, - wxBitmapType aBitmapType = wxBITMAP_TYPE_PNG ); + BITMAP_TYPE aBitmapType = BITMAP_TYPE::PNG ); #endif // BITMAP_TYPES_H_