From dc1dbfc6403ef5f3b97e410c5e74f702a4809b93 Mon Sep 17 00:00:00 2001 From: Ron Lee Date: Tue, 14 Dec 1999 16:53:41 +0000 Subject: [PATCH] added XBM example to image sample git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4940 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/image/Makefile.in | 2 +- samples/image/image.cpp | 21 +++++++++++++++++++-- samples/image/smile.xbm | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 samples/image/smile.xbm diff --git a/samples/image/Makefile.in b/samples/image/Makefile.in index 46f4365bbb..963a10a988 100644 --- a/samples/image/Makefile.in +++ b/samples/image/Makefile.in @@ -13,7 +13,7 @@ top_srcdir = @top_srcdir@ top_builddir = ../.. program_dir = samples/image -DATAFILES = horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse.tif +DATAFILES = horse.png horse.jpg horse.bmp horse.gif horse.pcx horse.pnm horse.tif smile.xbm PROGRAM=image diff --git a/samples/image/image.cpp b/samples/image/image.cpp index df33af7c8f..c9985fad5e 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -22,6 +22,8 @@ #include "wx/file.h" +#include "smile.xbm" + // derived classes class MyFrame; @@ -45,6 +47,7 @@ public: wxBitmap *my_horse_pcx; wxBitmap *my_horse_pnm; wxBitmap *my_horse_tiff; + wxBitmap *my_smile_xbm; wxBitmap *my_square; wxBitmap *my_anti; @@ -101,6 +104,7 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id, my_horse_pcx = (wxBitmap*) NULL; my_horse_pnm = (wxBitmap*) NULL; my_horse_tiff = (wxBitmap*) NULL; + my_smile_xbm = (wxBitmap*) NULL; my_square = (wxBitmap*) NULL; my_anti = (wxBitmap*) NULL; @@ -176,6 +180,9 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id, my_square = new wxBitmap( image.ConvertToBitmap() ); CreateAntiAliasedBitmap(); + + my_smile_xbm = new wxBitmap( (const char*)smile_bits, smile_width, + smile_height, 1 ); } MyCanvas::~MyCanvas() @@ -187,6 +194,7 @@ MyCanvas::~MyCanvas() delete my_horse_bmp; delete my_horse_pcx; delete my_horse_tiff; + delete my_smile_xbm; delete my_square; delete my_anti; } @@ -226,6 +234,15 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) dc.DrawText( "TIFF handler", 30, 1515 ); if (my_horse_tiff && my_horse_tiff->Ok()) dc.DrawBitmap( *my_horse_pnm, 30, 1530 ); + + dc.DrawText( "XBM bitmap", 30, 1745 ); + dc.SetPen( *wxRED_PEN ); + if (my_smile_xbm && my_smile_xbm->Ok()) { + dc.DrawBitmap( *my_smile_xbm, 30, 1760 ); + dc.DrawText( "..after wxImage conversion", 150, 1745 ); + wxImage i( *my_smile_xbm ); + dc.DrawBitmap( i.ConvertToBitmap(), 150, 1760 ); + } } void MyCanvas::CreateAntiAliasedBitmap() @@ -308,8 +325,8 @@ MyFrame::MyFrame() m_canvas = new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) ); - // 500 width * 1300 height - m_canvas->SetScrollbars( 10, 10, 50, 180 ); + // 500 width * 1900 height + m_canvas->SetScrollbars( 10, 10, 50, 190 ); } void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) ) diff --git a/samples/image/smile.xbm b/samples/image/smile.xbm new file mode 100644 index 0000000000..faf0bc57df --- /dev/null +++ b/samples/image/smile.xbm @@ -0,0 +1,33 @@ +#define smile_width 50 +#define smile_height 50 +static unsigned char smile_bits[] = { + 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x03, + 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xf8, 0xff, + 0xff, 0x3f, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, + 0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, + 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0xc0, 0xff, 0xff, 0xff, + 0xff, 0x07, 0x00, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xf0, 0x3f, + 0xfe, 0xff, 0xf8, 0x1f, 0x00, 0xf8, 0x1f, 0xfc, 0x7f, 0xf0, 0x3f, 0x00, + 0xf8, 0x0f, 0xf8, 0x3f, 0xe0, 0x3f, 0x00, 0xfc, 0x0f, 0xf8, 0x3f, 0xe0, + 0x7f, 0x00, 0xfc, 0x0f, 0xf8, 0x3f, 0xe0, 0x7f, 0x00, 0xfe, 0x1f, 0xfc, + 0x7f, 0xf0, 0xff, 0x00, 0xfe, 0x3f, 0xfe, 0xff, 0xf8, 0xff, 0x00, 0xfe, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0xfe, 0xf9, 0xff, 0xff, 0xff, 0xff, + 0x00, 0xfe, 0xf9, 0xff, 0xff, 0xef, 0xff, 0x00, 0xfe, 0xf9, 0xff, 0xff, + 0xe7, 0xff, 0x00, 0xfe, 0xe3, 0xff, 0xff, 0xe3, 0xff, 0x00, 0xfc, 0xc7, + 0xff, 0xff, 0xf1, 0x7f, 0x00, 0xfc, 0x0f, 0xfe, 0xff, 0xf8, 0x7f, 0x00, + 0xf8, 0x1f, 0xf0, 0x3f, 0xfc, 0x3f, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0xfe, + 0x3f, 0x00, 0xf0, 0xff, 0x01, 0x00, 0xff, 0x1f, 0x00, 0xe0, 0xff, 0xff, + 0xff, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, 0x80, + 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x01, + 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, + 0x7f, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0xe0, + 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x03, 0x00, 0x00, + 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00}; -- 2.45.2