]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: bitmap.h | |
e54c96f1 | 3 | // Purpose: interface of wxBitmapHandler |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxBitmapHandler | |
11 | @wxheader{bitmap.h} | |
7c913512 | 12 | |
e54c96f1 | 13 | Overview() |
7c913512 | 14 | |
23324ae1 FM |
15 | This is the base class for implementing bitmap file loading/saving, and bitmap |
16 | creation from data. | |
17 | It is used within wxBitmap and is not normally seen by the application. | |
7c913512 | 18 | |
23324ae1 FM |
19 | If you wish to extend the capabilities of wxBitmap, derive a class from |
20 | wxBitmapHandler | |
21 | and add the handler using wxBitmap::AddHandler in your | |
22 | application initialisation. | |
7c913512 | 23 | |
23324ae1 FM |
24 | @library{wxcore} |
25 | @category{FIXME} | |
7c913512 | 26 | |
e54c96f1 | 27 | @see wxBitmap, wxIcon, wxCursor |
23324ae1 FM |
28 | */ |
29 | class wxBitmapHandler : public wxObject | |
30 | { | |
31 | public: | |
32 | /** | |
33 | Default constructor. In your own default constructor, initialise the members | |
34 | m_name, m_extension and m_type. | |
35 | */ | |
36 | wxBitmapHandler(); | |
37 | ||
38 | /** | |
39 | Destroys the wxBitmapHandler object. | |
40 | */ | |
41 | ~wxBitmapHandler(); | |
42 | ||
43 | /** | |
44 | Creates a bitmap from the given data, which can be of arbitrary type. The | |
4cc4bfaf | 45 | wxBitmap object @a bitmap is |
23324ae1 FM |
46 | manipulated by this function. |
47 | ||
7c913512 | 48 | @param bitmap |
4cc4bfaf | 49 | The wxBitmap object. |
7c913512 | 50 | @param width |
4cc4bfaf | 51 | The width of the bitmap in pixels. |
7c913512 | 52 | @param height |
4cc4bfaf | 53 | The height of the bitmap in pixels. |
7c913512 | 54 | @param depth |
4cc4bfaf | 55 | The depth of the bitmap in pixels. If this is -1, the screen depth is used. |
7c913512 | 56 | @param data |
4cc4bfaf | 57 | Data whose type depends on the value of type. |
7c913512 | 58 | @param type |
4cc4bfaf FM |
59 | A bitmap type identifier - see wxBitmapHandler() for a list |
60 | of possible values. | |
23324ae1 FM |
61 | |
62 | @returns @true if the call succeeded, @false otherwise (the default). | |
63 | */ | |
64 | virtual bool Create(wxBitmap* bitmap, const void* data, int type, | |
65 | int width, | |
66 | int height, | |
67 | int depth = -1); | |
68 | ||
69 | /** | |
70 | Gets the file extension associated with this handler. | |
71 | */ | |
328f5751 | 72 | const wxString GetExtension() const; |
23324ae1 FM |
73 | |
74 | /** | |
75 | Gets the name of this handler. | |
76 | */ | |
328f5751 | 77 | const wxString GetName() const; |
23324ae1 FM |
78 | |
79 | /** | |
80 | Gets the bitmap type associated with this handler. | |
81 | */ | |
328f5751 | 82 | long GetType() const; |
23324ae1 FM |
83 | |
84 | /** | |
85 | Loads a bitmap from a file or resource, putting the resulting data into @e | |
86 | bitmap. | |
87 | ||
7c913512 | 88 | @param bitmap |
4cc4bfaf | 89 | The bitmap object which is to be affected by this operation. |
7c913512 | 90 | @param name |
4cc4bfaf FM |
91 | Either a filename or a Windows resource name. |
92 | The meaning of name is determined by the type parameter. | |
7c913512 | 93 | @param type |
4cc4bfaf | 94 | See wxBitmap::wxBitmap for values this can take. |
23324ae1 FM |
95 | |
96 | @returns @true if the operation succeeded, @false otherwise. | |
97 | ||
4cc4bfaf | 98 | @see wxBitmap::LoadFile, wxBitmap::SaveFile, SaveFile() |
23324ae1 FM |
99 | */ |
100 | bool LoadFile(wxBitmap* bitmap, const wxString& name, long type); | |
101 | ||
102 | /** | |
103 | Saves a bitmap in the named file. | |
104 | ||
7c913512 | 105 | @param bitmap |
4cc4bfaf | 106 | The bitmap object which is to be affected by this operation. |
7c913512 | 107 | @param name |
4cc4bfaf | 108 | A filename. The meaning of name is determined by the type parameter. |
7c913512 | 109 | @param type |
4cc4bfaf | 110 | See wxBitmap::wxBitmap for values this can take. |
7c913512 | 111 | @param palette |
4cc4bfaf | 112 | An optional palette used for saving the bitmap. |
23324ae1 FM |
113 | |
114 | @returns @true if the operation succeeded, @false otherwise. | |
115 | ||
4cc4bfaf | 116 | @see wxBitmap::LoadFile, wxBitmap::SaveFile, LoadFile() |
23324ae1 FM |
117 | */ |
118 | bool SaveFile(wxBitmap* bitmap, const wxString& name, int type, | |
4cc4bfaf | 119 | wxPalette* palette = NULL); |
23324ae1 FM |
120 | |
121 | /** | |
122 | Sets the handler extension. | |
123 | ||
7c913512 | 124 | @param extension |
4cc4bfaf | 125 | Handler extension. |
23324ae1 FM |
126 | */ |
127 | void SetExtension(const wxString& extension); | |
128 | ||
129 | /** | |
130 | Sets the handler name. | |
131 | ||
7c913512 | 132 | @param name |
4cc4bfaf | 133 | Handler name. |
23324ae1 FM |
134 | */ |
135 | void SetName(const wxString& name); | |
136 | ||
137 | /** | |
138 | Sets the handler type. | |
139 | ||
7c913512 | 140 | @param name |
4cc4bfaf | 141 | Handler type. |
23324ae1 FM |
142 | */ |
143 | void SetType(long type); | |
144 | }; | |
145 | ||
146 | ||
e54c96f1 | 147 | |
23324ae1 FM |
148 | /** |
149 | @class wxBitmap | |
3db7c3b1 | 150 | @ingroup group_class_gdi |
23324ae1 | 151 | @wxheader{bitmap.h} |
7c913512 | 152 | |
23324ae1 FM |
153 | This class encapsulates the concept of a platform-dependent bitmap, |
154 | either monochrome or colour or colour with alpha channel support. | |
7c913512 | 155 | |
23324ae1 FM |
156 | @library{wxcore} |
157 | @category{gdi} | |
7c913512 | 158 | |
23324ae1 | 159 | @stdobjects |
e54c96f1 | 160 | ::Objects:, ::wxNullBitmap, |
7c913512 | 161 | |
e54c96f1 | 162 | @see @ref overview_wxbitmapoverview "wxBitmap overview", @ref |
23324ae1 FM |
163 | overview_supportedbitmapformats "supported bitmap file formats", wxDC::Blit, wxIcon, wxCursor, wxBitmap, wxMemoryDC |
164 | */ | |
165 | class wxBitmap : public wxGDIObject | |
166 | { | |
167 | public: | |
168 | //@{ | |
169 | /** | |
170 | Creates bitmap object from the image. This has to be done | |
171 | to actually display an image as you cannot draw an image directly on a window. | |
172 | The resulting bitmap will use the provided colour depth (or that of the | |
173 | current system if depth is -1) which entails that a colour reduction has | |
174 | to take place. | |
23324ae1 FM |
175 | When in 8-bit mode (PseudoColour mode), the GTK port will use a color cube |
176 | created | |
177 | on program start-up to look up colors. This ensures a very fast conversion, but | |
178 | the image quality won't be perfect (and could be better for photo images using | |
179 | more | |
180 | sophisticated dithering algorithms). | |
23324ae1 FM |
181 | On Windows, if there is a palette present (set with SetPalette), it will be |
182 | used when | |
183 | creating the wxBitmap (most useful in 8-bit display mode). On other platforms, | |
184 | the palette is currently ignored. | |
185 | ||
7c913512 | 186 | @param bits |
4cc4bfaf | 187 | Specifies an array of pixel values. |
7c913512 | 188 | @param width |
4cc4bfaf | 189 | Specifies the width of the bitmap. |
7c913512 | 190 | @param height |
4cc4bfaf | 191 | Specifies the height of the bitmap. |
7c913512 | 192 | @param depth |
4cc4bfaf FM |
193 | Specifies the depth of the bitmap. If this is omitted, the display depth of |
194 | the | |
195 | screen is used. | |
7c913512 | 196 | @param name |
4cc4bfaf | 197 | This can refer to a resource name under MS Windows, or a filename under MS |
23324ae1 | 198 | Windows and X. |
4cc4bfaf | 199 | Its meaning is determined by the type parameter. |
7c913512 | 200 | @param type |
4cc4bfaf FM |
201 | May be one of the following: |
202 | ||
203 | ||
204 | ||
205 | ||
206 | ||
207 | ||
208 | ||
209 | wxBITMAP_TYPE_BMP | |
210 | ||
211 | ||
212 | ||
213 | ||
214 | Load a Windows bitmap file. | |
215 | ||
216 | ||
217 | ||
218 | ||
219 | ||
220 | wxBITMAP_TYPE_BMP_RESOURCE | |
221 | ||
222 | ||
23324ae1 FM |
223 | |
224 | ||
4cc4bfaf | 225 | Load a Windows bitmap resource from the executable. Windows only. |
23324ae1 FM |
226 | |
227 | ||
23324ae1 | 228 | |
23324ae1 FM |
229 | |
230 | ||
4cc4bfaf | 231 | wxBITMAP_TYPE_PICT_RESOURCE |
23324ae1 | 232 | |
23324ae1 FM |
233 | |
234 | ||
23324ae1 | 235 | |
4cc4bfaf | 236 | Load a PICT image resource from the executable. Mac OS only. |
23324ae1 FM |
237 | |
238 | ||
23324ae1 | 239 | |
23324ae1 FM |
240 | |
241 | ||
4cc4bfaf | 242 | wxBITMAP_TYPE_GIF |
23324ae1 | 243 | |
23324ae1 FM |
244 | |
245 | ||
23324ae1 | 246 | |
4cc4bfaf | 247 | Load a GIF bitmap file. |
23324ae1 | 248 | |
23324ae1 | 249 | |
4cc4bfaf FM |
250 | |
251 | ||
252 | ||
253 | wxBITMAP_TYPE_XBM | |
254 | ||
255 | ||
256 | ||
257 | ||
258 | Load an X bitmap file. | |
259 | ||
260 | ||
261 | ||
262 | ||
263 | ||
264 | wxBITMAP_TYPE_XPM | |
265 | ||
266 | ||
267 | ||
268 | ||
269 | Load an XPM bitmap file. | |
270 | ||
271 | ||
272 | ||
273 | ||
274 | ||
275 | The validity of these flags depends on the platform and wxWidgets | |
276 | configuration. | |
277 | If all possible wxWidgets settings are used, the Windows platform supports | |
278 | BMP file, BMP resource, | |
279 | XPM data, and XPM. Under wxGTK, the available formats are BMP file, XPM | |
280 | data, XPM file, and PNG file. | |
281 | Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM | |
282 | file. | |
283 | In addition, wxBitmap can read all formats that wxImage can, which | |
284 | currently include | |
285 | wxBITMAP_TYPE_JPEG, wxBITMAP_TYPE_TIF, wxBITMAP_TYPE_PNG, | |
286 | wxBITMAP_TYPE_GIF, wxBITMAP_TYPE_PCX, | |
287 | and wxBITMAP_TYPE_PNM. Of course, you must have wxImage handlers loaded. | |
7c913512 | 288 | @param img |
4cc4bfaf | 289 | Platform-independent wxImage object. |
23324ae1 FM |
290 | |
291 | @remarks The first form constructs a bitmap object with no data; an | |
4cc4bfaf FM |
292 | assignment or another member function such as Create or |
293 | LoadFile must be called subsequently. | |
23324ae1 | 294 | |
4cc4bfaf | 295 | @see LoadFile() |
23324ae1 FM |
296 | */ |
297 | wxBitmap(); | |
7c913512 FM |
298 | wxBitmap(const wxBitmap& bitmap); |
299 | wxBitmap(const void* data, int type, int width, int height, | |
300 | int depth = -1); | |
301 | wxBitmap(const char bits[], int width, int height, | |
302 | int depth = 1); | |
303 | wxBitmap(int width, int height, int depth = -1); | |
304 | wxBitmap(const char* const* bits); | |
305 | wxBitmap(const wxString& name, long type); | |
306 | wxBitmap(const wxImage& img, int depth = -1); | |
23324ae1 FM |
307 | //@} |
308 | ||
309 | /** | |
310 | Destructor. | |
311 | See @ref overview_refcountdestruct "reference-counted object destruction" for | |
312 | more info. | |
23324ae1 FM |
313 | If the application omits to delete the bitmap explicitly, the bitmap will be |
314 | destroyed automatically by wxWidgets when the application exits. | |
23324ae1 FM |
315 | Do not delete a bitmap that is selected into a memory device context. |
316 | */ | |
317 | ~wxBitmap(); | |
318 | ||
319 | /** | |
320 | Adds a handler to the end of the static list of format handlers. | |
321 | ||
7c913512 | 322 | @param handler |
4cc4bfaf FM |
323 | A new bitmap format handler object. There is usually only one instance |
324 | of a given handler class in an application session. | |
23324ae1 | 325 | |
4cc4bfaf | 326 | @see wxBitmapHandler |
23324ae1 FM |
327 | */ |
328 | static void AddHandler(wxBitmapHandler* handler); | |
329 | ||
330 | /** | |
331 | Deletes all bitmap handlers. | |
23324ae1 FM |
332 | This function is called by wxWidgets on exit. |
333 | */ | |
334 | static void CleanUpHandlers(); | |
335 | ||
336 | /** | |
337 | Creates an image from a platform-dependent bitmap. This preserves | |
338 | mask information so that bitmaps and images can be converted back | |
339 | and forth without loss in that respect. | |
340 | */ | |
341 | wxImage ConvertToImage(); | |
342 | ||
343 | /** | |
344 | Creates the bitmap from an icon. | |
345 | */ | |
346 | bool CopyFromIcon(const wxIcon& icon); | |
347 | ||
348 | //@{ | |
349 | /** | |
350 | Creates a bitmap from the given data, which can be of arbitrary type. | |
351 | ||
7c913512 | 352 | @param width |
4cc4bfaf | 353 | The width of the bitmap in pixels. |
7c913512 | 354 | @param height |
4cc4bfaf | 355 | The height of the bitmap in pixels. |
7c913512 | 356 | @param depth |
4cc4bfaf | 357 | The depth of the bitmap in pixels. If this is -1, the screen depth is used. |
7c913512 | 358 | @param data |
4cc4bfaf | 359 | Data whose type depends on the value of type. |
7c913512 | 360 | @param type |
4cc4bfaf FM |
361 | A bitmap type identifier - see wxBitmap() for a list |
362 | of possible values. | |
23324ae1 FM |
363 | |
364 | @returns @true if the call succeeded, @false otherwise. | |
365 | ||
366 | @remarks The first form works on all platforms. The portability of the | |
4cc4bfaf | 367 | second form depends on the type of data. |
23324ae1 | 368 | |
4cc4bfaf | 369 | @see wxBitmap() |
23324ae1 FM |
370 | */ |
371 | virtual bool Create(int width, int height, int depth = -1); | |
7c913512 FM |
372 | virtual bool Create(const void* data, int type, int width, |
373 | int height, | |
374 | int depth = -1); | |
23324ae1 FM |
375 | //@} |
376 | ||
377 | //@{ | |
378 | /** | |
379 | Finds the handler associated with the given bitmap type. | |
380 | ||
7c913512 | 381 | @param name |
4cc4bfaf | 382 | The handler name. |
7c913512 | 383 | @param extension |
4cc4bfaf | 384 | The file extension, such as "bmp". |
7c913512 | 385 | @param bitmapType |
4cc4bfaf | 386 | The bitmap type, such as wxBITMAP_TYPE_BMP. |
23324ae1 FM |
387 | |
388 | @returns A pointer to the handler if found, @NULL otherwise. | |
389 | ||
4cc4bfaf | 390 | @see wxBitmapHandler |
23324ae1 FM |
391 | */ |
392 | static wxBitmapHandler* FindHandler(const wxString& name); | |
7c913512 FM |
393 | static wxBitmapHandler* FindHandler(const wxString& extension, |
394 | wxBitmapType bitmapType); | |
395 | static wxBitmapHandler* FindHandler(wxBitmapType bitmapType); | |
23324ae1 FM |
396 | //@} |
397 | ||
398 | /** | |
399 | Gets the colour depth of the bitmap. A value of 1 indicates a | |
400 | monochrome bitmap. | |
401 | */ | |
328f5751 | 402 | int GetDepth() const; |
23324ae1 FM |
403 | |
404 | /** | |
405 | Returns the static list of bitmap format handlers. | |
406 | ||
4cc4bfaf | 407 | @see wxBitmapHandler |
23324ae1 FM |
408 | */ |
409 | static wxList GetHandlers(); | |
410 | ||
411 | /** | |
412 | Gets the height of the bitmap in pixels. | |
413 | */ | |
328f5751 | 414 | int GetHeight() const; |
23324ae1 FM |
415 | |
416 | /** | |
417 | Gets the associated mask (if any) which may have been loaded from a file | |
418 | or set for the bitmap. | |
419 | ||
4cc4bfaf | 420 | @see SetMask(), wxMask |
23324ae1 | 421 | */ |
328f5751 | 422 | wxMask* GetMask() const; |
23324ae1 FM |
423 | |
424 | /** | |
425 | Gets the associated palette (if any) which may have been loaded from a file | |
426 | or set for the bitmap. | |
427 | ||
4cc4bfaf | 428 | @see wxPalette |
23324ae1 | 429 | */ |
328f5751 | 430 | wxPalette* GetPalette() const; |
23324ae1 FM |
431 | |
432 | /** | |
433 | Returns a sub bitmap of the current one as long as the rect belongs entirely to | |
434 | the bitmap. This function preserves bit depth and mask information. | |
435 | */ | |
328f5751 | 436 | wxBitmap GetSubBitmap(const wxRect& rect) const; |
23324ae1 FM |
437 | |
438 | /** | |
439 | Gets the width of the bitmap in pixels. | |
440 | ||
4cc4bfaf | 441 | @see GetHeight() |
23324ae1 | 442 | */ |
328f5751 | 443 | int GetWidth() const; |
23324ae1 FM |
444 | |
445 | /** | |
446 | Adds the standard bitmap format handlers, which, depending on wxWidgets | |
447 | configuration, can be handlers for Windows bitmap, Windows bitmap resource, and | |
448 | XPM. | |
23324ae1 FM |
449 | This function is called by wxWidgets on startup. |
450 | ||
4cc4bfaf | 451 | @see wxBitmapHandler |
23324ae1 FM |
452 | */ |
453 | static void InitStandardHandlers(); | |
454 | ||
455 | /** | |
456 | Adds a handler at the start of the static list of format handlers. | |
457 | ||
7c913512 | 458 | @param handler |
4cc4bfaf FM |
459 | A new bitmap format handler object. There is usually only one instance |
460 | of a given handler class in an application session. | |
23324ae1 | 461 | |
4cc4bfaf | 462 | @see wxBitmapHandler |
23324ae1 FM |
463 | */ |
464 | static void InsertHandler(wxBitmapHandler* handler); | |
465 | ||
466 | /** | |
467 | Returns @true if bitmap data is present. | |
468 | */ | |
328f5751 | 469 | bool IsOk() const; |
23324ae1 FM |
470 | |
471 | /** | |
472 | Loads a bitmap from a file or resource. | |
473 | ||
7c913512 | 474 | @param name |
4cc4bfaf FM |
475 | Either a filename or a Windows resource name. |
476 | The meaning of name is determined by the type parameter. | |
7c913512 | 477 | @param type |
4cc4bfaf FM |
478 | One of the following values: |
479 | ||
480 | ||
481 | ||
23324ae1 FM |
482 | |
483 | ||
23324ae1 FM |
484 | |
485 | ||
4cc4bfaf | 486 | wxBITMAP_TYPE_BMP |
23324ae1 | 487 | |
23324ae1 FM |
488 | |
489 | ||
23324ae1 | 490 | |
4cc4bfaf | 491 | Load a Windows bitmap file. |
23324ae1 FM |
492 | |
493 | ||
23324ae1 | 494 | |
23324ae1 FM |
495 | |
496 | ||
4cc4bfaf | 497 | wxBITMAP_TYPE_BMP_RESOURCE |
23324ae1 | 498 | |
23324ae1 FM |
499 | |
500 | ||
23324ae1 | 501 | |
4cc4bfaf | 502 | Load a Windows bitmap resource from the executable. |
23324ae1 FM |
503 | |
504 | ||
23324ae1 | 505 | |
23324ae1 | 506 | |
4cc4bfaf FM |
507 | |
508 | wxBITMAP_TYPE_PICT_RESOURCE | |
509 | ||
510 | ||
511 | ||
512 | ||
513 | Load a PICT image resource from the executable. Mac OS only. | |
514 | ||
515 | ||
516 | ||
517 | ||
518 | ||
519 | wxBITMAP_TYPE_GIF | |
520 | ||
521 | ||
522 | ||
523 | ||
524 | Load a GIF bitmap file. | |
525 | ||
526 | ||
527 | ||
528 | ||
529 | ||
530 | wxBITMAP_TYPE_XBM | |
531 | ||
532 | ||
533 | ||
534 | ||
535 | Load an X bitmap file. | |
536 | ||
537 | ||
538 | ||
539 | ||
540 | ||
541 | wxBITMAP_TYPE_XPM | |
542 | ||
543 | ||
544 | ||
545 | ||
546 | Load an XPM bitmap file. | |
547 | ||
548 | ||
549 | ||
550 | ||
551 | ||
552 | The validity of these flags depends on the platform and wxWidgets | |
553 | configuration. | |
554 | In addition, wxBitmap can read all formats that wxImage can | |
555 | (wxBITMAP_TYPE_JPEG, wxBITMAP_TYPE_PNG, wxBITMAP_TYPE_GIF, | |
556 | wxBITMAP_TYPE_PCX, wxBITMAP_TYPE_PNM). | |
557 | (Of course you must have wxImage handlers loaded.) | |
23324ae1 FM |
558 | |
559 | @returns @true if the operation succeeded, @false otherwise. | |
560 | ||
561 | @remarks A palette may be associated with the bitmap if one exists | |
4cc4bfaf FM |
562 | (especially for colour Windows bitmaps), and if the |
563 | code supports it. You can check if one has been created | |
564 | by using the GetPalette member. | |
23324ae1 | 565 | |
4cc4bfaf | 566 | @see SaveFile() |
23324ae1 FM |
567 | */ |
568 | bool LoadFile(const wxString& name, wxBitmapType type); | |
569 | ||
570 | /** | |
571 | Finds the handler with the given name, and removes it. The handler | |
572 | is not deleted. | |
573 | ||
7c913512 | 574 | @param name |
4cc4bfaf | 575 | The handler name. |
23324ae1 FM |
576 | |
577 | @returns @true if the handler was found and removed, @false otherwise. | |
578 | ||
4cc4bfaf | 579 | @see wxBitmapHandler |
23324ae1 FM |
580 | */ |
581 | static bool RemoveHandler(const wxString& name); | |
582 | ||
583 | /** | |
584 | Saves a bitmap in the named file. | |
585 | ||
7c913512 | 586 | @param name |
4cc4bfaf | 587 | A filename. The meaning of name is determined by the type parameter. |
7c913512 | 588 | @param type |
4cc4bfaf FM |
589 | One of the following values: |
590 | ||
591 | ||
592 | ||
593 | ||
594 | ||
595 | ||
596 | ||
597 | wxBITMAP_TYPE_BMP | |
598 | ||
599 | ||
600 | ||
601 | ||
602 | Save a Windows bitmap file. | |
603 | ||
604 | ||
605 | ||
23324ae1 FM |
606 | |
607 | ||
4cc4bfaf | 608 | wxBITMAP_TYPE_GIF |
23324ae1 FM |
609 | |
610 | ||
23324ae1 | 611 | |
23324ae1 | 612 | |
4cc4bfaf | 613 | Save a GIF bitmap file. |
23324ae1 | 614 | |
23324ae1 | 615 | |
23324ae1 FM |
616 | |
617 | ||
23324ae1 | 618 | |
4cc4bfaf | 619 | wxBITMAP_TYPE_XBM |
23324ae1 FM |
620 | |
621 | ||
23324ae1 | 622 | |
23324ae1 | 623 | |
4cc4bfaf | 624 | Save an X bitmap file. |
23324ae1 | 625 | |
4cc4bfaf FM |
626 | |
627 | ||
628 | ||
629 | ||
630 | wxBITMAP_TYPE_XPM | |
631 | ||
632 | ||
633 | ||
634 | ||
635 | Save an XPM bitmap file. | |
636 | ||
637 | ||
638 | ||
639 | ||
640 | ||
641 | The validity of these flags depends on the platform and wxWidgets | |
642 | configuration. | |
643 | In addition, wxBitmap can save all formats that wxImage can | |
644 | (wxBITMAP_TYPE_JPEG, wxBITMAP_TYPE_PNG). | |
645 | (Of course you must have wxImage handlers loaded.) | |
7c913512 | 646 | @param palette |
4cc4bfaf | 647 | An optional palette used for saving the bitmap. |
23324ae1 FM |
648 | |
649 | @returns @true if the operation succeeded, @false otherwise. | |
650 | ||
651 | @remarks Depending on how wxWidgets has been configured, not all formats | |
4cc4bfaf | 652 | may be available. |
23324ae1 | 653 | |
4cc4bfaf | 654 | @see LoadFile() |
23324ae1 FM |
655 | */ |
656 | bool SaveFile(const wxString& name, wxBitmapType type, | |
4cc4bfaf | 657 | wxPalette* palette = NULL); |
23324ae1 FM |
658 | |
659 | /** | |
660 | Sets the depth member (does not affect the bitmap data). | |
661 | ||
7c913512 | 662 | @param depth |
4cc4bfaf | 663 | Bitmap depth. |
23324ae1 FM |
664 | */ |
665 | void SetDepth(int depth); | |
666 | ||
667 | /** | |
668 | Sets the height member (does not affect the bitmap data). | |
669 | ||
7c913512 | 670 | @param height |
4cc4bfaf | 671 | Bitmap height in pixels. |
23324ae1 FM |
672 | */ |
673 | void SetHeight(int height); | |
674 | ||
675 | /** | |
676 | Sets the mask for this bitmap. | |
677 | ||
678 | @remarks The bitmap object owns the mask once this has been called. | |
679 | ||
4cc4bfaf | 680 | @see GetMask(), wxMask |
23324ae1 FM |
681 | */ |
682 | void SetMask(wxMask* mask); | |
683 | ||
684 | /** | |
685 | Sets the associated palette. (Not implemented under GTK+). | |
686 | ||
7c913512 | 687 | @param palette |
4cc4bfaf | 688 | The palette to set. |
23324ae1 | 689 | |
4cc4bfaf | 690 | @see wxPalette |
23324ae1 FM |
691 | */ |
692 | void SetPalette(const wxPalette& palette); | |
693 | ||
694 | /** | |
695 | Sets the width member (does not affect the bitmap data). | |
696 | ||
7c913512 | 697 | @param width |
4cc4bfaf | 698 | Bitmap width in pixels. |
23324ae1 FM |
699 | */ |
700 | void SetWidth(int width); | |
701 | ||
702 | /** | |
703 | Assignment operator, using @ref overview_trefcount "reference counting". | |
704 | ||
7c913512 | 705 | @param bitmap |
4cc4bfaf | 706 | Bitmap to assign. |
23324ae1 FM |
707 | */ |
708 | wxBitmap operator =(const wxBitmap& bitmap); | |
709 | }; | |
710 | ||
711 | ||
e54c96f1 FM |
712 | /** |
713 | FIXME | |
714 | */ | |
715 | wxBitmap Objects: | |
716 | ; | |
717 | ||
718 | /** | |
719 | FIXME | |
720 | */ | |
721 | wxBitmap wxNullBitmap; | |
722 | ||
723 | ||
724 | ||
725 | ||
23324ae1 FM |
726 | /** |
727 | @class wxMask | |
3db7c3b1 | 728 | @ingroup group_class_gdi |
23324ae1 | 729 | @wxheader{bitmap.h} |
7c913512 | 730 | |
23324ae1 FM |
731 | This class encapsulates a monochrome mask bitmap, where the masked area is |
732 | black and | |
733 | the unmasked area is white. When associated with a bitmap and drawn in a device | |
734 | context, | |
735 | the unmasked area of the bitmap will be drawn, and the masked area will not be | |
736 | drawn. | |
7c913512 | 737 | |
23324ae1 FM |
738 | @library{wxcore} |
739 | @category{gdi} | |
7c913512 | 740 | |
e54c96f1 | 741 | @see wxBitmap, wxDC::Blit, wxMemoryDC |
23324ae1 FM |
742 | */ |
743 | class wxMask : public wxObject | |
744 | { | |
745 | public: | |
746 | //@{ | |
747 | /** | |
748 | Constructs a mask from a bitmap and a palette index that indicates the | |
749 | background. Not | |
750 | yet implemented for GTK. | |
751 | ||
7c913512 | 752 | @param bitmap |
4cc4bfaf | 753 | A valid bitmap. |
7c913512 | 754 | @param colour |
4cc4bfaf | 755 | A colour specifying the transparency RGB values. |
7c913512 | 756 | @param index |
4cc4bfaf | 757 | Index into a palette, specifying the transparency colour. |
23324ae1 FM |
758 | */ |
759 | wxMask(); | |
7c913512 FM |
760 | wxMask(const wxBitmap& bitmap); |
761 | wxMask(const wxBitmap& bitmap, | |
762 | const wxColour& colour); | |
763 | wxMask(const wxBitmap& bitmap, int index); | |
23324ae1 FM |
764 | //@} |
765 | ||
766 | /** | |
767 | Destroys the wxMask object and the underlying bitmap data. | |
768 | */ | |
769 | ~wxMask(); | |
770 | ||
771 | //@{ | |
772 | /** | |
773 | Constructs a mask from a bitmap and a palette index that indicates the | |
774 | background. Not | |
775 | yet implemented for GTK. | |
776 | ||
7c913512 | 777 | @param bitmap |
4cc4bfaf | 778 | A valid bitmap. |
7c913512 | 779 | @param colour |
4cc4bfaf | 780 | A colour specifying the transparency RGB values. |
7c913512 | 781 | @param index |
4cc4bfaf | 782 | Index into a palette, specifying the transparency colour. |
23324ae1 FM |
783 | */ |
784 | bool Create(const wxBitmap& bitmap); | |
7c913512 FM |
785 | bool Create(const wxBitmap& bitmap, const wxColour& colour); |
786 | bool Create(const wxBitmap& bitmap, int index); | |
23324ae1 FM |
787 | //@} |
788 | }; | |
e54c96f1 | 789 |