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
}
13 \wxheading{Include files
}
19 \helpref{wxBitmap overview
}{wxbitmapoverview
},
20 \helpref{supported bitmap file formats
}{supportedbitmapformats
},
21 \helpref{wxDC::Blit
}{wxdcblit
},
22 \helpref{wxIcon
}{wxicon
},
\helpref{wxCursor
}{wxcursor
},
\helpref{wxBitmap
}{wxbitmap
},
23 \helpref{wxMemoryDC
}{wxmemorydc
}
25 \latexignore{\rtfignore{\wxheading{Members
}}}
27 \membersection{wxBitmap::wxBitmap
}\label{wxbitmapconstr
}
29 \func{}{wxBitmap
}{\void}
33 \func{}{wxBitmap
}{\param{const wxBitmap\&
}{bitmap
}}
37 \func{}{wxBitmap
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
39 Creates a bitmap from the given data, which can be of arbitrary type.
41 \func{}{wxBitmap
}{\param{const char
}{ bits
[]},
\param{int
}{ width
},
\param{int
}{ height
}\\
42 \param{int
}{ depth =
1}}
44 Creates a bitmap from an array of bits.
46 \func{}{wxBitmap
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
50 \func{}{wxBitmap
}{\param{const char**
}{ bits
}}
52 Creates a bitmap from XPM data.
54 \func{}{wxBitmap
}{\param{const wxString\&
}{name
},
\param{long
}{ type
}}
56 Loads a bitmap from a file or resource.
58 \wxheading{Parameters
}
60 \docparam{bits
}{Specifies an array of pixel values.
}
62 \docparam{width
}{Specifies the width of the bitmap.
}
64 \docparam{height
}{Specifies the height of the bitmap.
}
66 \docparam{depth
}{Specifies the depth of the bitmap. If this is omitted, the display depth of the
69 \docparam{name
}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
70 Its meaning is determined by the
{\it type
} parameter.
}
72 \docparam{type
}{May be one of the following:
76 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP}}}{Load a Windows bitmap file.
}
77 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP\_RESOURCE}}}{Load a Windows bitmap from the resource database.
}
78 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_GIF}}}{Load a GIF bitmap file.
}
79 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XBM}}}{Load an X bitmap file.
}
80 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XPM}}}{Load an XPM bitmap file.
}
81 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_RESOURCE}}}{Load a Windows resource name.
}
84 The validity of these flags depends on the platform and wxWindows configuration.
85 If all possible wxWindows settings are used, the Windows platform supports BMP file, BMP resource,
86 XPM data, and XPM. Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file.
87 Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.
}
91 The first form constructs a bitmap object with no data; an assignment or another member function such as Create
92 or LoadFile must be called subsequently.
94 The second and third forms provide copy constructors. Note that these do not copy the
95 bitmap data, but instead a pointer to the data, keeping a reference count. They are therefore
96 very efficient operations.
98 The fourth form constructs a bitmap from data whose type and value depends on
99 the value of the
{\it type
} argument.
101 The fifth form constructs a (usually monochrome) bitmap from an array of pixel values, under both
104 The sixth form constructs a new bitmap.
106 The seventh form constructs a bitmap from pixmap (XPM) data, if wxWindows has been configured
107 to incorporate this feature.
109 To use this constructor, you must first include an XPM file. For
110 example, assuming that the file
{\tt mybitmap.xpm
} contains an XPM array
111 of character pointers called mybitmap:
114 #include "mybitmap.xpm"
118 wxBitmap *bitmap = new wxBitmap(mybitmap);
121 The eighth form constructs a bitmap from a file or resource.
{\it name
} can refer
122 to a resource name under MS Windows, or a filename under MS Windows and X.
124 Under Windows,
{\it type
} defaults to wxBITMAP
\_TYPE\_BMP\_RESOURCE.
125 Under X,
{\it type
} defaults to wxBITMAP
\_TYPE\_XPM.
129 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}
131 \pythonnote{Constructors supported by wxPython are:
\par
132 \indented{2cm
}{\begin{twocollist
}
133 \twocolitem{\bf{wxBitmap(name, flag)
}}{Loads a bitmap from a file
}
134 \twocolitem{\bf{wxNoRefBitmap(name, flag)
}}{This one won't own the
135 reference, so Python won't call the destructor, this is good for toolbars
136 and such where the parent will manage the bitmap.
}
137 \twocolitem{\bf{wxEmptyBitmap(width, height, depth=-
1)
}}{Creates an
138 empty bitmap with the given specifications
}
142 \membersection{wxBitmap::
\destruct{wxBitmap
}}
144 \func{}{\destruct{wxBitmap
}}{\void}
146 Destroys the wxBitmap object and possibly the underlying bitmap data.
147 Because reference counting is used, the bitmap may not actually be
148 destroyed at this point - only when the reference count is zero will the
151 If the application omits to delete the bitmap explicitly, the bitmap will be
152 destroyed automatically by wxWindows when the application exits.
154 Do not delete a bitmap that is selected into a memory device context.
156 \membersection{wxBitmap::AddHandler
}\label{wxbitmapaddhandler
}
158 \func{static void
}{AddHandler
}{\param{wxBitmapHandler*
}{ handler
}}
160 Adds a handler to the end of the static list of format handlers.
162 \docparam{handler
}{A new bitmap format handler object. There is usually only one instance
163 of a given handler class in an application session.
}
167 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
169 \membersection{wxBitmap::CleanUpHandlers
}
171 \func{static void
}{CleanUpHandlers
}{\void}
173 Deletes all bitmap handlers.
175 This function is called by wxWindows on exit.
177 \membersection{wxBitmap::Create
}
179 \func{virtual bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
181 Creates a fresh bitmap. If the final argument is omitted, the display depth of
184 \func{virtual bool
}{Create
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
186 Creates a bitmap from the given data, which can be of arbitrary type.
188 \wxheading{Parameters
}
190 \docparam{width
}{The width of the bitmap in pixels.
}
192 \docparam{height
}{The height of the bitmap in pixels.
}
194 \docparam{depth
}{The depth of the bitmap in pixels. If this is -
1, the screen depth is used.
}
196 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
198 \docparam{type
}{A bitmap type identifier - see
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for a list
201 \wxheading{Return value
}
203 TRUE if the call succeeded, FALSE otherwise.
207 The first form works on all platforms. The portability of the second form depends on the
212 \helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
}
214 \membersection{wxBitmap::FindHandler
}
216 \func{static wxBitmapHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
218 Finds the handler with the given name.
220 \func{static wxBitmapHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ bitmapType
}}
222 Finds the handler associated with the given extension and type.
224 \func{static wxBitmapHandler*
}{FindHandler
}{\param{long
}{bitmapType
}}
226 Finds the handler associated with the given bitmap type.
228 \docparam{name
}{The handler name.
}
230 \docparam{extension
}{The file extension, such as ``bmp".
}
232 \docparam{bitmapType
}{The bitmap type, such as wxBITMAP
\_TYPE\_BMP.
}
234 \wxheading{Return value
}
236 A pointer to the handler if found, NULL otherwise.
240 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
242 \membersection{wxBitmap::GetDepth
}
244 \constfunc{int
}{GetDepth
}{\void}
246 Gets the colour depth of the bitmap. A value of
1 indicates a
249 \membersection{wxBitmap::GetHandlers
}
251 \func{static wxList\&
}{GetHandlers
}{\void}
253 Returns the static list of bitmap format handlers.
257 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
259 \membersection{wxBitmap::GetHeight
}\label{wxbitmapgetheight
}
261 \constfunc{int
}{GetHeight
}{\void}
263 Gets the height of the bitmap in pixels.
265 \membersection{wxBitmap::GetPalette
}\label{wxbitmapgetpalette
}
267 \constfunc{wxPalette*
}{GetPalette
}{\void}
269 Gets the associated palette (if any) which may have been loaded from a file
270 or set for the bitmap.
274 \helpref{wxPalette
}{wxpalette
}
276 \membersection{wxBitmap::GetMask
}\label{wxbitmapgetmask
}
278 \constfunc{wxMask*
}{GetMask
}{\void}
280 Gets the associated mask (if any) which may have been loaded from a file
281 or set for the bitmap.
285 \helpref{wxBitmap::SetMask
}{wxbitmapsetmask
},
\helpref{wxMask
}{wxmask
}
287 \membersection{wxBitmap::GetWidth
}\label{wxbitmapgetwidth
}
289 \constfunc{int
}{GetWidth
}{\void}
291 Gets the width of the bitmap in pixels.
295 \helpref{wxBitmap::GetHeight
}{wxbitmapgetheight
}
297 \membersection{wxBitmap::InitStandardHandlers
}
299 \func{static void
}{InitStandardHandlers
}{\void}
301 Adds the standard bitmap format handlers, which, depending on wxWindows
302 configuration, can be handlers for Windows bitmap, Windows bitmap resource, and XPM.
304 This function is called by wxWindows on startup.
308 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
310 \membersection{wxBitmap::InsertHandler
}
312 \func{static void
}{InsertHandler
}{\param{wxBitmapHandler*
}{ handler
}}
314 Adds a handler at the start of the static list of format handlers.
316 \docparam{handler
}{A new bitmap format handler object. There is usually only one instance
317 of a given handler class in an application session.
}
321 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
323 \membersection{wxBitmap::LoadFile
}\label{wxbitmaploadfile
}
325 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
327 Loads a bitmap from a file or resource.
329 \wxheading{Parameters
}
331 \docparam{name
}{Either a filename or a Windows resource name.
332 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
334 \docparam{type
}{One of the following values:
338 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Load a Windows bitmap file.
}
339 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP\_RESOURCE}}{Load a Windows bitmap from the resource database.
}
340 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
341 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Load an X bitmap file.
}
342 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load an XPM bitmap file.
}
345 The validity of these flags depends on the platform and wxWindows configuration.
}
347 \wxheading{Return value
}
349 TRUE if the operation succeeded, FALSE otherwise.
353 A palette may be associated with the bitmap if one exists (especially for
354 colour Windows bitmaps), and if the code supports it. You can check
355 if one has been created by using the
\helpref{GetPalette
}{wxbitmapgetpalette
} member.
359 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}
361 \membersection{wxBitmap::Ok
}\label{wxbitmapok
}
363 \constfunc{bool
}{Ok
}{\void}
365 Returns TRUE if bitmap data is present.
367 \membersection{wxBitmap::RemoveHandler
}
369 \func{static bool
}{RemoveHandler
}{\param{const wxString\&
}{name
}}
371 Finds the handler with the given name, and removes it. The handler
374 \docparam{name
}{The handler name.
}
376 \wxheading{Return value
}
378 TRUE if the handler was found and removed, FALSE otherwise.
382 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
384 \membersection{wxBitmap::SaveFile
}\label{wxbitmapsavefile
}
386 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
388 Saves a bitmap in the named file.
390 \wxheading{Parameters
}
392 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
394 \docparam{type
}{One of the following values:
398 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Save a Windows bitmap file.
}
399 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Save a GIF bitmap file.
}
400 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Save an X bitmap file.
}
401 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save an XPM bitmap file.
}
404 The validity of these flags depends on the platform and wxWindows configuration.
}
406 \docparam{palette
}{An optional palette used for saving the bitmap.
}
407 % TODO: this parameter should
408 %probably be eliminated; instead the app should set the palette before saving.
410 \wxheading{Return value
}
412 TRUE if the operation succeeded, FALSE otherwise.
416 Depending on how wxWindows has been configured, not all formats may be available.
420 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}
422 \membersection{wxBitmap::SetDepth
}\label{wxbitmapsetdepth
}
424 \func{void
}{SetDepth
}{\param{int
}{depth
}}
426 Sets the depth member (does not affect the bitmap data).
428 \wxheading{Parameters
}
430 \docparam{depth
}{Bitmap depth.
}
432 \membersection{wxBitmap::SetHeight
}\label{wxbitmapsetheight
}
434 \func{void
}{SetHeight
}{\param{int
}{height
}}
436 Sets the height member (does not affect the bitmap data).
438 \wxheading{Parameters
}
440 \docparam{height
}{Bitmap height in pixels.
}
442 \membersection{wxBitmap::SetMask
}\label{wxbitmapsetmask
}
444 \func{void
}{SetMask
}{\param{wxMask*
}{mask
}}
446 Sets the mask for this bitmap.
450 The bitmap object owns the mask once this has been called.
454 \helpref{wxBitmap::GetMask
}{wxbitmapgetmask
},
\helpref{wxMask
}{wxmask
}
456 \membersection{wxBitmap::SetOk
}
458 \func{void
}{SetOk
}{\param{int
}{isOk
}}
460 Sets the validity member (does not affect the bitmap data).
462 \wxheading{Parameters
}
464 \docparam{isOk
}{Validity flag.
}
466 \membersection{wxBitmap::SetPalette
}\label{wxbitmapsetpalette
}
468 \func{void
}{SetPalette
}{\param{wxPalette*
}{palette
}}
470 Sets the associated palette: it will be deleted in the wxBitmap
471 destructor, so if you do not wish it to be deleted automatically,
472 reset the palette to NULL before the bitmap is deleted.
474 \wxheading{Parameters
}
476 \docparam{palette
}{The palette to set.
}
480 The bitmap object owns the palette once this has been called.
484 \helpref{wxPalette
}{wxpalette
}
486 \membersection{wxBitmap::SetWidth
}
488 \func{void
}{SetWidth
}{\param{int
}{width
}}
490 Sets the width member (does not affect the bitmap data).
492 \wxheading{Parameters
}
494 \docparam{width
}{Bitmap width in pixels.
}
496 \membersection{wxBitmap::operator $=$
}
498 \func{wxBitmap\&
}{operator $=$
}{\param{const wxBitmap\&
}{bitmap
}}
500 Assignment operator. This operator does not copy any data, but instead
501 passes a pointer to the data in
{\it bitmap
} and increments a reference
502 counter. It is a fast operation.
504 \wxheading{Parameters
}
506 \docparam{bitmap
}{Bitmap to assign.
}
508 \wxheading{Return value
}
510 Returns 'this' object.
512 \membersection{wxBitmap::operator $==$
}
514 \func{bool
}{operator $==$
}{\param{const wxBitmap\&
}{bitmap
}}
516 Equality operator. This operator tests whether the internal data pointers are
519 \wxheading{Parameters
}
521 \docparam{bitmap
}{Bitmap to compare with 'this'
}
523 \wxheading{Return value
}
525 Returns TRUE if the bitmaps were effectively equal, FALSE otherwise.
527 \membersection{wxBitmap::operator $!=$
}
529 \func{bool
}{operator $!=$
}{\param{const wxBitmap\&
}{bitmap
}}
531 Inequality operator. This operator tests whether the internal data pointers are
532 unequal (a fast test).
534 \wxheading{Parameters
}
536 \docparam{bitmap
}{Bitmap to compare with 'this'
}
538 \wxheading{Return value
}
540 Returns TRUE if the bitmaps were unequal, FALSE otherwise.
542 \section{\class{wxBitmapHandler
}}\label{wxbitmaphandler
}
544 \overview{Overview
}{wxbitmapoverview
}
546 This is the base class for implementing bitmap file loading/saving, and bitmap creation from data.
547 It is used within wxBitmap and is not normally seen by the application.
549 If you wish to extend the capabilities of wxBitmap, derive a class from wxBitmapHandler
550 and add the handler using
\helpref{wxBitmap::AddHandler
}{wxbitmapaddhandler
} in your
551 application initialisation.
553 \wxheading{Derived from
}
555 \helpref{wxObject
}{wxobject
}
557 \wxheading{Include files
}
563 \helpref{wxBitmap
}{wxbitmap
},
\helpref{wxIcon
}{wxicon
},
\helpref{wxCursor
}{wxcursor
}
565 \latexignore{\rtfignore{\wxheading{Members
}}}
567 \membersection{wxBitmapHandler::wxBitmapHandler
}\label{wxbitmaphandlerconstr
}
569 \func{}{wxBitmapHandler
}{\void}
571 Default constructor. In your own default constructor, initialise the members
572 m
\_name, m
\_extension and m
\_type.
574 \membersection{wxBitmapHandler::
\destruct{wxBitmapHandler
}}
576 \func{}{\destruct{wxBitmapHandler
}}{\void}
578 Destroys the wxBitmapHandler object.
580 \membersection{wxBitmapHandler::Create
}
582 \func{virtual bool
}{Create
}{\param{wxBitmap*
}{bitmap
},
\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
584 Creates a bitmap from the given data, which can be of arbitrary type. The wxBitmap object
{\it bitmap
} is
585 manipulated by this function.
587 \wxheading{Parameters
}
589 \docparam{bitmap
}{The wxBitmap object.
}
591 \docparam{width
}{The width of the bitmap in pixels.
}
593 \docparam{height
}{The height of the bitmap in pixels.
}
595 \docparam{depth
}{The depth of the bitmap in pixels. If this is -
1, the screen depth is used.
}
597 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
599 \docparam{type
}{A bitmap type identifier - see
\helpref{wxBitmapHandler::wxBitmapHandler
}{wxbitmapconstr
} for a list
602 \wxheading{Return value
}
604 TRUE if the call succeeded, FALSE otherwise (the default).
606 \membersection{wxBitmapHandler::GetName
}
608 \constfunc{wxString
}{GetName
}{\void}
610 Gets the name of this handler.
612 \membersection{wxBitmapHandler::GetExtension
}
614 \constfunc{wxString
}{GetExtension
}{\void}
616 Gets the file extension associated with this handler.
618 \membersection{wxBitmapHandler::GetType
}
620 \constfunc{long
}{GetType
}{\void}
622 Gets the bitmap type associated with this handler.
624 \membersection{wxBitmapHandler::LoadFile
}\label{wxbitmaphandlerloadfile
}
626 \func{bool
}{LoadFile
}{\param{wxBitmap*
}{bitmap
},
\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
628 Loads a bitmap from a file or resource, putting the resulting data into
{\it bitmap
}.
630 \wxheading{Parameters
}
632 \docparam{bitmap
}{The bitmap object which is to be affected by this operation.
}
634 \docparam{name
}{Either a filename or a Windows resource name.
635 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
637 \docparam{type
}{See
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for values this can take.
}
639 \wxheading{Return value
}
641 TRUE if the operation succeeded, FALSE otherwise.
645 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}\\
646 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}\\
647 \helpref{wxBitmapHandler::SaveFile
}{wxbitmaphandlersavefile
}
649 \membersection{wxBitmapHandler::SaveFile
}\label{wxbitmaphandlersavefile
}
651 \func{bool
}{SaveFile
}{\param{wxBitmap*
}{bitmap
},
\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
653 Saves a bitmap in the named file.
655 \wxheading{Parameters
}
657 \docparam{bitmap
}{The bitmap object which is to be affected by this operation.
}
659 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
661 \docparam{type
}{See
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for values this can take.
}
663 \docparam{palette
}{An optional palette used for saving the bitmap.
}
665 \wxheading{Return value
}
667 TRUE if the operation succeeded, FALSE otherwise.
671 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}\\
672 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}\\
673 \helpref{wxBitmapHandler::LoadFile
}{wxbitmaphandlerloadfile
}
675 \membersection{wxBitmapHandler::SetName
}
677 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
679 Sets the handler name.
681 \wxheading{Parameters
}
683 \docparam{name
}{Handler name.
}
685 \membersection{wxBitmapHandler::SetExtension
}
687 \func{void
}{SetExtension
}{\param{const wxString\&
}{extension
}}
689 Sets the handler extension.
691 \wxheading{Parameters
}
693 \docparam{extension
}{Handler extension.
}
695 \membersection{wxBitmapHandler::SetType
}
697 \func{void
}{SetType
}{\param{long
}{type
}}
699 Sets the handler type.
701 \wxheading{Parameters
}
703 \docparam{name
}{Handler type.
}