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 OnEraseBackground(wxEraseEvent
& WXUNUSED(event
))
140 // do nothing here to be able to see how transparent images are shown
143 void OnPaint(wxPaintEvent
& WXUNUSED(event
))
145 wxPaintDC
dc( this );
146 dc
.DrawBitmap( m_bitmap
, 0, 0, TRUE
/* use mask */ );
149 void OnSave(wxMouseEvent
& WXUNUSED(event
))
151 wxImage image
= m_bitmap
.ConvertToImage();
153 int bppselection
= wxGetSingleChoiceIndex(_T("Set BMP BPP"),
158 if ( bppselection
== -1 )
164 image
.SetOption(wxIMAGE_OPTION_BMP_FORMAT
, bppvalues
[bppselection
]);
166 wxString deffilename
= bppchoices
[bppselection
];
167 deffilename
.Replace(wxT(" "), wxT("_"));
168 deffilename
+= wxT(".bmp");
169 wxString savefilename
= wxFileSelector( wxT("Save Image"),
172 (const wxChar
*)NULL
,
173 wxT("BMP files (*.bmp)|*.bmp|")
174 wxT("PNG files (*.png)|*.png|")
175 wxT("JPEG files (*.jpg)|*.jpg|")
176 wxT("GIF files (*.gif)|*.gif|")
177 wxT("TIFF files (*.tif)|*.tif|")
178 wxT("PCX files (*.pcx)|*.pcx|")
179 wxT("ICO files (*.ico)|*.ico|")
180 wxT("CUR files (*.cur)|*.cur"),
183 if ( savefilename
.empty() )
186 if ( image
.GetOptionInt(wxIMAGE_OPTION_BMP_FORMAT
) == wxBMP_8BPP_PALETTE
)
188 unsigned char *cmap
= new unsigned char [256];
189 for ( int i
= 0; i
< 256; i
++ )
191 image
.SetPalette(wxPalette(256, cmap
, cmap
, cmap
));
197 wxString extension
= savefilename
.AfterLast('.').Lower();
199 if (extension
== _T("cur"))
201 image
.Rescale(32,32);
202 image
.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X
, 0);
203 image
.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y
, 0);
204 // This shows how you can save an image with explicitly
205 // specified image format:
206 loaded
= image
.SaveFile(savefilename
, wxBITMAP_TYPE_CUR
);
210 // This one guesses image format from filename extension
211 // (it may fail if the extension is not recognized):
212 loaded
= image
.SaveFile(savefilename
);
216 wxMessageBox(_T("No handler for this file type."),
217 _T("File was not saved"),
218 wxOK
|wxCENTRE
, this);
224 DECLARE_EVENT_TABLE()
229 class MyApp
: public wxApp
232 virtual bool OnInit();
241 IMPLEMENT_DYNAMIC_CLASS(MyCanvas
, wxScrolledWindow
)
243 BEGIN_EVENT_TABLE(MyImageFrame
, wxFrame
)
244 EVT_ERASE_BACKGROUND(MyImageFrame::OnEraseBackground
)
245 EVT_PAINT(MyImageFrame::OnPaint
)
246 EVT_LEFT_DCLICK(MyImageFrame::OnSave
)
249 BEGIN_EVENT_TABLE(MyCanvas
, wxScrolledWindow
)
250 EVT_PAINT(MyCanvas::OnPaint
)
253 MyCanvas::MyCanvas( wxWindow
*parent
, wxWindowID id
,
254 const wxPoint
&pos
, const wxSize
&size
)
255 : wxScrolledWindow( parent
, id
, pos
, size
, wxSUNKEN_BORDER
)
256 #if !defined(__WINDOWS__) || wxUSE_XPM_IN_MSW
257 , m_bmpSmileXpm((const char **) smile_xpm
)
258 , m_iconSmileXpm((const char **) smile_xpm
)
261 my_horse_png
= (wxBitmap
*) NULL
;
262 my_horse_jpeg
= (wxBitmap
*) NULL
;
263 my_horse_gif
= (wxBitmap
*) NULL
;
264 my_horse_bmp
= (wxBitmap
*) NULL
;
265 my_horse_bmp2
= (wxBitmap
*) NULL
;
266 my_horse_pcx
= (wxBitmap
*) NULL
;
267 my_horse_pnm
= (wxBitmap
*) NULL
;
268 my_horse_tiff
= (wxBitmap
*) NULL
;
269 my_horse_xpm
= (wxBitmap
*) NULL
;
270 my_horse_ico32
= (wxBitmap
*) NULL
;
271 my_horse_ico16
= (wxBitmap
*) NULL
;
272 my_horse_ico
= (wxBitmap
*) NULL
;
273 my_horse_cur
= (wxBitmap
*) NULL
;
274 my_horse_ani
= (wxBitmap
*) NULL
;
276 my_smile_xbm
= (wxBitmap
*) NULL
;
277 my_square
= (wxBitmap
*) NULL
;
278 my_anti
= (wxBitmap
*) NULL
;
282 SetBackgroundColour(* wxWHITE
);
284 wxBitmap
bitmap( 100, 100 );
287 dc
.SelectObject( bitmap
);
288 dc
.SetBrush( wxBrush( wxT("orange"), wxSOLID
) );
289 dc
.SetPen( *wxBLACK_PEN
);
290 dc
.DrawRectangle( 0, 0, 100, 100 );
291 dc
.SetBrush( *wxWHITE_BRUSH
);
292 dc
.DrawRectangle( 20, 20, 60, 60 );
293 dc
.SelectObject( wxNullBitmap
);
295 // try to find the directory with our images
297 if ( wxFile::Exists(wxT("./horse.png")) )
299 else if ( wxFile::Exists(wxT("../horse.png")) )
302 wxLogWarning(wxT("Can't find image files in either '.' or '..'!"));
304 wxImage image
= bitmap
.ConvertToImage();
307 if ( !image
.SaveFile( dir
+ _T("test.png"), wxBITMAP_TYPE_PNG
))
308 wxLogError(wxT("Can't save file"));
312 image
.LoadFile( dir
+ _T("test.png") );
313 my_square
= new wxBitmap( image
);
317 if ( !image
.LoadFile( dir
+ _T("horse.png")) )
318 wxLogError(wxT("Can't load PNG image"));
320 my_horse_png
= new wxBitmap( image
);
321 #endif // wxUSE_LIBPNG
326 if ( !image
.LoadFile( dir
+ _T("horse.jpg")) )
327 wxLogError(wxT("Can't load JPG image"));
329 my_horse_jpeg
= new wxBitmap( image
);
330 #endif // wxUSE_LIBJPEG
335 if ( !image
.LoadFile( dir
+ _T("horse.gif" )) )
336 wxLogError(wxT("Can't load GIF image"));
338 my_horse_gif
= new wxBitmap( image
);
344 if ( !image
.LoadFile( dir
+ _T("horse.pcx"), wxBITMAP_TYPE_PCX
) )
345 wxLogError(wxT("Can't load PCX image"));
347 my_horse_pcx
= new wxBitmap( image
);
352 if ( !image
.LoadFile( dir
+ _T("horse.bmp"), wxBITMAP_TYPE_BMP
) )
353 wxLogError(wxT("Can't load BMP image"));
355 my_horse_bmp
= new wxBitmap( image
);
360 if ( !image
.LoadFile( dir
+ _T("horse.xpm"), wxBITMAP_TYPE_XPM
) )
361 wxLogError(wxT("Can't load XPM image"));
363 my_horse_xpm
= new wxBitmap( image
);
365 if ( !image
.SaveFile( dir
+ _T("test.xpm"), wxBITMAP_TYPE_XPM
))
366 wxLogError(wxT("Can't save file"));
372 if ( !image
.LoadFile( dir
+ _T("horse.pnm"), wxBITMAP_TYPE_PNM
) )
373 wxLogError(wxT("Can't load PNM image"));
375 my_horse_pnm
= new wxBitmap( image
);
381 if ( !image
.LoadFile( dir
+ _T("horse.tif"), wxBITMAP_TYPE_TIF
) )
382 wxLogError(wxT("Can't load TIFF image"));
384 my_horse_tiff
= new wxBitmap( image
);
387 CreateAntiAliasedBitmap();
389 my_smile_xbm
= new wxBitmap( (const char*)smile_bits
, smile_width
,
392 #if !defined(__WINDOWS__) || wxUSE_XPM_IN_MSW
393 // demonstrates XPM automatically using the mask when saving
394 if ( m_bmpSmileXpm
.Ok() )
395 m_bmpSmileXpm
.SaveFile(_T("saved.xpm"), wxBITMAP_TYPE_XPM
);
401 if ( !image
.LoadFile( dir
+ _T("horse.ico"), wxBITMAP_TYPE_ICO
, 0 ) )
402 wxLogError(wxT("Can't load first ICO image"));
404 my_horse_ico32
= new wxBitmap( image
);
408 if ( !image
.LoadFile( dir
+ _T("horse.ico"), wxBITMAP_TYPE_ICO
, 1 ) )
409 wxLogError(wxT("Can't load second ICO image"));
411 my_horse_ico16
= new wxBitmap( image
);
415 if ( !image
.LoadFile( dir
+ _T("horse.ico") ) )
416 wxLogError(wxT("Can't load best ICO image"));
418 my_horse_ico
= new wxBitmap( image
);
422 if ( !image
.LoadFile( dir
+ _T("horse.cur"), wxBITMAP_TYPE_CUR
) )
423 wxLogError(wxT("Can't load best ICO image"));
426 my_horse_cur
= new wxBitmap( image
);
427 xH
= 30 + image
.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X
) ;
428 yH
= 2420 + image
.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y
) ;
431 m_ani_images
= wxImage::GetImageCount ( dir
+ _T("horse3.ani"), wxBITMAP_TYPE_ANI
);
433 wxLogError(wxT("No ANI-format images found"));
435 my_horse_ani
= new wxBitmap
[m_ani_images
];
437 for (i
=0; i
< m_ani_images
; i
++)
440 if (!image
.LoadFile( dir
+ _T("horse3.ani"), wxBITMAP_TYPE_ANI
, i
))
442 wxString tmp
= wxT("Can't load image number ");
447 my_horse_ani
[i
] = wxBitmap( image
);
455 // test image loading from stream
456 wxFile
file(dir
+ _T("horse.bmp"));
457 off_t len
= file
.Length();
458 void *data
= malloc(len
);
459 if ( file
.Read(data
, len
) != len
)
460 wxLogError(_T("Reading bitmap file failed"));
463 wxMemoryInputStream
mis(data
, len
);
464 if ( !image
.LoadFile(mis
) )
465 wxLogError(wxT("Can't load BMP image from stream"));
467 my_horse_bmp2
= new wxBitmap( image
);
473 MyCanvas::~MyCanvas()
477 delete my_horse_jpeg
;
480 delete my_horse_bmp2
;
482 delete my_horse_tiff
;
484 delete my_horse_ico32
;
485 delete my_horse_ico16
;
488 delete [] my_horse_ani
;
494 void MyCanvas::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
496 wxPaintDC
dc( this );
499 dc
.DrawText( _T("Loaded image"), 30, 10 );
500 if (my_square
&& my_square
->Ok()) dc
.DrawBitmap( *my_square
, 30, 30 );
502 dc
.DrawText( _T("Drawn directly"), 150, 10 );
503 dc
.SetBrush( wxBrush( wxT("orange"), wxSOLID
) );
504 dc
.SetPen( *wxBLACK_PEN
);
505 dc
.DrawRectangle( 150, 30, 100, 100 );
506 dc
.SetBrush( *wxWHITE_BRUSH
);
507 dc
.DrawRectangle( 170, 50, 60, 60 );
509 if (my_anti
&& my_anti
->Ok())
510 dc
.DrawBitmap( *my_anti
, 280, 30 );
512 dc
.DrawText( _T("PNG handler"), 30, 135 );
513 if (my_horse_png
&& my_horse_png
->Ok())
515 dc
.DrawBitmap( *my_horse_png
, 30, 150 );
516 wxRect
rect(0,0,100,100);
517 wxBitmap
sub( my_horse_png
->GetSubBitmap(rect
) );
518 dc
.DrawText( _T("GetSubBitmap()"), 280, 190 );
519 dc
.DrawBitmap( sub
, 280, 210 );
522 dc
.DrawText( _T("JPEG handler"), 30, 365 );
523 if (my_horse_jpeg
&& my_horse_jpeg
->Ok())
524 dc
.DrawBitmap( *my_horse_jpeg
, 30, 380 );
526 dc
.DrawText( _T("GIF handler"), 30, 595 );
527 if (my_horse_gif
&& my_horse_gif
->Ok())
528 dc
.DrawBitmap( *my_horse_gif
, 30, 610 );
530 dc
.DrawText( _T("PCX handler"), 30, 825 );
531 if (my_horse_pcx
&& my_horse_pcx
->Ok())
532 dc
.DrawBitmap( *my_horse_pcx
, 30, 840 );
534 dc
.DrawText( _T("BMP handler"), 30, 1055 );
535 if (my_horse_bmp
&& my_horse_bmp
->Ok())
536 dc
.DrawBitmap( *my_horse_bmp
, 30, 1070 );
538 dc
.DrawText( _T("BMP read from memory"), 280, 1055 );
539 if (my_horse_bmp2
&& my_horse_bmp2
->Ok())
540 dc
.DrawBitmap( *my_horse_bmp2
, 280, 1070 );
542 dc
.DrawText( _T("PNM handler"), 30, 1285 );
543 if (my_horse_pnm
&& my_horse_pnm
->Ok())
544 dc
.DrawBitmap( *my_horse_pnm
, 30, 1300 );
546 dc
.DrawText( _T("TIFF handler"), 30, 1515 );
547 if (my_horse_tiff
&& my_horse_tiff
->Ok())
548 dc
.DrawBitmap( *my_horse_tiff
, 30, 1530 );
550 dc
.DrawText( _T("XPM handler"), 30, 1745 );
551 if (my_horse_xpm
&& my_horse_xpm
->Ok())
552 dc
.DrawBitmap( *my_horse_xpm
, 30, 1760 );
555 if (my_smile_xbm
&& my_smile_xbm
->Ok())
557 dc
.DrawText( _T("XBM bitmap"), 30, 1975 );
558 dc
.DrawText( _T("(green on red)"), 30, 1990 );
559 dc
.SetTextForeground( _T("GREEN") );
560 dc
.SetTextBackground( _T("RED") );
561 dc
.DrawBitmap( *my_smile_xbm
, 30, 2010 );
563 dc
.SetTextForeground( wxT("BLACK") );
564 dc
.DrawText( _T("After wxImage conversion"), 150, 1975 );
565 dc
.DrawText( _T("(red on white)"), 150, 1990 );
566 dc
.SetTextForeground( wxT("RED") );
567 wxImage i
= my_smile_xbm
->ConvertToImage();
568 i
.SetMaskColour( 255, 255, 255 );
570 wxRED_PEN
->GetColour().Red(),
571 wxRED_PEN
->GetColour().Green(),
572 wxRED_PEN
->GetColour().Blue() );
573 dc
.DrawBitmap( wxBitmap(i
), 150, 2010, TRUE
);
574 dc
.SetTextForeground( wxT("BLACK") );
578 wxBitmap
mono( 60,50,1 );
580 memdc
.SelectObject( mono
);
581 memdc
.SetPen( *wxBLACK_PEN
);
582 memdc
.SetBrush( *wxWHITE_BRUSH
);
583 memdc
.DrawRectangle( 0,0,60,50 );
584 memdc
.SetTextForeground( *wxBLACK
);
585 memdc
.DrawText( _T("Hi!"), 5, 5 );
586 memdc
.SetBrush( *wxBLACK_BRUSH
);
587 memdc
.DrawRectangle( 33,5,20,20 );
588 memdc
.SetPen( *wxRED_PEN
);
589 memdc
.DrawLine( 5, 42, 50, 42 );
590 memdc
.SelectObject( wxNullBitmap
);
594 dc
.DrawText( _T("Mono bitmap"), 30, 2095 );
595 dc
.DrawText( _T("(red on green)"), 30, 2110 );
596 dc
.SetTextForeground( wxT("RED") );
597 dc
.SetTextBackground( wxT("GREEN") );
598 dc
.DrawBitmap( mono
, 30, 2130 );
600 dc
.SetTextForeground( wxT("BLACK") );
601 dc
.DrawText( _T("After wxImage conversion"), 150, 2095 );
602 dc
.DrawText( _T("(red on white)"), 150, 2110 );
603 dc
.SetTextForeground( wxT("RED") );
604 wxImage i
= mono
.ConvertToImage();
605 i
.SetMaskColour( 255,255,255 );
607 wxRED_PEN
->GetColour().Red(),
608 wxRED_PEN
->GetColour().Green(),
609 wxRED_PEN
->GetColour().Blue() );
610 dc
.DrawBitmap( wxBitmap(i
), 150, 2130, TRUE
);
611 dc
.SetTextForeground( wxT("BLACK") );
614 dc
.DrawText(_T("XPM bitmap"), 30, 2230);
615 if ( m_bmpSmileXpm
.Ok() )
617 dc
.DrawBitmap(m_bmpSmileXpm
, 30, 2250, TRUE
);
620 dc
.DrawText(_T("XPM icon"), 150, 2230);
621 if ( m_iconSmileXpm
.Ok() )
623 dc
.DrawIcon(m_iconSmileXpm
, 150, 2250);
626 dc
.DrawText( _T("ICO handler (1st image)"), 30, 2290 );
627 if (my_horse_ico32
&& my_horse_ico32
->Ok())
628 dc
.DrawBitmap( *my_horse_ico32
, 30, 2330, TRUE
);
630 dc
.DrawText( _T("ICO handler (2nd image)"), 230, 2290 );
631 if (my_horse_ico16
&& my_horse_ico16
->Ok())
632 dc
.DrawBitmap( *my_horse_ico16
, 230, 2330, TRUE
);
634 dc
.DrawText( _T("ICO handler (best image)"), 430, 2290 );
635 if (my_horse_ico
&& my_horse_ico
->Ok())
636 dc
.DrawBitmap( *my_horse_ico
, 430, 2330, TRUE
);
638 dc
.DrawText( _T("CUR handler"), 30, 2390 );
639 if (my_horse_cur
&& my_horse_cur
->Ok())
641 dc
.DrawBitmap( *my_horse_cur
, 30, 2420, TRUE
);
642 dc
.SetPen (*wxRED_PEN
);
643 dc
.DrawLine (xH
-10,yH
,xH
+10,yH
);
644 dc
.DrawLine (xH
,yH
-10,xH
,yH
+10);
646 dc
.DrawText( _T("ANI handler"), 230, 2390 );
648 for (i
=0; i
< m_ani_images
; i
++)
649 if (my_horse_ani
[i
].Ok())
651 dc
.DrawBitmap( my_horse_ani
[i
], 230 + i
* 2 * my_horse_ani
[i
].GetWidth() , 2420, TRUE
);
655 void MyCanvas::CreateAntiAliasedBitmap()
657 wxBitmap
bitmap( 300, 300 );
661 dc
.SelectObject( bitmap
);
665 dc
.SetFont( wxFont( 24, wxDECORATIVE
, wxNORMAL
, wxNORMAL
) );
666 dc
.SetTextForeground( wxT("RED") );
667 dc
.DrawText( _T("This is anti-aliased Text."), 20, 20 );
668 dc
.DrawText( _T("And a Rectangle."), 20, 60 );
670 dc
.SetBrush( *wxRED_BRUSH
);
671 dc
.SetPen( *wxTRANSPARENT_PEN
);
672 dc
.DrawRoundedRectangle( 20, 100, 200, 180, 20 );
674 wxImage original
= bitmap
.ConvertToImage();
675 wxImage
anti( 150, 150 );
677 /* This is quite slow, but safe. Use wxImage::GetData() for speed instead. */
679 for (int y
= 1; y
< 149; y
++)
680 for (int x
= 1; x
< 149; x
++)
682 int red
= original
.GetRed( x
*2, y
*2 ) +
683 original
.GetRed( x
*2-1, y
*2 ) +
684 original
.GetRed( x
*2, y
*2+1 ) +
685 original
.GetRed( x
*2+1, y
*2+1 );
688 int green
= original
.GetGreen( x
*2, y
*2 ) +
689 original
.GetGreen( x
*2-1, y
*2 ) +
690 original
.GetGreen( x
*2, y
*2+1 ) +
691 original
.GetGreen( x
*2+1, y
*2+1 );
694 int blue
= original
.GetBlue( x
*2, y
*2 ) +
695 original
.GetBlue( x
*2-1, y
*2 ) +
696 original
.GetBlue( x
*2, y
*2+1 ) +
697 original
.GetBlue( x
*2+1, y
*2+1 );
699 anti
.SetRGB( x
, y
, red
, green
, blue
);
701 my_anti
= new wxBitmap(anti
);
706 const int ID_QUIT
= 108;
707 const int ID_ABOUT
= 109;
708 const int ID_NEW
= 110;
710 IMPLEMENT_DYNAMIC_CLASS( MyFrame
, wxFrame
)
712 BEGIN_EVENT_TABLE(MyFrame
,wxFrame
)
713 EVT_MENU (ID_ABOUT
, MyFrame::OnAbout
)
714 EVT_MENU (ID_QUIT
, MyFrame::OnQuit
)
715 EVT_MENU (ID_NEW
, MyFrame::OnNewFrame
)
719 : wxFrame( (wxFrame
*)NULL
, -1, _T("wxImage sample"),
720 wxPoint(20,20), wxSize(470,360) )
722 wxMenu
*file_menu
= new wxMenu();
723 file_menu
->Append( ID_NEW
, _T("&Show image..."));
724 file_menu
->AppendSeparator();
725 file_menu
->Append( ID_ABOUT
, _T("&About..."));
726 file_menu
->AppendSeparator();
727 file_menu
->Append( ID_QUIT
, _T("E&xit"));
729 wxMenuBar
*menu_bar
= new wxMenuBar();
730 menu_bar
->Append(file_menu
, _T("&File"));
732 SetMenuBar( menu_bar
);
735 int widths
[] = { -1, 100 };
736 SetStatusWidths( 2, widths
);
738 m_canvas
= new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) );
740 // 500 width * 2500 height
741 m_canvas
->SetScrollbars( 10, 10, 50, 250 );
744 void MyFrame::OnQuit( wxCommandEvent
&WXUNUSED(event
) )
749 void MyFrame::OnAbout( wxCommandEvent
&WXUNUSED(event
) )
751 (void)wxMessageBox( _T("wxImage demo\n")
752 _T("Robert Roebling (c) 1998,2000"),
753 _T("About wxImage Demo"), wxICON_INFORMATION
| wxOK
);
756 void MyFrame::OnNewFrame( wxCommandEvent
&WXUNUSED(event
) )
758 wxString filename
= wxFileSelector(_T("Select image file"));
763 if ( !image
.LoadFile(filename
) )
765 wxLogError(_T("Couldn't load image from '%s'."), filename
.c_str());
770 (new MyImageFrame(this, wxBitmap(image
)))->Show();
773 //-----------------------------------------------------------------------------
775 //-----------------------------------------------------------------------------
780 wxImage::AddHandler( new wxPNGHandler
);
784 wxImage::AddHandler( new wxJPEGHandler
);
788 wxImage::AddHandler( new wxTIFFHandler
);
792 wxImage::AddHandler( new wxGIFHandler
);
796 wxImage::AddHandler( new wxPCXHandler
);
800 wxImage::AddHandler( new wxPNMHandler
);
804 wxImage::AddHandler( new wxXPMHandler
);
808 wxImage::AddHandler( new wxICOHandler
);
809 wxImage::AddHandler( new wxCURHandler
);
810 wxImage::AddHandler( new wxANIHandler
);
813 wxFrame
*frame
= new MyFrame();