diff --git a/build/cmake/samples/CMakeLists.txt b/build/cmake/samples/CMakeLists.txt
index b796023b2f..a28eee226f 100644
--- a/build/cmake/samples/CMakeLists.txt
+++ b/build/cmake/samples/CMakeLists.txt
@@ -70,7 +70,7 @@ endif()
wx_add_sample(image image.cpp canvas.cpp canvas.h cursor_png.c RES image.rc
DATA horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm
horse_ag.pnm horse_rg.pnm horse.tif horse.tga horse.xpm horse.cur
- horse.ico horse3.ani smile.xbm toucan.png cmyk.jpg cursor.png
+ horse.ico horse3.ani horse.svg smile.xbm toucan.png cmyk.jpg cursor.png
NAME imagesample DEPENDS wxUSE_IMAGE)
foreach(lang ar bg cs de fr it ka pl ru sv ja ja_JP.EUC-JP)
list(APPEND INTERNAT_DATA_FILES ${lang}/internat.po ${lang}/internat.mo)
diff --git a/samples/image/Makefile.in b/samples/image/Makefile.in
index 8a4593f697..50defa89ce 100644
--- a/samples/image/Makefile.in
+++ b/samples/image/Makefile.in
@@ -186,7 +186,7 @@ image$(EXEEXT): $(IMAGE_OBJECTS) $(__image___win32rc)
data:
@mkdir -p .
- @for f in horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse_ag.pnm horse_rg.pnm horse.tif horse.tga horse.xpm horse.cur horse.ico horse3.ani smile.xbm toucan.png cmyk.jpg cursor.png; do \
+ @for f in horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse_ag.pnm horse_rg.pnm horse.tif horse.tga horse.xpm horse.cur horse.ico horse3.ani horse.svg smile.xbm toucan.png cmyk.jpg cursor.png; do \
if test ! -f ./$$f -a ! -d ./$$f ; \
then x=yep ; \
else x=`find $(srcdir)/$$f -newer ./$$f -print` ; \
diff --git a/samples/image/horse.svg b/samples/image/horse.svg
new file mode 100644
index 0000000000..2483101380
--- /dev/null
+++ b/samples/image/horse.svg
@@ -0,0 +1,8 @@
+
+
diff --git a/samples/image/image.bkl b/samples/image/image.bkl
index 4cfbd8ad36..84fe4f82b9 100644
--- a/samples/image/image.bkl
+++ b/samples/image/image.bkl
@@ -21,7 +21,7 @@
horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse_ag.pnm horse_rg.pnm
- horse.tif horse.tga horse.xpm horse.cur horse.ico horse3.ani
+ horse.tif horse.tga horse.xpm horse.cur horse.ico horse3.ani horse.svg
smile.xbm toucan.png cmyk.jpg cursor.png
diff --git a/samples/image/image.cpp b/samples/image/image.cpp
index ec3b894310..64dfb8aa0c 100644
--- a/samples/image/image.cpp
+++ b/samples/image/image.cpp
@@ -78,6 +78,9 @@ public:
void OnAbout( wxCommandEvent &event );
void OnNewFrame( wxCommandEvent &event );
void OnNewFrameHiDPI(wxCommandEvent&);
+#ifdef wxHAS_SVG
+ void OnNewSVGFrame(wxCommandEvent&);
+#endif // wxHAS_SVG
void OnImageInfo( wxCommandEvent &event );
void OnThumbnail( wxCommandEvent &event );
void OnFilters(wxCommandEvent& event);
@@ -967,6 +970,7 @@ enum
ID_ABOUT = wxID_ABOUT,
ID_NEW = 100,
ID_NEW_HIDPI,
+ ID_NEW_SVG,
ID_INFO,
ID_SHOWRAW,
ID_GRAPHICS,
@@ -982,6 +986,9 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU (ID_QUIT, MyFrame::OnQuit)
EVT_MENU (ID_NEW, MyFrame::OnNewFrame)
EVT_MENU (ID_NEW_HIDPI, MyFrame::OnNewFrameHiDPI)
+#ifdef wxHAS_SVG
+ EVT_MENU (ID_NEW_SVG, MyFrame::OnNewSVGFrame)
+#endif // wxHAS_SVG
EVT_MENU (ID_INFO, MyFrame::OnImageInfo)
EVT_MENU (ID_SHOWTHUMBNAIL, MyFrame::OnThumbnail)
EVT_MENU (ID_FILTERS, MyFrame::OnFilters)
@@ -1011,6 +1018,9 @@ MyFrame::MyFrame()
wxMenu *menuImage = new wxMenu;
menuImage->Append( ID_NEW, "&Show any image...\tCtrl-O");
menuImage->Append(ID_NEW_HIDPI, "Show any image as &HiDPI...\tCtrl-H");
+#ifdef wxHAS_SVG
+ menuImage->Append( ID_NEW_SVG, "Show &SVG image...\tCtrl-S");
+#endif // wxHAS_SVG
menuImage->Append( ID_INFO, "Show image &information...\tCtrl-I");
#ifdef wxHAVE_RAW_BITMAP
menuImage->AppendSeparator();
@@ -1131,6 +1141,76 @@ void MyFrame::OnNewFrameHiDPI(wxCommandEvent&)
new MyImageFrame(this, filename, image, GetContentScaleFactor());
}
+#ifdef wxHAS_SVG
+
+class MySVGFrame : public wxFrame
+{
+public:
+ explicit MySVGFrame(wxFrame* parent,
+ const wxString& filename,
+ const wxBitmapBundle& bundle)
+ : wxFrame(parent, wxID_ANY, wxString::Format("SVG image %s", filename),
+ wxDefaultPosition, wxDefaultSize,
+ wxDEFAULT_FRAME_STYLE | wxFULL_REPAINT_ON_RESIZE),
+ m_bundle(bundle)
+ {
+ Bind(wxEVT_PAINT, &MySVGFrame::OnPaint, this);
+
+ SetClientSize(bundle.GetDefaultSize());
+
+ Show();
+ }
+
+private:
+ void OnPaint(wxPaintEvent&)
+ {
+ wxPaintDC dc(this);
+
+ // Check if the bitmap needs to be re-rendered at the new size. Note
+ // that the bitmap size is in physical pixels, which can be different
+ // from the logical pixels in which the window size is expressed.
+ const wxSize sizeWin = GetClientSize();
+ const wxSize sizeBmp = sizeWin*GetContentScaleFactor();
+ if ( !m_bitmap.IsOk() || m_bitmap.GetSize() != sizeBmp )
+ {
+ m_bitmap = m_bundle.GetBitmap(sizeBmp);
+ }
+
+ // Use wxGraphicsContext if available for alpha support.
+#if wxUSE_GRAPHICS_CONTEXT
+ wxScopedPtr const
+ gc(wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(dc));
+
+ gc->DrawBitmap(m_bitmap, 0, 0, sizeWin.x, sizeWin.y);
+#else
+ dc.DrawBitmap(m_bitmap, wxPoint(0, 0), true);
+#endif
+ }
+
+ const wxBitmapBundle m_bundle;
+ wxBitmap m_bitmap;
+
+ wxDECLARE_NO_COPY_CLASS(MySVGFrame);
+};
+
+void MyFrame::OnNewSVGFrame(wxCommandEvent&)
+{
+ const wxString
+ filename = wxLoadFileSelector("SVG document", ".svg", "image", this);
+ if ( filename.empty() )
+ return;
+
+ // The default size here is completely arbitrary, as we don't know anything
+ // about the SVG being loaded.
+ wxBitmapBundle bb = wxBitmapBundle::FromSVGFile(filename, wxSize(200, 200));
+ if ( !bb.IsOk() )
+ return;
+
+ new MySVGFrame(this, filename, bb);
+}
+
+#endif // wxHAS_SVG
+
void MyFrame::OnUpdateNewFrameHiDPI(wxUpdateUIEvent& event)
{
event.Enable(GetContentScaleFactor() > 1);
diff --git a/samples/image/makefile.gcc b/samples/image/makefile.gcc
index 072b0e5a18..eff4b36106 100644
--- a/samples/image/makefile.gcc
+++ b/samples/image/makefile.gcc
@@ -223,7 +223,7 @@ $(OBJS)\image.exe: $(IMAGE_OBJECTS) $(OBJS)\image_image_rc.o
data:
if not exist $(OBJS) mkdir $(OBJS)
- for %%f in (horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse_ag.pnm horse_rg.pnm horse.tif horse.tga horse.xpm horse.cur horse.ico horse3.ani smile.xbm toucan.png cmyk.jpg cursor.png) do if not exist $(OBJS)\%%f copy .\%%f $(OBJS)
+ for %%f in (horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse_ag.pnm horse_rg.pnm horse.tif horse.tga horse.xpm horse.cur horse.ico horse3.ani horse.svg smile.xbm toucan.png cmyk.jpg cursor.png) do if not exist $(OBJS)\%%f copy .\%%f $(OBJS)
$(OBJS)\image_image.o: ./image.cpp
$(CXX) -c -o $@ $(IMAGE_CXXFLAGS) $(CPPDEPS) $<
diff --git a/samples/image/makefile.vc b/samples/image/makefile.vc
index ebea4d430a..ed81f0e56f 100644
--- a/samples/image/makefile.vc
+++ b/samples/image/makefile.vc
@@ -568,7 +568,7 @@ $(OBJS)\image.exe: $(IMAGE_OBJECTS) $(OBJS)\image_image.res
data:
if not exist $(OBJS) mkdir $(OBJS)
- for %f in (horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse_ag.pnm horse_rg.pnm horse.tif horse.tga horse.xpm horse.cur horse.ico horse3.ani smile.xbm toucan.png cmyk.jpg cursor.png) do if not exist $(OBJS)\%f copy .\%f $(OBJS)
+ for %f in (horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse_ag.pnm horse_rg.pnm horse.tif horse.tga horse.xpm horse.cur horse.ico horse3.ani horse.svg smile.xbm toucan.png cmyk.jpg cursor.png) do if not exist $(OBJS)\%f copy .\%f $(OBJS)
$(OBJS)\image_image.obj: .\image.cpp
$(CXX) /c /nologo /TP /Fo$@ $(IMAGE_CXXFLAGS) .\image.cpp