4 * Author: Robert Roebling
6 * Copyright: (C) 1998, Robert Roebling
10 // For compilers that support precompilation, includes "wx/wx.h".
11 #include "wx/wxprec.h"
23 #include "wx/mstream.h"
24 #include "wx/wfstream.h"
25 #include "wx/quantize.h"
29 #if !defined(__WINDOWS__) || wxUSE_XPM_IN_MSW
41 class MyCanvas
: public wxScrolledWindow
45 MyCanvas( wxWindow
*parent
, wxWindowID
, const wxPoint
&pos
, const wxSize
&size
);
47 void OnPaint( wxPaintEvent
&event
);
48 void CreateAntiAliasedBitmap();
50 wxBitmap
*my_horse_png
;
51 wxBitmap
*my_horse_jpeg
;
52 wxBitmap
*my_horse_gif
;
53 wxBitmap
*my_horse_bmp
;
54 wxBitmap
*my_horse_bmp2
;
55 wxBitmap
*my_horse_pcx
;
56 wxBitmap
*my_horse_pnm
;
57 wxBitmap
*my_horse_tiff
;
58 wxBitmap
*my_horse_xpm
;
59 wxBitmap
*my_horse_ico32
;
60 wxBitmap
*my_horse_ico16
;
61 wxBitmap
*my_horse_ico
;
62 wxBitmap
*my_horse_cur
;
63 wxBitmap
*my_horse_ani
;
65 wxBitmap
*my_smile_xbm
;
73 wxBitmap m_bmpSmileXpm
;
74 wxIcon m_iconSmileXpm
;
77 DECLARE_DYNAMIC_CLASS(MyCanvas
)
82 const int nChoices
= 8 ;
83 static const wxString bppchoices
[nChoices
] =
89 _T("8 bpp greyscale"),
91 _T("8 bpp own palette"),
95 static const int bppvalues
[nChoices
] =
110 class MyFrame
: public wxFrame
115 void OnAbout( wxCommandEvent
&event
);
116 void OnNewFrame( wxCommandEvent
&event
);
117 void OnQuit( wxCommandEvent
&event
);
122 DECLARE_DYNAMIC_CLASS(MyFrame
)
123 DECLARE_EVENT_TABLE()
126 class MyImageFrame
: public wxFrame
129 MyImageFrame(wxFrame
*parent
, const wxBitmap
& bitmap
)
130 : wxFrame(parent
, -1, _T("Double click to save"),
131 wxDefaultPosition
, wxDefaultSize
,
132 wxCAPTION
| wxSYSTEM_MENU
),
135 SetClientSize(bitmap
.GetWidth(), bitmap
.GetHeight());
138 void OnPaint(wxPaintEvent
& WXUNUSED(event
))
140 wxPaintDC
dc( this );
141 //TRUE for masked images
142 dc
.DrawBitmap( m_bitmap
, 0, 0, TRUE
);
145 void OnSave(wxCommandEvent
& WXUNUSED(event
))
147 wxImage image
= m_bitmap
.ConvertToImage();
149 int bppselection
= wxGetSingleChoiceIndex(_T("Set BMP BPP"),
154 if ( bppselection
== -1 )
160 image
.SetOption(wxIMAGE_OPTION_BMP_FORMAT
, bppvalues
[bppselection
]);
162 wxString deffilename
= bppchoices
[bppselection
];
163 deffilename
.Replace(wxT(" "), wxT("_"));
164 deffilename
+= wxT(".bmp");
165 wxString savefilename
= wxFileSelector( wxT("Save Image"),
168 (const wxChar
*)NULL
,
169 wxT("BMP files (*.bmp)|*.bmp|")
170 wxT("PNG files (*.png)|*.png|")
171 wxT("JPEG files (*.jpg)|*.jpg|")
172 wxT("GIF files (*.gif)|*.gif|")
173 wxT("TIFF files (*.tif)|*.tif|")
174 wxT("PCX files (*.pcx)|*.pcx|")
175 wxT("ICO files (*.ico)|*.ico|")
176 wxT("CUR files (*.cur)|*.cur"),
179 if ( savefilename
.empty() )
182 if ( image
.GetOptionInt(wxIMAGE_OPTION_BMP_FORMAT
) == wxBMP_8BPP_PALETTE
)
184 unsigned char *cmap
= new unsigned char [256];
185 for ( int i
= 0; i
< 256; i
++ )
187 image
.SetPalette(wxPalette(256, cmap
, cmap
, cmap
));
193 wxString extension
= savefilename
.AfterLast('.').Lower();
195 if (extension
== _T("cur"))
197 image
.Rescale(32,32);
198 image
.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X
, 0);
199 image
.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y
, 0);
200 // This shows how you can save an image with explicitly
201 // specified image format:
202 loaded
= image
.SaveFile(savefilename
, wxBITMAP_TYPE_CUR
);
206 // This one guesses image format from filename extension
207 // (it may fail if the extension is not recognized):
208 loaded
= image
.SaveFile(savefilename
);
212 wxMessageBox(_T("No handler for this file type."),
213 _T("File was not saved"),
214 wxOK
|wxCENTRE
, this);
220 DECLARE_EVENT_TABLE()
225 class MyApp
: public wxApp
228 virtual bool OnInit();
237 IMPLEMENT_DYNAMIC_CLASS(MyCanvas
, wxScrolledWindow
)
239 BEGIN_EVENT_TABLE(MyImageFrame
, wxFrame
)
240 EVT_PAINT(MyImageFrame::OnPaint
)
241 EVT_LEFT_DCLICK(MyImageFrame::OnSave
)
244 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
245 EVT_PAINT(MyCanvas::OnPaint
)
248 MyCanvas::MyCanvas( wxWindow
*parent
, wxWindowID id
,
249 const wxPoint
&pos
, const wxSize
&size
)
250 : wxScrolledWindow( parent
, id
, pos
, size
, wxSUNKEN_BORDER
)
251 #if !defined(__WINDOWS__) || wxUSE_XPM_IN_MSW
252 , m_bmpSmileXpm((const char **) smile_xpm
)
253 , m_iconSmileXpm((const char **) smile_xpm
)
256 my_horse_png
= (wxBitmap
*) NULL
;
257 my_horse_jpeg
= (wxBitmap
*) NULL
;
258 my_horse_gif
= (wxBitmap
*) NULL
;
259 my_horse_bmp
= (wxBitmap
*) NULL
;
260 my_horse_bmp2
= (wxBitmap
*) NULL
;
261 my_horse_pcx
= (wxBitmap
*) NULL
;
262 my_horse_pnm
= (wxBitmap
*) NULL
;
263 my_horse_tiff
= (wxBitmap
*) NULL
;
264 my_horse_xpm
= (wxBitmap
*) NULL
;
265 my_horse_ico32
= (wxBitmap
*) NULL
;
266 my_horse_ico16
= (wxBitmap
*) NULL
;
267 my_horse_ico
= (wxBitmap
*) NULL
;
268 my_horse_cur
= (wxBitmap
*) NULL
;
269 my_horse_ani
= (wxBitmap
*) NULL
;
271 my_smile_xbm
= (wxBitmap
*) NULL
;
272 my_square
= (wxBitmap
*) NULL
;
273 my_anti
= (wxBitmap
*) NULL
;
277 SetBackgroundColour(* wxWHITE
);
279 wxBitmap
bitmap( 100, 100 );
282 dc
.SelectObject( bitmap
);
283 dc
.SetBrush( wxBrush( wxT("orange"), wxSOLID
) );
284 dc
.SetPen( *wxBLACK_PEN
);
285 dc
.DrawRectangle( 0, 0, 100, 100 );
286 dc
.SetBrush( *wxWHITE_BRUSH
);
287 dc
.DrawRectangle( 20, 20, 60, 60 );
288 dc
.SelectObject( wxNullBitmap
);
290 // try to find the directory with our images
292 if ( wxFile::Exists(wxT("./horse.png")) )
294 else if ( wxFile::Exists(wxT("../horse.png")) )
297 wxLogWarning(wxT("Can't find image files in either '.' or '..'!"));
299 wxImage image
= bitmap
.ConvertToImage();
302 if ( !image
.SaveFile( dir
+ _T("test.png"), wxBITMAP_TYPE_PNG
))
303 wxLogError(wxT("Can't save file"));
307 image
.LoadFile( dir
+ _T("test.png") );
308 my_square
= new wxBitmap( image
);
312 if ( !image
.LoadFile( dir
+ _T("horse.png")) )
313 wxLogError(wxT("Can't load PNG image"));
315 my_horse_png
= new wxBitmap( image
);
316 #endif // wxUSE_LIBPNG
321 if ( !image
.LoadFile( dir
+ _T("horse.jpg")) )
322 wxLogError(wxT("Can't load JPG image"));
324 my_horse_jpeg
= new wxBitmap( image
);
325 #endif // wxUSE_LIBJPEG
330 if ( !image
.LoadFile( dir
+ _T("horse.gif" )) )
331 wxLogError(wxT("Can't load GIF image"));
333 my_horse_gif
= new wxBitmap( image
);
339 if ( !image
.LoadFile( dir
+ _T("horse.pcx"), wxBITMAP_TYPE_PCX
) )
340 wxLogError(wxT("Can't load PCX image"));
342 my_horse_pcx
= new wxBitmap( image
);
347 if ( !image
.LoadFile( dir
+ _T("horse.bmp"), wxBITMAP_TYPE_BMP
) )
348 wxLogError(wxT("Can't load BMP image"));
350 my_horse_bmp
= new wxBitmap( image
);
355 if ( !image
.LoadFile( dir
+ _T("horse.xpm"), wxBITMAP_TYPE_XPM
) )
356 wxLogError(wxT("Can't load XPM image"));
358 my_horse_xpm
= new wxBitmap( image
);
360 if ( !image
.SaveFile( dir
+ _T("test.xpm"), wxBITMAP_TYPE_XPM
))
361 wxLogError(wxT("Can't save file"));
367 if ( !image
.LoadFile( dir
+ _T("horse.pnm"), wxBITMAP_TYPE_PNM
) )
368 wxLogError(wxT("Can't load PNM image"));
370 my_horse_pnm
= new wxBitmap( image
);
376 if ( !image
.LoadFile( dir
+ _T("horse.tif"), wxBITMAP_TYPE_TIF
) )
377 wxLogError(wxT("Can't load TIFF image"));
379 my_horse_tiff
= new wxBitmap( image
);
382 CreateAntiAliasedBitmap();
384 my_smile_xbm
= new wxBitmap( (const char*)smile_bits
, smile_width
,
387 #if !defined(__WINDOWS__) || wxUSE_XPM_IN_MSW
388 // demonstrates XPM automatically using the mask when saving
389 if ( m_bmpSmileXpm
.Ok() )
390 m_bmpSmileXpm
.SaveFile(_T("saved.xpm"), wxBITMAP_TYPE_XPM
);
396 if ( !image
.LoadFile( dir
+ _T("horse.ico"), wxBITMAP_TYPE_ICO
, 0 ) )
397 wxLogError(wxT("Can't load first ICO image"));
399 my_horse_ico32
= new wxBitmap( image
);
403 if ( !image
.LoadFile( dir
+ _T("horse.ico"), wxBITMAP_TYPE_ICO
, 1 ) )
404 wxLogError(wxT("Can't load second ICO image"));
406 my_horse_ico16
= new wxBitmap( image
);
410 if ( !image
.LoadFile( dir
+ _T("horse.ico") ) )
411 wxLogError(wxT("Can't load best ICO image"));
413 my_horse_ico
= new wxBitmap( image
);
417 if ( !image
.LoadFile( dir
+ _T("horse.cur"), wxBITMAP_TYPE_CUR
) )
418 wxLogError(wxT("Can't load best ICO image"));
421 my_horse_cur
= new wxBitmap( image
);
422 xH
= 30 + image
.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X
) ;
423 yH
= 2420 + image
.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y
) ;
426 m_ani_images
= wxImage::GetImageCount ( dir
+ _T("horse3.ani"), wxBITMAP_TYPE_ANI
);
428 wxLogError(wxT("No ANI-format images found"));
430 my_horse_ani
= new wxBitmap
[m_ani_images
];
432 for (i
=0; i
< m_ani_images
; i
++)
435 if (!image
.LoadFile( dir
+ _T("horse3.ani"), wxBITMAP_TYPE_ANI
, i
))
437 wxString tmp
= wxT("Can't load image number ");
442 my_horse_ani
[i
] = wxBitmap( image
);
450 // test image loading from stream
451 wxFile
file(dir
+ _T("horse.bmp"));
452 off_t len
= file
.Length();
453 void *data
= malloc(len
);
454 if ( file
.Read(data
, len
) != len
)
455 wxLogError(_T("Reading bitmap file failed"));
458 wxMemoryInputStream
mis(data
, len
);
459 if ( !image
.LoadFile(mis
) )
460 wxLogError(wxT("Can't load BMP image from stream"));
462 my_horse_bmp2
= new wxBitmap( image
);
468 MyCanvas::~MyCanvas()
472 delete my_horse_jpeg
;
475 delete my_horse_bmp2
;
477 delete my_horse_tiff
;
479 delete my_horse_ico32
;
480 delete my_horse_ico16
;
483 delete [] my_horse_ani
;
489 void MyCanvas::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
491 wxPaintDC
dc( this );
494 dc
.DrawText( _T("Loaded image"), 30, 10 );
495 if (my_square
&& my_square
->Ok()) dc
.DrawBitmap( *my_square
, 30, 30 );
497 dc
.DrawText( _T("Drawn directly"), 150, 10 );
498 dc
.SetBrush( wxBrush( wxT("orange"), wxSOLID
) );
499 dc
.SetPen( *wxBLACK_PEN
);
500 dc
.DrawRectangle( 150, 30, 100, 100 );
501 dc
.SetBrush( *wxWHITE_BRUSH
);
502 dc
.DrawRectangle( 170, 50, 60, 60 );
504 if (my_anti
&& my_anti
->Ok())
505 dc
.DrawBitmap( *my_anti
, 280, 30 );
507 dc
.DrawText( _T("PNG handler"), 30, 135 );
508 if (my_horse_png
&& my_horse_png
->Ok())
510 dc
.DrawBitmap( *my_horse_png
, 30, 150 );
511 wxRect
rect(0,0,100,100);
512 wxBitmap
sub( my_horse_png
->GetSubBitmap(rect
) );
513 dc
.DrawText( _T("GetSubBitmap()"), 280, 190 );
514 dc
.DrawBitmap( sub
, 280, 210 );
517 dc
.DrawText( _T("JPEG handler"), 30, 365 );
518 if (my_horse_jpeg
&& my_horse_jpeg
->Ok())
519 dc
.DrawBitmap( *my_horse_jpeg
, 30, 380 );
521 dc
.DrawText( _T("GIF handler"), 30, 595 );
522 if (my_horse_gif
&& my_horse_gif
->Ok())
523 dc
.DrawBitmap( *my_horse_gif
, 30, 610 );
525 dc
.DrawText( _T("PCX handler"), 30, 825 );
526 if (my_horse_pcx
&& my_horse_pcx
->Ok())
527 dc
.DrawBitmap( *my_horse_pcx
, 30, 840 );
529 dc
.DrawText( _T("BMP handler"), 30, 1055 );
530 if (my_horse_bmp
&& my_horse_bmp
->Ok())
531 dc
.DrawBitmap( *my_horse_bmp
, 30, 1070 );
533 dc
.DrawText( _T("BMP read from memory"), 280, 1055 );
534 if (my_horse_bmp2
&& my_horse_bmp2
->Ok())
535 dc
.DrawBitmap( *my_horse_bmp2
, 280, 1070 );
537 dc
.DrawText( _T("PNM handler"), 30, 1285 );
538 if (my_horse_pnm
&& my_horse_pnm
->Ok())
539 dc
.DrawBitmap( *my_horse_pnm
, 30, 1300 );
541 dc
.DrawText( _T("TIFF handler"), 30, 1515 );
542 if (my_horse_tiff
&& my_horse_tiff
->Ok())
543 dc
.DrawBitmap( *my_horse_tiff
, 30, 1530 );
545 dc
.DrawText( _T("XPM handler"), 30, 1745 );
546 if (my_horse_xpm
&& my_horse_xpm
->Ok())
547 dc
.DrawBitmap( *my_horse_xpm
, 30, 1760 );
550 if (my_smile_xbm
&& my_smile_xbm
->Ok())
552 dc
.DrawText( _T("XBM bitmap"), 30, 1975 );
553 dc
.DrawText( _T("(green on red)"), 30, 1990 );
554 dc
.SetTextForeground( _T("GREEN") );
555 dc
.SetTextBackground( _T("RED") );
556 dc
.DrawBitmap( *my_smile_xbm
, 30, 2010 );
558 dc
.SetTextForeground( wxT("BLACK") );
559 dc
.DrawText( _T("After wxImage conversion"), 150, 1975 );
560 dc
.DrawText( _T("(red on white)"), 150, 1990 );
561 dc
.SetTextForeground( wxT("RED") );
562 wxImage i
= my_smile_xbm
->ConvertToImage();
563 i
.SetMaskColour( 255, 255, 255 );
565 wxRED_PEN
->GetColour().Red(),
566 wxRED_PEN
->GetColour().Green(),
567 wxRED_PEN
->GetColour().Blue() );
568 dc
.DrawBitmap( wxBitmap(i
), 150, 2010, TRUE
);
569 dc
.SetTextForeground( wxT("BLACK") );
573 wxBitmap
mono( 60,50,1 );
575 memdc
.SelectObject( mono
);
576 memdc
.SetPen( *wxBLACK_PEN
);
577 memdc
.SetBrush( *wxWHITE_BRUSH
);
578 memdc
.DrawRectangle( 0,0,60,50 );
579 memdc
.SetTextForeground( *wxBLACK
);
580 memdc
.DrawText( _T("Hi!"), 5, 5 );
581 memdc
.SetBrush( *wxBLACK_BRUSH
);
582 memdc
.DrawRectangle( 33,5,20,20 );
583 memdc
.SetPen( *wxRED_PEN
);
584 memdc
.DrawLine( 5, 42, 50, 42 );
585 memdc
.SelectObject( wxNullBitmap
);
589 dc
.DrawText( _T("Mono bitmap"), 30, 2095 );
590 dc
.DrawText( _T("(red on green)"), 30, 2110 );
591 dc
.SetTextForeground( wxT("RED") );
592 dc
.SetTextBackground( wxT("GREEN") );
593 dc
.DrawBitmap( mono
, 30, 2130 );
595 dc
.SetTextForeground( wxT("BLACK") );
596 dc
.DrawText( _T("After wxImage conversion"), 150, 2095 );
597 dc
.DrawText( _T("(red on white)"), 150, 2110 );
598 dc
.SetTextForeground( wxT("RED") );
599 wxImage i
= mono
.ConvertToImage();
600 i
.SetMaskColour( 255,255,255 );
602 wxRED_PEN
->GetColour().Red(),
603 wxRED_PEN
->GetColour().Green(),
604 wxRED_PEN
->GetColour().Blue() );
605 dc
.DrawBitmap( wxBitmap(i
), 150, 2130, TRUE
);
606 dc
.SetTextForeground( wxT("BLACK") );
609 dc
.DrawText(_T("XPM bitmap"), 30, 2230);
610 if ( m_bmpSmileXpm
.Ok() )
612 dc
.DrawBitmap(m_bmpSmileXpm
, 30, 2250, TRUE
);
615 dc
.DrawText(_T("XPM icon"), 150, 2230);
616 if ( m_iconSmileXpm
.Ok() )
618 dc
.DrawIcon(m_iconSmileXpm
, 150, 2250);
621 dc
.DrawText( _T("ICO handler (1st image)"), 30, 2290 );
622 if (my_horse_ico32
&& my_horse_ico32
->Ok())
623 dc
.DrawBitmap( *my_horse_ico32
, 30, 2330, TRUE
);
625 dc
.DrawText( _T("ICO handler (2nd image)"), 230, 2290 );
626 if (my_horse_ico16
&& my_horse_ico16
->Ok())
627 dc
.DrawBitmap( *my_horse_ico16
, 230, 2330, TRUE
);
629 dc
.DrawText( _T("ICO handler (best image)"), 430, 2290 );
630 if (my_horse_ico
&& my_horse_ico
->Ok())
631 dc
.DrawBitmap( *my_horse_ico
, 430, 2330, TRUE
);
633 dc
.DrawText( _T("CUR handler"), 30, 2390 );
634 if (my_horse_cur
&& my_horse_cur
->Ok())
636 dc
.DrawBitmap( *my_horse_cur
, 30, 2420, TRUE
);
637 dc
.SetPen (*wxRED_PEN
);
638 dc
.DrawLine (xH
-10,yH
,xH
+10,yH
);
639 dc
.DrawLine (xH
,yH
-10,xH
,yH
+10);
641 dc
.DrawText( _T("ANI handler"), 230, 2390 );
643 for (i
=0; i
< m_ani_images
; i
++)
644 if (my_horse_ani
[i
].Ok())
646 dc
.DrawBitmap( my_horse_ani
[i
], 230 + i
* 2 * my_horse_ani
[i
].GetWidth() , 2420, TRUE
);
650 void MyCanvas::CreateAntiAliasedBitmap()
652 wxBitmap
bitmap( 300, 300 );
656 dc
.SelectObject( bitmap
);
660 dc
.SetFont( wxFont( 24, wxDECORATIVE
, wxNORMAL
, wxNORMAL
) );
661 dc
.SetTextForeground( wxT("RED") );
662 dc
.DrawText( _T("This is anti-aliased Text."), 20, 20 );
663 dc
.DrawText( _T("And a Rectangle."), 20, 60 );
665 dc
.SetBrush( *wxRED_BRUSH
);
666 dc
.SetPen( *wxTRANSPARENT_PEN
);
667 dc
.DrawRoundedRectangle( 20, 100, 200, 180, 20 );
669 wxImage original
= bitmap
.ConvertToImage();
670 wxImage
anti( 150, 150 );
672 /* This is quite slow, but safe. Use wxImage::GetData() for speed instead. */
674 for (int y
= 1; y
< 149; y
++)
675 for (int x
= 1; x
< 149; x
++)
677 int red
= original
.GetRed( x
*2, y
*2 ) +
678 original
.GetRed( x
*2-1, y
*2 ) +
679 original
.GetRed( x
*2, y
*2+1 ) +
680 original
.GetRed( x
*2+1, y
*2+1 );
683 int green
= original
.GetGreen( x
*2, y
*2 ) +
684 original
.GetGreen( x
*2-1, y
*2 ) +
685 original
.GetGreen( x
*2, y
*2+1 ) +
686 original
.GetGreen( x
*2+1, y
*2+1 );
689 int blue
= original
.GetBlue( x
*2, y
*2 ) +
690 original
.GetBlue( x
*2-1, y
*2 ) +
691 original
.GetBlue( x
*2, y
*2+1 ) +
692 original
.GetBlue( x
*2+1, y
*2+1 );
694 anti
.SetRGB( x
, y
, red
, green
, blue
);
696 my_anti
= new wxBitmap(anti
);
701 const int ID_QUIT
= 108;
702 const int ID_ABOUT
= 109;
703 const int ID_NEW
= 110;
705 IMPLEMENT_DYNAMIC_CLASS( MyFrame
, wxFrame
)
707 BEGIN_EVENT_TABLE(MyFrame
,wxFrame
)
708 EVT_MENU (ID_ABOUT
, MyFrame::OnAbout
)
709 EVT_MENU (ID_QUIT
, MyFrame::OnQuit
)
710 EVT_MENU (ID_NEW
, MyFrame::OnNewFrame
)
714 : wxFrame( (wxFrame
*)NULL
, -1, _T("wxImage sample"),
715 wxPoint(20,20), wxSize(470,360) )
717 wxMenu
*file_menu
= new wxMenu();
718 file_menu
->Append( ID_NEW
, _T("&Show image..."));
719 file_menu
->AppendSeparator();
720 file_menu
->Append( ID_ABOUT
, _T("&About..."));
721 file_menu
->AppendSeparator();
722 file_menu
->Append( ID_QUIT
, _T("E&xit"));
724 wxMenuBar
*menu_bar
= new wxMenuBar();
725 menu_bar
->Append(file_menu
, _T("&File"));
727 SetMenuBar( menu_bar
);
730 int widths
[] = { -1, 100 };
731 SetStatusWidths( 2, widths
);
733 m_canvas
= new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) );
735 // 500 width * 2500 height
736 m_canvas
->SetScrollbars( 10, 10, 50, 250 );
739 void MyFrame::OnQuit( wxCommandEvent
&WXUNUSED(event
) )
744 void MyFrame::OnAbout( wxCommandEvent
&WXUNUSED(event
) )
746 (void)wxMessageBox( _T("wxImage demo\n")
747 _T("Robert Roebling (c) 1998,2000"),
748 _T("About wxImage Demo"), wxICON_INFORMATION
| wxOK
);
751 void MyFrame::OnNewFrame( wxCommandEvent
&WXUNUSED(event
) )
753 wxString filename
= wxFileSelector(_T("Select image file"));
758 if ( !image
.LoadFile(filename
) )
760 wxLogError(_T("Couldn't load image from '%s'."), filename
.c_str());
765 (new MyImageFrame(this, wxBitmap(image
)))->Show();
768 //-----------------------------------------------------------------------------
770 //-----------------------------------------------------------------------------
775 wxImage::AddHandler( new wxPNGHandler
);
779 wxImage::AddHandler( new wxJPEGHandler
);
783 wxImage::AddHandler( new wxTIFFHandler
);
787 wxImage::AddHandler( new wxGIFHandler
);
791 wxImage::AddHandler( new wxPCXHandler
);
795 wxImage::AddHandler( new wxPNMHandler
);
799 wxImage::AddHandler( new wxXPMHandler
);
803 wxImage::AddHandler( new wxICOHandler
);
804 wxImage::AddHandler( new wxCURHandler
);
805 wxImage::AddHandler( new wxANIHandler
);
808 wxFrame
*frame
= new MyFrame();