]>
Commit | Line | Data |
---|---|---|
01111366 RR |
1 | /* |
2 | * Program: image | |
1d5b7a0b | 3 | * |
01111366 RR |
4 | * Author: Robert Roebling |
5 | * | |
6 | * Copyright: (C) 1998, Robert Roebling | |
7 | * | |
8 | */ | |
9 | ||
3d05544e JS |
10 | // For compilers that support precompilation, includes "wx/wx.h". |
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #ifdef __BORLANDC__ | |
14 | #pragma hdrstop | |
15 | #endif | |
16 | ||
17 | #ifndef WX_PRECOMP | |
01111366 | 18 | #include "wx/wx.h" |
3d05544e JS |
19 | #endif |
20 | ||
01111366 RR |
21 | #include "wx/image.h" |
22 | ||
a23fd0e1 VZ |
23 | #include "wx/file.h" |
24 | ||
dc1dbfc6 | 25 | #include "smile.xbm" |
bea56879 | 26 | #include "smile.xpm" |
dc1dbfc6 | 27 | |
01111366 RR |
28 | // derived classes |
29 | ||
30 | class MyFrame; | |
31 | class MyApp; | |
32 | ||
33 | // MyCanvas | |
34 | ||
35 | class MyCanvas: public wxScrolledWindow | |
36 | { | |
1d5b7a0b VZ |
37 | public: |
38 | MyCanvas() {}; | |
01111366 | 39 | MyCanvas( wxWindow *parent, wxWindowID, const wxPoint &pos, const wxSize &size ); |
1d5b7a0b | 40 | ~MyCanvas(); |
01111366 | 41 | void OnPaint( wxPaintEvent &event ); |
9390a202 | 42 | void CreateAntiAliasedBitmap(); |
1d5b7a0b | 43 | |
e1929140 RR |
44 | wxBitmap *my_horse_png; |
45 | wxBitmap *my_horse_jpeg; | |
46 | wxBitmap *my_horse_gif; | |
ca26177c | 47 | wxBitmap *my_horse_bmp; |
cbd4be25 | 48 | wxBitmap *my_horse_pcx; |
6319afe3 | 49 | wxBitmap *my_horse_pnm; |
60a41aee | 50 | wxBitmap *my_horse_tiff; |
dc1dbfc6 | 51 | wxBitmap *my_smile_xbm; |
e8fdc264 | 52 | wxBitmap *my_square; |
9390a202 | 53 | wxBitmap *my_anti; |
1d5b7a0b | 54 | |
bea56879 VZ |
55 | protected: |
56 | wxBitmap m_bmpSmileXpm; | |
57 | wxIcon m_iconSmileXpm; | |
58 | ||
60a41aee | 59 | private: |
1d5b7a0b VZ |
60 | DECLARE_DYNAMIC_CLASS(MyCanvas) |
61 | DECLARE_EVENT_TABLE() | |
01111366 RR |
62 | }; |
63 | ||
64 | // MyFrame | |
65 | ||
66 | class MyFrame: public wxFrame | |
67 | { | |
1d5b7a0b VZ |
68 | public: |
69 | MyFrame(); | |
01111366 | 70 | |
01111366 RR |
71 | void OnAbout( wxCommandEvent &event ); |
72 | void OnQuit( wxCommandEvent &event ); | |
1d5b7a0b | 73 | |
01111366 | 74 | MyCanvas *m_canvas; |
1d5b7a0b | 75 | |
60a41aee | 76 | private: |
1d5b7a0b VZ |
77 | DECLARE_DYNAMIC_CLASS(MyFrame) |
78 | DECLARE_EVENT_TABLE() | |
01111366 RR |
79 | }; |
80 | ||
81 | // MyApp | |
82 | ||
83 | class MyApp: public wxApp | |
84 | { | |
1d5b7a0b VZ |
85 | public: |
86 | virtual bool OnInit(); | |
01111366 RR |
87 | }; |
88 | ||
89 | // main program | |
90 | ||
91 | IMPLEMENT_APP(MyApp) | |
92 | ||
93 | // MyCanvas | |
94 | ||
95 | IMPLEMENT_DYNAMIC_CLASS(MyCanvas, wxScrolledWindow) | |
96 | ||
1d5b7a0b VZ |
97 | BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) |
98 | EVT_PAINT(MyCanvas::OnPaint) | |
01111366 RR |
99 | END_EVENT_TABLE() |
100 | ||
acbd13a3 | 101 | MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id, |
1d5b7a0b | 102 | const wxPoint &pos, const wxSize &size ) |
81278df2 VZ |
103 | : wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER ) |
104 | #if !defined(__WINDOWS__) || wxUSE_XPM_IN_MSW | |
105 | , m_bmpSmileXpm((const char **) smile_xpm) | |
106 | , m_iconSmileXpm((const char **) smile_xpm) | |
107 | #endif | |
01111366 | 108 | { |
60a41aee RR |
109 | my_horse_png = (wxBitmap*) NULL; |
110 | my_horse_jpeg = (wxBitmap*) NULL; | |
111 | my_horse_gif = (wxBitmap*) NULL; | |
112 | my_horse_bmp = (wxBitmap*) NULL; | |
113 | my_horse_pcx = (wxBitmap*) NULL; | |
114 | my_horse_pnm = (wxBitmap*) NULL; | |
115 | my_horse_tiff = (wxBitmap*) NULL; | |
dc1dbfc6 | 116 | my_smile_xbm = (wxBitmap*) NULL; |
60a41aee RR |
117 | my_square = (wxBitmap*) NULL; |
118 | my_anti = (wxBitmap*) NULL; | |
119 | ||
120 | SetBackgroundColour(* wxWHITE); | |
121 | ||
122 | wxBitmap bitmap( 100, 100 ); | |
123 | ||
124 | wxMemoryDC dc; | |
125 | dc.SelectObject( bitmap ); | |
126 | dc.SetBrush( wxBrush( "orange", wxSOLID ) ); | |
cf3da716 | 127 | dc.SetPen( *wxBLACK_PEN ); |
60a41aee | 128 | dc.DrawRectangle( 0, 0, 100, 100 ); |
cf3da716 RR |
129 | dc.SetBrush( *wxWHITE_BRUSH ); |
130 | dc.DrawRectangle( 20, 20, 60, 60 ); | |
60a41aee RR |
131 | dc.SelectObject( wxNullBitmap ); |
132 | ||
133 | // try to find the directory with our images | |
134 | wxString dir; | |
135 | if ( wxFile::Exists("./horse.png") ) | |
81278df2 | 136 | dir = "./"; |
60a41aee RR |
137 | else if ( wxFile::Exists("../horse.png") ) |
138 | dir = "../"; | |
139 | else | |
140 | wxLogWarning("Can't find image files in either '.' or '..'!"); | |
141 | ||
142 | wxImage image( bitmap ); | |
143 | ||
bea56879 | 144 | #if wxUSE_LIBPNG |
279ababf RR |
145 | image.LoadFile( dir + wxString("test.png") ); |
146 | my_square = new wxBitmap( image.ConvertToBitmap() ); | |
147 | ||
60a41aee RR |
148 | if ( !image.SaveFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG ) ) |
149 | wxLogError("Can't save file"); | |
279ababf RR |
150 | |
151 | image = wxImage( 100, 100 ); | |
60a41aee RR |
152 | |
153 | if ( !image.LoadFile( dir + wxString("horse.png"), wxBITMAP_TYPE_PNG ) ) | |
154 | wxLogError("Can't load PNG image"); | |
155 | else | |
156 | my_horse_png = new wxBitmap( image.ConvertToBitmap() ); | |
bea56879 | 157 | #endif // wxUSE_LIBPNG |
60a41aee | 158 | |
bea56879 | 159 | #if wxUSE_LIBJPEG |
279ababf RR |
160 | image = wxImage( 100, 100 ); |
161 | ||
60a41aee RR |
162 | if ( !image.LoadFile( dir + wxString("horse.jpg") ) ) |
163 | wxLogError("Can't load JPG image"); | |
164 | else | |
165 | my_horse_jpeg = new wxBitmap( image.ConvertToBitmap() ); | |
bea56879 | 166 | #endif // wxUSE_LIBJPEG |
6e47faf1 JS |
167 | |
168 | #if wxUSE_GIF | |
279ababf RR |
169 | image = wxImage( 100, 100 ); |
170 | ||
60a41aee RR |
171 | if ( !image.LoadFile( dir + wxString("horse.gif") ) ) |
172 | wxLogError("Can't load GIF image"); | |
173 | else | |
174 | my_horse_gif = new wxBitmap( image.ConvertToBitmap() ); | |
6e47faf1 | 175 | #endif |
cbd4be25 | 176 | |
6e47faf1 | 177 | #if wxUSE_PCX |
279ababf RR |
178 | image = wxImage( 100, 100 ); |
179 | ||
60a41aee RR |
180 | if ( !image.LoadFile( dir + wxString("horse.pcx"), wxBITMAP_TYPE_PCX ) ) |
181 | wxLogError("Can't load PCX image"); | |
182 | else | |
183 | my_horse_pcx = new wxBitmap( image.ConvertToBitmap() ); | |
6e47faf1 | 184 | #endif |
cbd4be25 | 185 | |
279ababf RR |
186 | image = wxImage( 100, 100 ); |
187 | ||
60a41aee RR |
188 | if ( !image.LoadFile( dir + wxString("horse.bmp"), wxBITMAP_TYPE_BMP ) ) |
189 | wxLogError("Can't load BMP image"); | |
190 | else | |
191 | my_horse_bmp = new wxBitmap( image.ConvertToBitmap() ); | |
6319afe3 | 192 | |
6e47faf1 | 193 | #if wxUSE_PNM |
279ababf RR |
194 | image = wxImage( 100, 100 ); |
195 | ||
60a41aee RR |
196 | if ( !image.LoadFile( dir + wxString("horse.pnm"), wxBITMAP_TYPE_PNM ) ) |
197 | wxLogError("Can't load PNM image"); | |
198 | else | |
199 | my_horse_pnm = new wxBitmap( image.ConvertToBitmap() ); | |
6e47faf1 | 200 | #endif |
f048e32f | 201 | |
60a41aee | 202 | #if wxUSE_LIBTIFF |
279ababf RR |
203 | image = wxImage( 100, 100 ); |
204 | ||
60a41aee RR |
205 | if ( !image.LoadFile( dir + wxString("horse.tif"), wxBITMAP_TYPE_TIF ) ) |
206 | wxLogError("Can't load TIFF image"); | |
207 | else | |
208 | my_horse_tiff = new wxBitmap( image.ConvertToBitmap() ); | |
209 | #endif | |
210 | ||
60a41aee | 211 | CreateAntiAliasedBitmap(); |
dc1dbfc6 RL |
212 | |
213 | my_smile_xbm = new wxBitmap( (const char*)smile_bits, smile_width, | |
214 | smile_height, 1 ); | |
bfef20bf | 215 | |
279ababf | 216 | #ifndef __WXGTK__ |
81278df2 | 217 | #if !defined(__WINDOWS__) || wxUSE_XPM_IN_MSW |
bfef20bf GRG |
218 | // demonstrates XPM automatically using the mask when saving |
219 | if ( m_bmpSmileXpm.Ok() ) | |
220 | m_bmpSmileXpm.SaveFile("saved.xpm", wxBITMAP_TYPE_XPM); | |
81278df2 | 221 | #endif |
279ababf | 222 | #endif |
01111366 RR |
223 | } |
224 | ||
1d5b7a0b | 225 | MyCanvas::~MyCanvas() |
01111366 | 226 | { |
60a41aee RR |
227 | delete my_horse_pnm; |
228 | delete my_horse_png; | |
229 | delete my_horse_jpeg; | |
230 | delete my_horse_gif; | |
231 | delete my_horse_bmp; | |
232 | delete my_horse_pcx; | |
233 | delete my_horse_tiff; | |
dc1dbfc6 | 234 | delete my_smile_xbm; |
60a41aee RR |
235 | delete my_square; |
236 | delete my_anti; | |
01111366 RR |
237 | } |
238 | ||
239 | void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) | |
240 | { | |
be25e480 RR |
241 | wxPaintDC dc( this ); |
242 | PrepareDC( dc ); | |
a91b47e8 | 243 | |
be25e480 RR |
244 | dc.DrawText( "Loaded image", 30, 10 ); |
245 | if (my_square && my_square->Ok()) dc.DrawBitmap( *my_square, 30, 30 ); | |
f048e32f | 246 | |
be25e480 RR |
247 | dc.DrawText( "Drawn directly", 150, 10 ); |
248 | dc.SetBrush( wxBrush( "orange", wxSOLID ) ); | |
cf3da716 | 249 | dc.SetPen( *wxBLACK_PEN ); |
be25e480 | 250 | dc.DrawRectangle( 150, 30, 100, 100 ); |
cf3da716 RR |
251 | dc.SetBrush( *wxWHITE_BRUSH ); |
252 | dc.DrawRectangle( 170, 50, 60, 60 ); | |
be25e480 | 253 | |
408b4168 | 254 | if (my_anti && my_anti->Ok()) |
be25e480 RR |
255 | dc.DrawBitmap( *my_anti, 280, 30 ); |
256 | ||
257 | dc.DrawText( "PNG handler", 30, 135 ); | |
258 | if (my_horse_png && my_horse_png->Ok()) | |
408b4168 | 259 | { |
be25e480 RR |
260 | dc.DrawBitmap( *my_horse_png, 30, 150 ); |
261 | wxRect rect(0,0,100,100); | |
262 | wxBitmap sub( my_horse_png->GetSubBitmap(rect) ); | |
263 | dc.DrawText( "GetSubBitmap()", 280, 190 ); | |
264 | dc.DrawBitmap( sub, 280, 210 ); | |
265 | } | |
266 | ||
267 | dc.DrawText( "JPEG handler", 30, 365 ); | |
408b4168 | 268 | if (my_horse_jpeg && my_horse_jpeg->Ok()) |
be25e480 RR |
269 | dc.DrawBitmap( *my_horse_jpeg, 30, 380 ); |
270 | ||
271 | dc.DrawText( "GIF handler", 30, 595 ); | |
408b4168 | 272 | if (my_horse_gif && my_horse_gif->Ok()) |
be25e480 RR |
273 | dc.DrawBitmap( *my_horse_gif, 30, 610 ); |
274 | ||
275 | dc.DrawText( "PCX handler", 30, 825 ); | |
408b4168 | 276 | if (my_horse_pcx && my_horse_pcx->Ok()) |
be25e480 RR |
277 | dc.DrawBitmap( *my_horse_pcx, 30, 840 ); |
278 | ||
279 | dc.DrawText( "BMP handler", 30, 1055 ); | |
408b4168 | 280 | if (my_horse_bmp && my_horse_bmp->Ok()) |
be25e480 RR |
281 | dc.DrawBitmap( *my_horse_bmp, 30, 1070 ); |
282 | ||
283 | dc.DrawText( "PNM handler", 30, 1285 ); | |
408b4168 | 284 | if (my_horse_pnm && my_horse_pnm->Ok()) |
be25e480 | 285 | dc.DrawBitmap( *my_horse_pnm, 30, 1300 ); |
408b4168 | 286 | |
be25e480 | 287 | dc.DrawText( "TIFF handler", 30, 1515 ); |
408b4168 | 288 | if (my_horse_tiff && my_horse_tiff->Ok()) |
4b05d973 | 289 | dc.DrawBitmap( *my_horse_tiff, 30, 1530 ); |
be25e480 | 290 | |
408b4168 | 291 | if (my_smile_xbm && my_smile_xbm->Ok()) |
be25e480 RR |
292 | { |
293 | dc.DrawText( "XBM bitmap", 30, 1745 ); | |
82ea63e6 RR |
294 | dc.SetTextForeground( "RED" ); |
295 | dc.SetTextBackground( "GREEN" ); | |
be25e480 | 296 | dc.DrawBitmap( *my_smile_xbm, 30, 1760 ); |
408b4168 | 297 | |
be25e480 RR |
298 | dc.DrawText( "After wxImage conversion", 150, 1745 ); |
299 | wxImage i( *my_smile_xbm ); | |
408b4168 VZ |
300 | i.SetMaskColour( 0,0,0 ); |
301 | i.Replace( 255,255,255, | |
be25e480 RR |
302 | wxRED_PEN->GetColour().Red(), |
303 | wxRED_PEN->GetColour().Green(), | |
304 | wxRED_PEN->GetColour().Blue() ); | |
305 | dc.DrawBitmap( i.ConvertToBitmap(), 150, 1760, TRUE ); | |
306 | } | |
82ea63e6 | 307 | dc.SetTextForeground( "BLACK" ); |
408b4168 | 308 | |
41fbc841 | 309 | wxBitmap mono( 60,50,1 ); |
82ea63e6 RR |
310 | wxMemoryDC memdc; |
311 | memdc.SelectObject( mono ); | |
bfef20bf | 312 | memdc.SetPen( *wxBLACK_PEN ); |
82ea63e6 | 313 | memdc.SetBrush( *wxWHITE_BRUSH ); |
41fbc841 RR |
314 | memdc.DrawRectangle( 0,0,60,50 ); |
315 | memdc.SetTextForeground( *wxBLACK ); | |
316 | memdc.DrawText( "Hi!", 5, 5 ); | |
317 | memdc.SetBrush( *wxBLACK_BRUSH ); | |
318 | memdc.DrawRectangle( 33,5,20,20 ); | |
319 | memdc.SetPen( *wxRED_PEN ); | |
320 | memdc.DrawLine( 5, 42, 50, 42 ); | |
82ea63e6 | 321 | memdc.SelectObject( wxNullBitmap ); |
408b4168 | 322 | if (mono.Ok()) |
82ea63e6 RR |
323 | { |
324 | dc.DrawText( "Mono bitmap", 30, 1845 ); | |
325 | dc.SetTextForeground( "RED" ); | |
326 | dc.SetTextBackground( "GREEN" ); | |
327 | dc.DrawBitmap( mono, 30, 1860 ); | |
408b4168 | 328 | |
bea56879 | 329 | dc.SetTextForeground( "BLACK" ); |
82ea63e6 | 330 | dc.DrawText( "After wxImage conversion", 150, 1845 ); |
bea56879 | 331 | dc.SetTextForeground( "RED" ); |
82ea63e6 | 332 | wxImage i( mono ); |
408b4168 VZ |
333 | i.SetMaskColour( 255,255,255 ); |
334 | i.Replace( 0,0,0, | |
82ea63e6 RR |
335 | wxRED_PEN->GetColour().Red(), |
336 | wxRED_PEN->GetColour().Green(), | |
337 | wxRED_PEN->GetColour().Blue() ); | |
338 | dc.DrawBitmap( i.ConvertToBitmap(), 150, 1860, TRUE ); | |
bea56879 VZ |
339 | dc.SetTextForeground( "BLACK" ); |
340 | } | |
341 | ||
342 | dc.DrawText("XPM bitmap", 30, 1950); | |
343 | if ( m_bmpSmileXpm.Ok() ) | |
344 | { | |
345 | dc.DrawBitmap(m_bmpSmileXpm, 30, 1975, TRUE); | |
346 | } | |
347 | ||
348 | dc.DrawText("XPM icon", 150, 1950); | |
349 | if ( m_iconSmileXpm.Ok() ) | |
350 | { | |
351 | dc.DrawIcon(m_iconSmileXpm, 150, 1975); | |
82ea63e6 | 352 | } |
9390a202 | 353 | } |
1d5b7a0b | 354 | |
9390a202 RR |
355 | void MyCanvas::CreateAntiAliasedBitmap() |
356 | { | |
357 | wxBitmap bitmap( 300, 300 ); | |
a91b47e8 | 358 | |
9390a202 | 359 | wxMemoryDC dc; |
a91b47e8 | 360 | |
9390a202 | 361 | dc.SelectObject( bitmap ); |
a91b47e8 | 362 | |
9390a202 | 363 | dc.Clear(); |
f048e32f | 364 | |
6e47faf1 | 365 | dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL) ); |
9390a202 RR |
366 | dc.SetTextForeground( "RED" ); |
367 | dc.DrawText( "This is anti-aliased Text.", 20, 20 ); | |
368 | dc.DrawText( "And a Rectangle.", 20, 60 ); | |
f048e32f | 369 | |
9390a202 | 370 | dc.SetBrush( *wxRED_BRUSH ); |
91b8de8d | 371 | dc.SetPen( *wxTRANSPARENT_PEN ); |
9390a202 | 372 | dc.DrawRoundedRectangle( 20, 100, 200, 180, 20 ); |
f048e32f | 373 | |
9390a202 RR |
374 | wxImage original( bitmap ); |
375 | wxImage anti( 150, 150 ); | |
a91b47e8 | 376 | |
9390a202 | 377 | /* This is quite slow, but safe. Use wxImage::GetData() for speed instead. */ |
f048e32f | 378 | |
9390a202 RR |
379 | for (int y = 1; y < 149; y++) |
380 | for (int x = 1; x < 149; x++) | |
381 | { | |
382 | int red = original.GetRed( x*2, y*2 ) + | |
f048e32f VZ |
383 | original.GetRed( x*2-1, y*2 ) + |
384 | original.GetRed( x*2, y*2+1 ) + | |
9390a202 | 385 | original.GetRed( x*2+1, y*2+1 ); |
f048e32f VZ |
386 | red = red/4; |
387 | ||
9390a202 | 388 | int green = original.GetGreen( x*2, y*2 ) + |
f048e32f VZ |
389 | original.GetGreen( x*2-1, y*2 ) + |
390 | original.GetGreen( x*2, y*2+1 ) + | |
9390a202 | 391 | original.GetGreen( x*2+1, y*2+1 ); |
f048e32f VZ |
392 | green = green/4; |
393 | ||
9390a202 | 394 | int blue = original.GetBlue( x*2, y*2 ) + |
f048e32f VZ |
395 | original.GetBlue( x*2-1, y*2 ) + |
396 | original.GetBlue( x*2, y*2+1 ) + | |
9390a202 | 397 | original.GetBlue( x*2+1, y*2+1 ); |
f048e32f | 398 | blue = blue/4; |
9390a202 RR |
399 | anti.SetRGB( x, y, red, green, blue ); |
400 | } | |
401 | my_anti = new wxBitmap( anti.ConvertToBitmap() ); | |
01111366 RR |
402 | } |
403 | ||
404 | // MyFrame | |
405 | ||
79490c3d VZ |
406 | const int ID_QUIT = 108; |
407 | const int ID_ABOUT = 109; | |
01111366 RR |
408 | |
409 | IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame ) | |
410 | ||
411 | BEGIN_EVENT_TABLE(MyFrame,wxFrame) | |
412 | EVT_MENU (ID_ABOUT, MyFrame::OnAbout) | |
413 | EVT_MENU (ID_QUIT, MyFrame::OnQuit) | |
414 | END_EVENT_TABLE() | |
415 | ||
1d5b7a0b VZ |
416 | MyFrame::MyFrame() |
417 | : wxFrame( (wxFrame *)NULL, -1, "wxImage sample", | |
418 | wxPoint(20,20), wxSize(470,360) ) | |
01111366 RR |
419 | { |
420 | wxMenu *file_menu = new wxMenu(); | |
81278df2 | 421 | file_menu->Append( ID_ABOUT, "&About..."); |
90e58684 | 422 | file_menu->Append( ID_QUIT, "E&xit"); |
1d5b7a0b | 423 | |
01111366 | 424 | wxMenuBar *menu_bar = new wxMenuBar(); |
90e58684 | 425 | menu_bar->Append(file_menu, "&File"); |
3d05544e | 426 | |
01111366 | 427 | SetMenuBar( menu_bar ); |
1d5b7a0b | 428 | |
917e533b RR |
429 | CreateStatusBar(2); |
430 | int widths[] = { -1, 100 }; | |
431 | SetStatusWidths( 2, widths ); | |
1d5b7a0b | 432 | |
fb1585ae | 433 | m_canvas = new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) ); |
cbd4be25 | 434 | |
bea56879 VZ |
435 | // 500 width * 2100 height |
436 | m_canvas->SetScrollbars( 10, 10, 50, 210 ); | |
01111366 RR |
437 | } |
438 | ||
439 | void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) ) | |
440 | { | |
441 | Close( TRUE ); | |
442 | } | |
443 | ||
444 | void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) ) | |
445 | { | |
1d5b7a0b | 446 | (void)wxMessageBox( "wxImage demo\n" |
41fbc841 | 447 | "Robert Roebling (c) 1998,2000", |
1d5b7a0b | 448 | "About wxImage Demo", wxICON_INFORMATION | wxOK ); |
fb1585ae RR |
449 | } |
450 | ||
01111366 RR |
451 | //----------------------------------------------------------------------------- |
452 | // MyApp | |
453 | //----------------------------------------------------------------------------- | |
454 | ||
1d5b7a0b | 455 | bool MyApp::OnInit() |
01111366 | 456 | { |
e9c4b1a2 JS |
457 | #if wxUSE_LIBPNG |
458 | wxImage::AddHandler( new wxPNGHandler ); | |
459 | #endif | |
460 | ||
461 | #if wxUSE_LIBJPEG | |
462 | wxImage::AddHandler( new wxJPEGHandler ); | |
463 | #endif | |
464 | ||
60a41aee RR |
465 | #if wxUSE_LIBTIFF |
466 | wxImage::AddHandler( new wxTIFFHandler ); | |
467 | #endif | |
468 | ||
6e47faf1 | 469 | #if wxUSE_GIF |
e1929140 | 470 | wxImage::AddHandler( new wxGIFHandler ); |
6e47faf1 JS |
471 | #endif |
472 | ||
473 | #if wxUSE_PCX | |
cbd4be25 | 474 | wxImage::AddHandler( new wxPCXHandler ); |
6e47faf1 JS |
475 | #endif |
476 | ||
477 | #if wxUSE_PNM | |
6319afe3 | 478 | wxImage::AddHandler( new wxPNMHandler ); |
6e47faf1 | 479 | #endif |
e1929140 | 480 | |
01111366 RR |
481 | wxFrame *frame = new MyFrame(); |
482 | frame->Show( TRUE ); | |
1d5b7a0b | 483 | |
01111366 RR |
484 | return TRUE; |
485 | } | |
486 |