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
},
16 \helpref{supported bitmap file formats
}{supportedbitmapformats
},
17 \helpref{wxDC::Blit
}{wxdcblit
},
18 \helpref{wxIcon
}{wxicon
},
\helpref{wxCursor
}{wxcursor
},
\helpref{wxBitmap
}{wxbitmap
},
19 \helpref{wxMemoryDC
}{wxmemorydc
}
21 \latexignore{\rtfignore{\wxheading{Members
}}}
23 \membersection{wxBitmap::wxBitmap
}\label{wxbitmapconstr
}
25 \func{}{wxBitmap
}{\void}
29 \func{}{wxBitmap
}{\param{const wxBitmap\&
}{bitmap
}}
33 \func{}{wxBitmap
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
35 Creates a bitmap from the given data, which can be of arbitrary type.
37 \func{}{wxBitmap
}{\param{const char
}{ bits
[]},
\param{int
}{ width
},
\param{int
}{ height
}\\
38 \param{int
}{ depth =
1}}
40 Creates a bitmap from an array of bits.
42 \func{}{wxBitmap
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
46 \func{}{wxBitmap
}{\param{const char**
}{ bits
}}
48 Creates a bitmap from XPM data.
50 \func{}{wxBitmap
}{\param{const wxString\&
}{name
},
\param{long
}{ type
}}
52 Loads a bitmap from a file or resource.
54 \wxheading{Parameters
}
56 \docparam{bits
}{Specifies an array of pixel values.
}
58 \docparam{width
}{Specifies the width of the bitmap.
}
60 \docparam{height
}{Specifies the height of the bitmap.
}
62 \docparam{depth
}{Specifies the depth of the bitmap. If this is omitted, the display depth of the
65 \docparam{name
}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
66 Its meaning is determined by the
{\it type
} parameter.
}
68 \docparam{type
}{May be one of the following:
72 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP}}}{Load a Windows bitmap file.
}
73 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP\_RESOURCE}}}{Load a Windows bitmap from the resource database.
}
74 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_GIF}}}{Load a GIF bitmap file.
}
75 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XBM}}}{Load an X bitmap file.
}
76 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XPM}}}{Load an XPM bitmap file.
}
77 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_RESOURCE}}}{Load a Windows resource name.
}
80 The validity of these flags depends on the platform and wxWindows configuration.
81 If all possible wxWindows settings are used, the Windows platform supports BMP file, BMP resource,
82 XPM data, and XPM. Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file.
83 Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.
}
87 The first form constructs a bitmap object with no data; an assignment or another member function such as Create
88 or LoadFile must be called subsequently.
90 The second and third forms provide copy constructors. Note that these do not copy the
91 bitmap data, but instead a pointer to the data, keeping a reference count. They are therefore
92 very efficient operations.
94 The fourth form constructs a bitmap from data whose type and value depends on
95 the value of the
{\it type
} argument.
97 The fifth form constructs a (usually monochrome) bitmap from an array of pixel values, under both
100 The sixth form constructs a new bitmap.
102 The seventh form constructs a bitmap from pixmap (XPM) data, if wxWindows has been configured
103 to incorporate this feature.
105 To use this constructor, you must first include an XPM file. For
106 example, assuming that the file
{\tt mybitmap.xpm
} contains an XPM array
107 of character pointers called mybitmap:
110 #include "mybitmap.xpm"
114 wxBitmap *bitmap = new wxBitmap(mybitmap);
117 The eighth form constructs a bitmap from a file or resource.
{\it name
} can refer
118 to a resource name under MS Windows, or a filename under MS Windows and X.
120 Under Windows,
{\it type
} defaults to wxBITMAP
\_TYPE\_BMP\_RESOURCE.
121 Under X,
{\it type
} defaults to wxBITMAP
\_TYPE\_XPM.
125 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}
127 \membersection{wxBitmap::
\destruct{wxBitmap
}}
129 \func{}{\destruct{wxBitmap
}}{\void}
131 Destroys the wxBitmap object and possibly the underlying bitmap data.
132 Because reference counting is used, the bitmap may not actually be
133 destroyed at this point - only when the reference count is zero will the
136 If the application omits to delete the bitmap explicitly, the bitmap will be
137 destroyed automatically by wxWindows when the application exits.
139 Do not delete a bitmap that is selected into a memory device context.
141 \membersection{wxBitmap::AddHandler
}\label{wxbitmapaddhandler
}
143 \func{static void
}{AddHandler
}{\param{wxBitmapHandler*
}{ handler
}}
145 Adds a handler to the end of the static list of format handlers.
147 \docparam{handler
}{A new bitmap format handler object. There is usually only one instance
148 of a given handler class in an application session.
}
152 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
154 \membersection{wxBitmap::CleanUpHandlers
}
156 \func{static void
}{CleanUpHandlers
}{\void}
158 Deletes all bitmap handlers.
160 This function is called by wxWindows on exit.
162 \membersection{wxBitmap::Create
}
164 \func{virtual bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
166 Creates a fresh bitmap. If the final argument is omitted, the display depth of
169 \func{virtual bool
}{Create
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
171 Creates a bitmap from the given data, which can be of arbitrary type.
173 \wxheading{Parameters
}
175 \docparam{width
}{The width of the bitmap in pixels.
}
177 \docparam{height
}{The height of the bitmap in pixels.
}
179 \docparam{depth
}{The depth of the bitmap in pixels. If this is -
1, the screen depth is used.
}
181 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
183 \docparam{type
}{A bitmap type identifier - see
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for a list
186 \wxheading{Return value
}
188 TRUE if the call succeeded, FALSE otherwise.
192 The first form works on all platforms. The portability of the second form depends on the
197 \helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
}
199 \membersection{wxBitmap::FindHandler
}
201 \func{static wxBitmapHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
203 Finds the handler with the given name.
205 \func{static wxBitmapHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ bitmapType
}}
207 Finds the handler associated with the given extension and type.
209 \func{static wxBitmapHandler*
}{FindHandler
}{\param{long
}{bitmapType
}}
211 Finds the handler associated with the given bitmap type.
213 \docparam{name
}{The handler name.
}
215 \docparam{extension
}{The file extension, such as ``bmp".
}
217 \docparam{bitmapType
}{The bitmap type, such as wxBITMAP
\_TYPE\_BMP.
}
219 \wxheading{Return value
}
221 A pointer to the handler if found, NULL otherwise.
225 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
227 \membersection{wxBitmap::GetDepth
}
229 \constfunc{int
}{GetDepth
}{\void}
231 Gets the colour depth of the bitmap. A value of
1 indicates a
234 \membersection{wxBitmap::GetHandlers
}
236 \func{static wxList\&
}{GetHandlers
}{\void}
238 Returns the static list of bitmap format handlers.
242 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
244 \membersection{wxBitmap::GetHeight
}\label{wxbitmapgetheight
}
246 \constfunc{int
}{GetHeight
}{\void}
248 Gets the height of the bitmap in pixels.
250 \membersection{wxBitmap::GetPalette
}\label{wxbitmapgetpalette
}
252 \constfunc{wxPalette*
}{GetPalette
}{\void}
254 Gets the associated palette (if any) which may have been loaded from a file
255 or set for the bitmap.
259 \helpref{wxPalette
}{wxpalette
}
261 \membersection{wxBitmap::GetMask
}\label{wxbitmapgetmask
}
263 \constfunc{wxMask*
}{GetMask
}{\void}
265 Gets the associated mask (if any) which may have been loaded from a file
266 or set for the bitmap.
270 \helpref{wxBitmap::SetMask
}{wxbitmapsetmask
},
\helpref{wxMask
}{wxmask
}
272 \membersection{wxBitmap::GetWidth
}\label{wxbitmapgetwidth
}
274 \constfunc{int
}{GetWidth
}{\void}
276 Gets the width of the bitmap in pixels.
280 \helpref{wxBitmap::GetHeight
}{wxbitmapgetheight
}
282 \membersection{wxBitmap::InitStandardHandlers
}
284 \func{static void
}{InitStandardHandlers
}{\void}
286 Adds the standard bitmap format handlers, which, depending on wxWindows
287 configuration, can be handlers for Windows bitmap, Windows bitmap resource, and XPM.
289 This function is called by wxWindows on startup.
293 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
295 \membersection{wxBitmap::InsertHandler
}
297 \func{static void
}{InsertHandler
}{\param{wxBitmapHandler*
}{ handler
}}
299 Adds a handler at the start of the static list of format handlers.
301 \docparam{handler
}{A new bitmap format handler object. There is usually only one instance
302 of a given handler class in an application session.
}
306 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
308 \membersection{wxBitmap::LoadFile
}\label{wxbitmaploadfile
}
310 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
312 Loads a bitmap from a file or resource.
314 \wxheading{Parameters
}
316 \docparam{name
}{Either a filename or a Windows resource name.
317 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
319 \docparam{type
}{One of the following values:
323 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Load a Windows bitmap file.
}
324 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP\_RESOURCE}}{Load a Windows bitmap from the resource database.
}
325 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
326 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Load an X bitmap file.
}
327 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load an XPM bitmap file.
}
330 The validity of these flags depends on the platform and wxWindows configuration.
}
332 \wxheading{Return value
}
334 TRUE if the operation succeeded, FALSE otherwise.
338 A palette may be associated with the bitmap if one exists (especially for
339 colour Windows bitmaps), and if the code supports it. You can check
340 if one has been created by using the
\helpref{GetPalette
}{wxbitmapgetpalette
} member.
344 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}
346 \membersection{wxBitmap::Ok
}\label{wxbitmapok
}
348 \constfunc{bool
}{Ok
}{\void}
350 Returns TRUE if bitmap data is present.
352 \membersection{wxBitmap::RemoveHandler
}
354 \func{static bool
}{RemoveHandler
}{\param{const wxString\&
}{name
}}
356 Finds the handler with the given name, and removes it. The handler
359 \docparam{name
}{The handler name.
}
361 \wxheading{Return value
}
363 TRUE if the handler was found and removed, FALSE otherwise.
367 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
369 \membersection{wxBitmap::SaveFile
}\label{wxbitmapsavefile
}
371 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
373 Saves a bitmap in the named file.
375 \wxheading{Parameters
}
377 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
379 \docparam{type
}{One of the following values:
383 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Save a Windows bitmap file.
}
384 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Save a GIF bitmap file.
}
385 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Save an X bitmap file.
}
386 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save an XPM bitmap file.
}
389 The validity of these flags depends on the platform and wxWindows configuration.
}
391 \docparam{palette
}{An optional palette used for saving the bitmap.
}
392 % TODO: this parameter should
393 %probably be eliminated; instead the app should set the palette before saving.
395 \wxheading{Return value
}
397 TRUE if the operation succeeded, FALSE otherwise.
401 Depending on how wxWindows has been configured, not all formats may be available.
405 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}
407 \membersection{wxBitmap::SetDepth
}\label{wxbitmapsetdepth
}
409 \func{void
}{SetDepth
}{\param{int
}{depth
}}
411 Sets the depth member (does not affect the bitmap data).
413 \wxheading{Parameters
}
415 \docparam{depth
}{Bitmap depth.
}
417 \membersection{wxBitmap::SetHeight
}\label{wxbitmapsetheight
}
419 \func{void
}{SetHeight
}{\param{int
}{height
}}
421 Sets the height member (does not affect the bitmap data).
423 \wxheading{Parameters
}
425 \docparam{height
}{Bitmap height in pixels.
}
427 \membersection{wxBitmap::SetMask
}\label{wxbitmapsetmask
}
429 \func{void
}{SetMask
}{\param{wxMask*
}{mask
}}
431 Sets the mask for this bitmap.
435 The bitmap object owns the mask once this has been called.
439 \helpref{wxBitmap::GetMask
}{wxbitmapgetmask
},
\helpref{wxMask
}{wxmask
}
441 \membersection{wxBitmap::SetOk
}
443 \func{void
}{SetOk
}{\param{int
}{isOk
}}
445 Sets the validity member (does not affect the bitmap data).
447 \wxheading{Parameters
}
449 \docparam{isOk
}{Validity flag.
}
451 \membersection{wxBitmap::SetPalette
}\label{wxbitmapsetpalette
}
453 \func{void
}{SetPalette
}{\param{wxPalette*
}{palette
}}
455 Sets the associated palette: it will be deleted in the wxBitmap
456 destructor, so if you do not wish it to be deleted automatically,
457 reset the palette to NULL before the bitmap is deleted.
459 \wxheading{Parameters
}
461 \docparam{palette
}{The palette to set.
}
465 The bitmap object owns the palette once this has been called.
469 \helpref{wxPalette
}{wxpalette
}
471 \membersection{wxBitmap::SetWidth
}
473 \func{void
}{SetWidth
}{\param{int
}{width
}}
475 Sets the width member (does not affect the bitmap data).
477 \wxheading{Parameters
}
479 \docparam{width
}{Bitmap width in pixels.
}
481 \membersection{wxBitmap::operator $=$
}
483 \func{wxBitmap\&
}{operator $=$
}{\param{const wxBitmap\&
}{bitmap
}}
485 Assignment operator. This operator does not copy any data, but instead
486 passes a pointer to the data in
{\it bitmap
} and increments a reference
487 counter. It is a fast operation.
489 \wxheading{Parameters
}
491 \docparam{bitmap
}{Bitmap to assign.
}
493 \wxheading{Return value
}
495 Returns 'this' object.
497 \membersection{wxBitmap::operator $==$
}
499 \func{bool
}{operator $==$
}{\param{const wxBitmap\&
}{bitmap
}}
501 Equality operator. This operator tests whether the internal data pointers are
504 \wxheading{Parameters
}
506 \docparam{bitmap
}{Bitmap to compare with 'this'
}
508 \wxheading{Return value
}
510 Returns TRUE if the bitmaps were effectively equal, FALSE otherwise.
512 \membersection{wxBitmap::operator $!=$
}
514 \func{bool
}{operator $!=$
}{\param{const wxBitmap\&
}{bitmap
}}
516 Inequality operator. This operator tests whether the internal data pointers are
517 unequal (a fast test).
519 \wxheading{Parameters
}
521 \docparam{bitmap
}{Bitmap to compare with 'this'
}
523 \wxheading{Return value
}
525 Returns TRUE if the bitmaps were unequal, FALSE otherwise.
527 \section{\class{wxBitmapHandler
}}\label{wxbitmaphandler
}
529 \overview{Overview
}{wxbitmapoverview
}
531 This is the base class for implementing bitmap file loading/saving, and bitmap creation from data.
532 It is used within wxBitmap and is not normally seen by the application.
534 If you wish to extend the capabilities of wxBitmap, derive a class from wxBitmapHandler
535 and add the handler using
\helpref{wxBitmap::AddHandler
}{wxbitmapaddhandler
} in your
536 application initialisation.
538 \wxheading{Derived from
}
540 \helpref{wxObject
}{wxobject
}
544 \helpref{wxBitmap
}{wxbitmap
},
\helpref{wxIcon
}{wxicon
},
\helpref{wxCursor
}{wxcursor
}
546 \latexignore{\rtfignore{\wxheading{Members
}}}
548 \membersection{wxBitmapHandler::wxBitmapHandler
}\label{wxbitmaphandlerconstr
}
550 \func{}{wxBitmapHandler
}{\void}
552 Default constructor. In your own default constructor, initialise the members
553 m
\_name, m
\_extension and m
\_type.
555 \membersection{wxBitmapHandler::
\destruct{wxBitmapHandler
}}
557 \func{}{\destruct{wxBitmapHandler
}}{\void}
559 Destroys the wxBitmapHandler object.
561 \membersection{wxBitmapHandler::Create
}
563 \func{virtual bool
}{Create
}{\param{wxBitmap*
}{bitmap
},
\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
565 Creates a bitmap from the given data, which can be of arbitrary type. The wxBitmap object
{\it bitmap
} is
566 manipulated by this function.
568 \wxheading{Parameters
}
570 \docparam{bitmap
}{The wxBitmap object.
}
572 \docparam{width
}{The width of the bitmap in pixels.
}
574 \docparam{height
}{The height of the bitmap in pixels.
}
576 \docparam{depth
}{The depth of the bitmap in pixels. If this is -
1, the screen depth is used.
}
578 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
580 \docparam{type
}{A bitmap type identifier - see
\helpref{wxBitmapHandler::wxBitmapHandler
}{wxbitmapconstr
} for a list
583 \wxheading{Return value
}
585 TRUE if the call succeeded, FALSE otherwise (the default).
587 \membersection{wxBitmapHandler::GetName
}
589 \constfunc{wxString
}{GetName
}{\void}
591 Gets the name of this handler.
593 \membersection{wxBitmapHandler::GetExtension
}
595 \constfunc{wxString
}{GetExtension
}{\void}
597 Gets the file extension associated with this handler.
599 \membersection{wxBitmapHandler::GetType
}
601 \constfunc{long
}{GetType
}{\void}
603 Gets the bitmap type associated with this handler.
605 \membersection{wxBitmapHandler::LoadFile
}\label{wxbitmaphandlerloadfile
}
607 \func{bool
}{LoadFile
}{\param{wxBitmap*
}{bitmap
},
\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
609 Loads a bitmap from a file or resource, putting the resulting data into
{\it bitmap
}.
611 \wxheading{Parameters
}
613 \docparam{bitmap
}{The bitmap object which is to be affected by this operation.
}
615 \docparam{name
}{Either a filename or a Windows resource name.
616 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
618 \docparam{type
}{See
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for values this can take.
}
620 \wxheading{Return value
}
622 TRUE if the operation succeeded, FALSE otherwise.
626 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}\\
627 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}\\
628 \helpref{wxBitmapHandler::SaveFile
}{wxbitmaphandlersavefile
}
630 \membersection{wxBitmapHandler::SaveFile
}\label{wxbitmaphandlersavefile
}
632 \func{bool
}{SaveFile
}{\param{wxBitmap*
}{bitmap
},
\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
634 Saves a bitmap in the named file.
636 \wxheading{Parameters
}
638 \docparam{bitmap
}{The bitmap object which is to be affected by this operation.
}
640 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
642 \docparam{type
}{See
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for values this can take.
}
644 \docparam{palette
}{An optional palette used for saving the bitmap.
}
646 \wxheading{Return value
}
648 TRUE if the operation succeeded, FALSE otherwise.
652 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}\\
653 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}\\
654 \helpref{wxBitmapHandler::LoadFile
}{wxbitmaphandlerloadfile
}
656 \membersection{wxBitmapHandler::SetName
}
658 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
660 Sets the handler name.
662 \wxheading{Parameters
}
664 \docparam{name
}{Handler name.
}
666 \membersection{wxBitmapHandler::SetExtension
}
668 \func{void
}{SetExtension
}{\param{const wxString\&
}{extension
}}
670 Sets the handler extension.
672 \wxheading{Parameters
}
674 \docparam{extension
}{Handler extension.
}
676 \membersection{wxBitmapHandler::SetType
}
678 \func{void
}{SetType
}{\param{long
}{type
}}
680 Sets the handler type.
682 \wxheading{Parameters
}
684 \docparam{name
}{Handler type.
}