1 \section{\class{wxBitmap
}}\label{wxbitmap
}
3 %\overview{Overview}{wxbitmapoverview}
5 This class encapsulates the concept of a platform-dependent bitmap,
6 either monochrome or colour.
8 \wxheading{Derived from
}
10 \helpref{wxGDIObject
}{wxgdiobject
}\\
11 \helpref{wxObject
}{wxobject
}
15 \helpref{wxBitmap overview
}{wxbitmapoverview
},
\helpref{wxDC::Blit
}{wxdcblit
},
\helpref{wxIcon
}{wxicon
},
\helpref{wxCursor
}{wxcursor
},
\helpref{wxMemoryDC
}{wxmemorydc
}
17 \latexignore{\rtfignore{\wxheading{Members
}}}
19 \membersection{wxBitmap::wxBitmap
}\label{wxbitmapconstr
}
21 \func{}{wxBitmap
}{\void}
25 \func{}{wxBitmap
}{\param{const wxBitmap\&
}{bitmap
}}
29 \func{}{wxBitmap
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
31 Creates a bitmap from the given data, which can be of arbitrary type.
33 \func{}{wxBitmap
}{\param{const char
}{ bits
[]},
\param{int
}{ width
},
\param{int
}{ height
}\\
34 \param{int
}{ depth =
1}}
36 Creates a bitmap from an array of bits.
38 \func{}{wxBitmap
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
42 \func{}{wxBitmap
}{\param{const char**
}{ bits
}}
44 Creates a bitmap from XPM data.
46 \func{}{wxBitmap
}{\param{const wxString\&
}{name
},
\param{long
}{ type
}}
48 Loads a bitmap from a file or resource.
50 \wxheading{Parameters
}
52 \docparam{bits
}{Specifies an array of pixel values.
}
54 \docparam{width
}{Specifies the width of the bitmap.
}
56 \docparam{height
}{Specifies the height of the bitmap.
}
58 \docparam{depth
}{Specifies the depth of the bitmap. If this is omitted, the display depth of the
61 \docparam{name
}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
62 Its meaning is determined by the
{\it type
} parameter.
}
64 \docparam{type
}{May be one of the following:
68 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP}}}{Load a Windows bitmap file.
}
69 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP\_RESOURCE}}}{Load a Windows bitmap from the resource database.
}
70 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_GIF}}}{Load a GIF bitmap file.
}
71 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XBM}}}{Load an X bitmap file.
}
72 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XPM}}}{Load an XPM bitmap file.
}
73 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_RESOURCE}}}{Load a Windows resource name.
}
76 The validity of these flags depends on the platform and wxWindows configuration.
77 If all possible wxWindows settings are used, the Windows platform supports BMP, BMP
\_RESOURCE,
78 XPM
\_DATA, and XPM. Under X, the available formats are BMP, GIF, XBM, and XPM.
}
82 The first form constructs a bitmap object with no data; an assignment or another member function such as Create
83 or LoadFile must be called subsequently.
85 The second and third forms provide copy constructors. Note that these do not copy the
86 bitmap data, but instead a pointer to the data, keeping a reference count. They are therefore
87 very efficient operations.
89 The fourth form constructs a bitmap from data whose type and value depends on
90 the value of the
{\it type
} argument.
92 The fifth form constructs a (usually monochrome) bitmap from an array of pixel values, under both
95 The sixth form constructs a new bitmap.
97 The seventh form constructs a bitmap from pixmap (XPM) data, if wxWindows has been configured
98 to incorporate this feature.
100 To use this constructor, you must first include an XPM file. For
101 example, assuming that the file
{\tt mybitmap.xpm
} contains an XPM array
102 of character pointers called mybitmap:
105 #include "mybitmap.xpm"
109 wxBitmap *bitmap = new wxBitmap(mybitmap);
112 The eighth form constructs a bitmap from a file or resource.
{\it name
} can refer
113 to a resource name under MS Windows, or a filename under MS Windows and X.
115 Under Windows,
{\it type
} defaults to wxBITMAP
\_TYPE\_BMP\_RESOURCE.
116 Under X,
{\it type
} defaults to wxBITMAP
\_TYPE\_XBM.
120 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}
122 \membersection{wxBitmap::
\destruct{wxBitmap
}}
124 \func{}{\destruct{wxBitmap
}}{\void}
126 Destroys the wxBitmap object and possibly the underlying bitmap data.
127 Because reference counting is used, the bitmap may not actually be
128 destroyed at this point - only when the reference count is zero will the
131 If the application omits to delete the bitmap explicitly, the bitmap will be
132 destroyed automatically by wxWindows when the application exits.
134 Do not delete a bitmap that is selected into a memory device context.
136 \membersection{wxBitmap::AddHandler
}\label{wxbitmapaddhandler
}
138 \func{static void
}{AddHandler
}{\param{wxBitmapHandler*
}{ handler
}}
140 Adds a handler to the end of the static list of format handlers.
142 \docparam{handler
}{A new bitmap format handler object. There is usually only one instance
143 of a given handler class in an application session.
}
147 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
149 \membersection{wxBitmap::CleanUpHandlers
}
151 \func{static void
}{CleanUpHandlers
}{\void}
153 Deletes all bitmap handlers.
155 This function is called by wxWindows on exit.
157 \membersection{wxBitmap::Create
}
159 \func{virtual bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
161 Creates a fresh bitmap. If the final argument is omitted, the display depth of
164 \func{virtual bool
}{Create
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
166 Creates a bitmap from the given data, which can be of arbitrary type.
168 \wxheading{Parameters
}
170 \docparam{width
}{The width of the bitmap in pixels.
}
172 \docparam{height
}{The height of the bitmap in pixels.
}
174 \docparam{depth
}{The depth of the bitmap in pixels. If this is -
1, the screen depth is used.
}
176 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
178 \docparam{type
}{A bitmap type identifier - see
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for a list
181 \wxheading{Return value
}
183 TRUE if the call succeeded, FALSE otherwise.
187 The first form works on all platforms. The portability of the second form depends on the
192 \helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
}
194 \membersection{wxBitmap::FindHandler
}
196 \func{static wxBitmapHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
198 Finds the handler with the given name.
200 \func{static wxBitmapHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ bitmapType
}}
202 Finds the handler associated with the given extension and type.
204 \func{static wxBitmapHandler*
}{FindHandler
}{\param{long
}{bitmapType
}}
206 Finds the handler associated with the given bitmap type.
208 \docparam{name
}{The handler name.
}
210 \docparam{extension
}{The file extension, such as ``bmp".
}
212 \docparam{bitmapType
}{The bitmap type, such as wxBITMAP
\_TYPE\_BMP.
}
214 \wxheading{Return value
}
216 A pointer to the handler if found, NULL otherwise.
220 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
222 \membersection{wxBitmap::GetDepth
}
224 \constfunc{int
}{GetDepth
}{\void}
226 Gets the colour depth of the bitmap. A value of
1 indicates a
229 \membersection{wxBitmap::GetHandlers
}
231 \func{static wxList\&
}{GetHandlers
}{\void}
233 Returns the static list of bitmap format handlers.
237 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
239 \membersection{wxBitmap::GetHeight
}\label{wxbitmapgetheight
}
241 \constfunc{int
}{GetHeight
}{\void}
243 Gets the height of the bitmap in pixels.
245 \membersection{wxBitmap::GetPalette
}\label{wxbitmapgetpalette
}
247 \constfunc{wxPalette*
}{GetPalette
}{\void}
249 Gets the associated palette (if any) which may have been loaded from a file
250 or set for the bitmap.
254 \helpref{wxPalette
}{wxpalette
}
256 \membersection{wxBitmap::GetMask
}\label{wxbitmapgetmask
}
258 \constfunc{wxMask*
}{GetMask
}{\void}
260 Gets the associated mask (if any) which may have been loaded from a file
261 or set for the bitmap.
265 \helpref{wxBitmap::SetMask
}{wxbitmapsetmask
},
\helpref{wxMask
}{wxmask
}
267 \membersection{wxBitmap::GetWidth
}\label{wxbitmapgetwidth
}
269 \constfunc{int
}{GetWidth
}{\void}
271 Gets the width of the bitmap in pixels.
275 \helpref{wxBitmap::GetHeight
}{wxbitmapgetheight
}
277 \membersection{wxBitmap::InitStandardHandlers
}
279 \func{static void
}{InitStandardHandlers
}{\void}
281 Adds the standard bitmap format handlers, which, depending on wxWindows
282 configuration, can be handlers for Windows bitmap, Windows bitmap resource, and XPM.
284 This function is called by wxWindows on startup.
288 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
290 \membersection{wxBitmap::InsertHandler
}
292 \func{static void
}{InsertHandler
}{\param{wxBitmapHandler*
}{ handler
}}
294 Adds a handler at the start of the static list of format handlers.
296 \docparam{handler
}{A new bitmap format handler object. There is usually only one instance
297 of a given handler class in an application session.
}
301 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
303 \membersection{wxBitmap::LoadFile
}\label{wxbitmaploadfile
}
305 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
307 Loads a bitmap from a file or resource.
309 \wxheading{Parameters
}
311 \docparam{name
}{Either a filename or a Windows resource name.
312 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
314 \docparam{type
}{One of the following values:
318 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Load a Windows bitmap file.
}
319 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP\_RESOURCE}}{Load a Windows bitmap from the resource database.
}
320 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
321 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Load an X bitmap file.
}
322 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load an XPM bitmap file.
}
325 The validity of these flags depends on the platform and wxWindows configuration.
}
327 \wxheading{Return value
}
329 TRUE if the operation succeeded, FALSE otherwise.
333 A palette may be associated with the bitmap if one exists (especially for
334 colour Windows bitmaps), and if the code supports it. You can check
335 if one has been created by using the
\helpref{GetPalette
}{wxbitmapgetpalette
} member.
339 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}
341 \membersection{wxBitmap::Ok
}\label{wxbitmapok
}
343 \constfunc{bool
}{Ok
}{\void}
345 Returns TRUE if bitmap data is present.
347 \membersection{wxBitmap::RemoveHandler
}
349 \func{static bool
}{RemoveHandler
}{\param{const wxString\&
}{name
}}
351 Finds the handler with the given name, and removes it. The handler
354 \docparam{name
}{The handler name.
}
356 \wxheading{Return value
}
358 TRUE if the handler was found and removed, FALSE otherwise.
362 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
364 \membersection{wxBitmap::SaveFile
}\label{wxbitmapsavefile
}
366 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
368 Saves a bitmap in the named file.
370 \wxheading{Parameters
}
372 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
374 \docparam{type
}{One of the following values:
378 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Save a Windows bitmap file.
}
379 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Save a GIF bitmap file.
}
380 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Save an X bitmap file.
}
381 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save an XPM bitmap file.
}
384 The validity of these flags depends on the platform and wxWindows configuration.
}
386 \docparam{palette
}{An optional palette used for saving the bitmap. TODO: this parameter should
387 probably be eliminated; instead the app should set the palette before saving.
}
389 \wxheading{Return value
}
391 TRUE if the operation succeeded, FALSE otherwise.
395 Depending on how wxWindows has been configured, not all formats may be available.
399 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}
401 \membersection{wxBitmap::SetDepth
}\label{wxbitmapsetdepth
}
403 \func{void
}{SetDepth
}{\param{int
}{depth
}}
405 Sets the depth member (does not affect the bitmap data).
407 \wxheading{Parameters
}
409 \docparam{depth
}{Bitmap depth.
}
411 \membersection{wxBitmap::SetHeight
}\label{wxbitmapsetheight
}
413 \func{void
}{SetHeight
}{\param{int
}{height
}}
415 Sets the height member (does not affect the bitmap data).
417 \wxheading{Parameters
}
419 \docparam{height
}{Bitmap height in pixels.
}
421 \membersection{wxBitmap::SetMask
}\label{wxbitmapsetmask
}
423 \func{void
}{SetMask
}{\param{wxMask*
}{mask
}}
425 Sets the mask for this bitmap.
429 The bitmap object owns the mask once this has been called.
433 \helpref{wxBitmap::GetMask
}{wxbitmapgetmask
},
\helpref{wxMask
}{wxmask
}
435 \membersection{wxBitmap::SetOk
}
437 \func{void
}{SetOk
}{\param{int
}{isOk
}}
439 Sets the validity member (does not affect the bitmap data).
441 \wxheading{Parameters
}
443 \docparam{isOk
}{Validity flag.
}
445 \membersection{wxBitmap::SetPalette
}\label{wxbitmapsetpalette
}
447 \func{void
}{SetPalette
}{\param{wxPalette*
}{palette
}}
449 Sets the associated palette: it will be deleted in the wxBitmap
450 destructor, so if you do not wish it to be deleted automatically,
451 reset the palette to NULL before the bitmap is deleted.
453 \wxheading{Parameters
}
455 \docparam{palette
}{The palette to set.
}
459 The bitmap object owns the palette once this has been called.
463 \helpref{wxPalette
}{wxpalette
}
465 \membersection{wxBitmap::SetWidth
}
467 \func{void
}{SetWidth
}{\param{int
}{width
}}
469 Sets the width member (does not affect the bitmap data).
471 \wxheading{Parameters
}
473 \docparam{width
}{Bitmap width in pixels.
}
475 \membersection{wxBitmap::operator $=$
}
477 \func{wxBitmap\&
}{operator $=$
}{\param{const wxBitmap\&
}{bitmap
}}
479 Assignment operator. This operator does not copy any data, but instead
480 passes a pointer to the data in
{\it bitmap
} and increments a reference
481 counter. It is a fast operation.
483 \wxheading{Parameters
}
485 \docparam{bitmap
}{Bitmap to assign.
}
487 \wxheading{Return value
}
489 Returns 'this' object.
491 \membersection{wxBitmap::operator $==$
}
493 \func{bool
}{operator $==$
}{\param{const wxBitmap\&
}{bitmap
}}
495 Equality operator. This operator tests whether the internal data pointers are
498 \wxheading{Parameters
}
500 \docparam{bitmap
}{Bitmap to compare with 'this'
}
502 \wxheading{Return value
}
504 Returns TRUE if the bitmaps were effectively equal, FALSE otherwise.
506 \membersection{wxBitmap::operator $!=$
}
508 \func{bool
}{operator $!=$
}{\param{const wxBitmap\&
}{bitmap
}}
510 Inequality operator. This operator tests whether the internal data pointers are
511 unequal (a fast test).
513 \wxheading{Parameters
}
515 \docparam{bitmap
}{Bitmap to compare with 'this'
}
517 \wxheading{Return value
}
519 Returns TRUE if the bitmaps were unequal, FALSE otherwise.
521 \section{\class{wxBitmapHandler
}}\label{wxbitmaphandler
}
523 \overview{Overview
}{wxbitmapoverview
}
525 This is the base class for implementing bitmap file loading/saving, and bitmap creation from data.
526 It is used within wxBitmap and is not normally seen by the application.
528 If you wish to extend the capabilities of wxBitmap, derive a class from wxBitmapHandler
529 and add the handler using
\helpref{wxBitmap::AddHandler
}{wxbitmapaddhandler
} in your
530 application initialisation.
532 \wxheading{Derived from
}
534 \helpref{wxObject
}{wxobject
}
538 \helpref{wxBitmap
}{wxbitmap
},
\helpref{wxIcon
}{wxicon
},
\helpref{wxCursor
}{wxcursor
}
540 \latexignore{\rtfignore{\wxheading{Members
}}}
542 \membersection{wxBitmapHandler::wxBitmapHandler
}\label{wxbitmaphandlerconstr
}
544 \func{}{wxBitmapHandler
}{\void}
546 Default constructor. In your own default constructor, initialise the members
547 m
\_name, m
\_extension and m
\_type.
549 \membersection{wxBitmapHandler::
\destruct{wxBitmapHandler
}}
551 \func{}{\destruct{wxBitmapHandler
}}{\void}
553 Destroys the wxBitmapHandler object.
555 \membersection{wxBitmapHandler::Create
}
557 \func{virtual bool
}{Create
}{\param{wxBitmap*
}{bitmap
},
\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
559 Creates a bitmap from the given data, which can be of arbitrary type. The wxBitmap object
{\it bitmap
} is
560 manipulated by this function.
562 \wxheading{Parameters
}
564 \docparam{bitmap
}{The wxBitmap object.
}
566 \docparam{width
}{The width of the bitmap in pixels.
}
568 \docparam{height
}{The height of the bitmap in pixels.
}
570 \docparam{depth
}{The depth of the bitmap in pixels. If this is -
1, the screen depth is used.
}
572 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
574 \docparam{type
}{A bitmap type identifier - see
\helpref{wxBitmapHandler::wxBitmapHandler
}{wxbitmapconstr
} for a list
577 \wxheading{Return value
}
579 TRUE if the call succeeded, FALSE otherwise (the default).
581 \membersection{wxBitmapHandler::GetName
}
583 \constfunc{wxString
}{GetName
}{\void}
585 Gets the name of this handler.
587 \membersection{wxBitmapHandler::GetExtension
}
589 \constfunc{wxString
}{GetExtension
}{\void}
591 Gets the file extension associated with this handler.
593 \membersection{wxBitmapHandler::GetType
}
595 \constfunc{long
}{GetType
}{\void}
597 Gets the bitmap type associated with this handler.
599 \membersection{wxBitmapHandler::LoadFile
}\label{wxbitmaphandlerloadfile
}
601 \func{bool
}{LoadFile
}{\param{wxBitmap*
}{bitmap
},
\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
603 Loads a bitmap from a file or resource, putting the resulting data into
{\it bitmap
}.
605 \wxheading{Parameters
}
607 \docparam{bitmap
}{The bitmap object which is to be affected by this operation.
}
609 \docparam{name
}{Either a filename or a Windows resource name.
610 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
612 \docparam{type
}{See
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for values this can take.
}
614 \wxheading{Return value
}
616 TRUE if the operation succeeded, FALSE otherwise.
620 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}\\
621 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}\\
622 \helpref{wxBitmapHandler::SaveFile
}{wxbitmaphandlersavefile
}
624 \membersection{wxBitmapHandler::SaveFile
}\label{wxbitmaphandlersavefile
}
626 \func{bool
}{SaveFile
}{\param{wxBitmap*
}{bitmap
},
\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
628 Saves a bitmap in the named file.
630 \wxheading{Parameters
}
632 \docparam{bitmap
}{The bitmap object which is to be affected by this operation.
}
634 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
636 \docparam{type
}{See
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for values this can take.
}
638 \docparam{palette
}{An optional palette used for saving the bitmap. TODO: this parameter should
639 probably be eliminated; instead the app should set the palette before saving.
}
641 \wxheading{Return value
}
643 TRUE if the operation succeeded, FALSE otherwise.
647 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}\\
648 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}\\
649 \helpref{wxBitmapHandler::LoadFile
}{wxbitmaphandlerloadfile
}
651 \membersection{wxBitmapHandler::SetName
}
653 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
655 Sets the handler name.
657 \wxheading{Parameters
}
659 \docparam{name
}{Handler name.
}
661 \membersection{wxBitmapHandler::SetExtension
}
663 \func{void
}{SetExtension
}{\param{const wxString\&
}{extension
}}
665 Sets the handler extension.
667 \wxheading{Parameters
}
669 \docparam{extension
}{Handler extension.
}
671 \membersection{wxBitmapHandler::SetType
}
673 \func{void
}{SetType
}{\param{long
}{type
}}
675 Sets the handler type.
677 \wxheading{Parameters
}
679 \docparam{name
}{Handler type.
}