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
}
17 \wxheading{Predefined objects
}
25 \helpref{wxBitmap overview
}{wxbitmapoverview
},
26 \helpref{supported bitmap file formats
}{supportedbitmapformats
},
27 \helpref{wxDC::Blit
}{wxdcblit
},
28 \helpref{wxIcon
}{wxicon
},
\helpref{wxCursor
}{wxcursor
},
\helpref{wxBitmap
}{wxbitmap
},
29 \helpref{wxMemoryDC
}{wxmemorydc
}
31 \latexignore{\rtfignore{\wxheading{Members
}}}
33 \membersection{wxBitmap::wxBitmap
}\label{wxbitmapconstr
}
35 \func{}{wxBitmap
}{\void}
39 \func{}{wxBitmap
}{\param{const wxBitmap\&
}{bitmap
}}
43 \func{}{wxBitmap
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
45 Creates a bitmap from the given data, which can be of arbitrary type.
47 \func{}{wxBitmap
}{\param{const char
}{ bits
[]},
\param{int
}{ width
},
\param{int
}{ height
}\\
48 \param{int
}{ depth =
1}}
50 Creates a bitmap from an array of bits.
52 \func{}{wxBitmap
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
56 \func{}{wxBitmap
}{\param{const char**
}{ bits
}}
58 Creates a bitmap from XPM data.
60 \func{}{wxBitmap
}{\param{const wxString\&
}{name
},
\param{long
}{ type
}}
62 Loads a bitmap from a file or resource.
64 \wxheading{Parameters
}
66 \docparam{bits
}{Specifies an array of pixel values.
}
68 \docparam{width
}{Specifies the width of the bitmap.
}
70 \docparam{height
}{Specifies the height of the bitmap.
}
72 \docparam{depth
}{Specifies the depth of the bitmap. If this is omitted, the display depth of the
75 \docparam{name
}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
76 Its meaning is determined by the
{\it type
} parameter.
}
78 \docparam{type
}{May be one of the following:
82 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP}}}{Load a Windows bitmap file.
}
83 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP\_RESOURCE}}}{Load a Windows bitmap from the resource database.
}
84 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_GIF}}}{Load a GIF bitmap file.
}
85 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XBM}}}{Load an X bitmap file.
}
86 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XPM}}}{Load an XPM bitmap file.
}
87 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_RESOURCE}}}{Load a Windows resource name.
}
90 The validity of these flags depends on the platform and wxWindows configuration.
91 If all possible wxWindows settings are used, the Windows platform supports BMP file, BMP resource,
92 XPM data, and XPM. Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file.
93 Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.
}
97 The first form constructs a bitmap object with no data; an assignment or another member function such as Create
98 or LoadFile must be called subsequently.
100 The second and third forms provide copy constructors. Note that these do not copy the
101 bitmap data, but instead a pointer to the data, keeping a reference count. They are therefore
102 very efficient operations.
104 The fourth form constructs a bitmap from data whose type and value depends on
105 the value of the
{\it type
} argument.
107 The fifth form constructs a (usually monochrome) bitmap from an array of pixel values, under both
110 The sixth form constructs a new bitmap.
112 The seventh form constructs a bitmap from pixmap (XPM) data, if wxWindows has been configured
113 to incorporate this feature.
115 To use this constructor, you must first include an XPM file. For
116 example, assuming that the file
{\tt mybitmap.xpm
} contains an XPM array
117 of character pointers called mybitmap:
120 #include "mybitmap.xpm"
124 wxBitmap *bitmap = new wxBitmap(mybitmap);
127 The eighth form constructs a bitmap from a file or resource.
{\it name
} can refer
128 to a resource name under MS Windows, or a filename under MS Windows and X.
130 Under Windows,
{\it type
} defaults to wxBITMAP
\_TYPE\_BMP\_RESOURCE.
131 Under X,
{\it type
} defaults to wxBITMAP
\_TYPE\_XPM.
135 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}
137 \pythonnote{Constructors supported by wxPython are:
\par
138 \indented{2cm
}{\begin{twocollist
}
139 \twocolitem{\bf{wxBitmap(name, flag)
}}{Loads a bitmap from a file
}
140 \twocolitem{\bf{wxNoRefBitmap(name, flag)
}}{This one won't own the
141 reference, so Python won't call the destructor, this is good for toolbars
142 and such where the parent will manage the bitmap.
}
143 \twocolitem{\bf{wxEmptyBitmap(width, height, depth=-
1)
}}{Creates an
144 empty bitmap with the given specifications
}
148 \membersection{wxBitmap::
\destruct{wxBitmap
}}
150 \func{}{\destruct{wxBitmap
}}{\void}
152 Destroys the wxBitmap object and possibly the underlying bitmap data.
153 Because reference counting is used, the bitmap may not actually be
154 destroyed at this point - only when the reference count is zero will the
157 If the application omits to delete the bitmap explicitly, the bitmap will be
158 destroyed automatically by wxWindows when the application exits.
160 Do not delete a bitmap that is selected into a memory device context.
162 \membersection{wxBitmap::AddHandler
}\label{wxbitmapaddhandler
}
164 \func{static void
}{AddHandler
}{\param{wxBitmapHandler*
}{ handler
}}
166 Adds a handler to the end of the static list of format handlers.
168 \docparam{handler
}{A new bitmap format handler object. There is usually only one instance
169 of a given handler class in an application session.
}
173 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
175 \membersection{wxBitmap::CleanUpHandlers
}
177 \func{static void
}{CleanUpHandlers
}{\void}
179 Deletes all bitmap handlers.
181 This function is called by wxWindows on exit.
183 \membersection{wxBitmap::Create
}
185 \func{virtual bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
187 Creates a fresh bitmap. If the final argument is omitted, the display depth of
190 \func{virtual bool
}{Create
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
192 Creates a bitmap from the given data, which can be of arbitrary type.
194 \wxheading{Parameters
}
196 \docparam{width
}{The width of the bitmap in pixels.
}
198 \docparam{height
}{The height of the bitmap in pixels.
}
200 \docparam{depth
}{The depth of the bitmap in pixels. If this is -
1, the screen depth is used.
}
202 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
204 \docparam{type
}{A bitmap type identifier - see
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for a list
207 \wxheading{Return value
}
209 TRUE if the call succeeded, FALSE otherwise.
213 The first form works on all platforms. The portability of the second form depends on the
218 \helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
}
220 \membersection{wxBitmap::FindHandler
}
222 \func{static wxBitmapHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
224 Finds the handler with the given name.
226 \func{static wxBitmapHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ bitmapType
}}
228 Finds the handler associated with the given extension and type.
230 \func{static wxBitmapHandler*
}{FindHandler
}{\param{long
}{bitmapType
}}
232 Finds the handler associated with the given bitmap type.
234 \docparam{name
}{The handler name.
}
236 \docparam{extension
}{The file extension, such as ``bmp".
}
238 \docparam{bitmapType
}{The bitmap type, such as wxBITMAP
\_TYPE\_BMP.
}
240 \wxheading{Return value
}
242 A pointer to the handler if found, NULL otherwise.
246 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
248 \membersection{wxBitmap::GetDepth
}
250 \constfunc{int
}{GetDepth
}{\void}
252 Gets the colour depth of the bitmap. A value of
1 indicates a
255 \membersection{wxBitmap::GetHandlers
}
257 \func{static wxList\&
}{GetHandlers
}{\void}
259 Returns the static list of bitmap format handlers.
263 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
265 \membersection{wxBitmap::GetHeight
}\label{wxbitmapgetheight
}
267 \constfunc{int
}{GetHeight
}{\void}
269 Gets the height of the bitmap in pixels.
271 \membersection{wxBitmap::GetPalette
}\label{wxbitmapgetpalette
}
273 \constfunc{wxPalette*
}{GetPalette
}{\void}
275 Gets the associated palette (if any) which may have been loaded from a file
276 or set for the bitmap.
280 \helpref{wxPalette
}{wxpalette
}
282 \membersection{wxBitmap::GetMask
}\label{wxbitmapgetmask
}
284 \constfunc{wxMask*
}{GetMask
}{\void}
286 Gets the associated mask (if any) which may have been loaded from a file
287 or set for the bitmap.
291 \helpref{wxBitmap::SetMask
}{wxbitmapsetmask
},
\helpref{wxMask
}{wxmask
}
293 \membersection{wxBitmap::GetWidth
}\label{wxbitmapgetwidth
}
295 \constfunc{int
}{GetWidth
}{\void}
297 Gets the width of the bitmap in pixels.
301 \helpref{wxBitmap::GetHeight
}{wxbitmapgetheight
}
303 \membersection{wxBitmap::InitStandardHandlers
}
305 \func{static void
}{InitStandardHandlers
}{\void}
307 Adds the standard bitmap format handlers, which, depending on wxWindows
308 configuration, can be handlers for Windows bitmap, Windows bitmap resource, and XPM.
310 This function is called by wxWindows on startup.
314 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
316 \membersection{wxBitmap::InsertHandler
}
318 \func{static void
}{InsertHandler
}{\param{wxBitmapHandler*
}{ handler
}}
320 Adds a handler at the start of the static list of format handlers.
322 \docparam{handler
}{A new bitmap format handler object. There is usually only one instance
323 of a given handler class in an application session.
}
327 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
329 \membersection{wxBitmap::LoadFile
}\label{wxbitmaploadfile
}
331 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
333 Loads a bitmap from a file or resource.
335 \wxheading{Parameters
}
337 \docparam{name
}{Either a filename or a Windows resource name.
338 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
340 \docparam{type
}{One of the following values:
344 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Load a Windows bitmap file.
}
345 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP\_RESOURCE}}{Load a Windows bitmap from the resource database.
}
346 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
347 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Load an X bitmap file.
}
348 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load an XPM bitmap file.
}
351 The validity of these flags depends on the platform and wxWindows configuration.
}
353 \wxheading{Return value
}
355 TRUE if the operation succeeded, FALSE otherwise.
359 A palette may be associated with the bitmap if one exists (especially for
360 colour Windows bitmaps), and if the code supports it. You can check
361 if one has been created by using the
\helpref{GetPalette
}{wxbitmapgetpalette
} member.
365 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}
367 \membersection{wxBitmap::Ok
}\label{wxbitmapok
}
369 \constfunc{bool
}{Ok
}{\void}
371 Returns TRUE if bitmap data is present.
373 \membersection{wxBitmap::RemoveHandler
}
375 \func{static bool
}{RemoveHandler
}{\param{const wxString\&
}{name
}}
377 Finds the handler with the given name, and removes it. The handler
380 \docparam{name
}{The handler name.
}
382 \wxheading{Return value
}
384 TRUE if the handler was found and removed, FALSE otherwise.
388 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
390 \membersection{wxBitmap::SaveFile
}\label{wxbitmapsavefile
}
392 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
394 Saves a bitmap in the named file.
396 \wxheading{Parameters
}
398 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
400 \docparam{type
}{One of the following values:
404 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Save a Windows bitmap file.
}
405 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Save a GIF bitmap file.
}
406 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Save an X bitmap file.
}
407 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save an XPM bitmap file.
}
410 The validity of these flags depends on the platform and wxWindows configuration.
}
412 \docparam{palette
}{An optional palette used for saving the bitmap.
}
413 % TODO: this parameter should
414 %probably be eliminated; instead the app should set the palette before saving.
416 \wxheading{Return value
}
418 TRUE if the operation succeeded, FALSE otherwise.
422 Depending on how wxWindows has been configured, not all formats may be available.
426 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}
428 \membersection{wxBitmap::SetDepth
}\label{wxbitmapsetdepth
}
430 \func{void
}{SetDepth
}{\param{int
}{depth
}}
432 Sets the depth member (does not affect the bitmap data).
434 \wxheading{Parameters
}
436 \docparam{depth
}{Bitmap depth.
}
438 \membersection{wxBitmap::SetHeight
}\label{wxbitmapsetheight
}
440 \func{void
}{SetHeight
}{\param{int
}{height
}}
442 Sets the height member (does not affect the bitmap data).
444 \wxheading{Parameters
}
446 \docparam{height
}{Bitmap height in pixels.
}
448 \membersection{wxBitmap::SetMask
}\label{wxbitmapsetmask
}
450 \func{void
}{SetMask
}{\param{wxMask*
}{mask
}}
452 Sets the mask for this bitmap.
456 The bitmap object owns the mask once this has been called.
460 \helpref{wxBitmap::GetMask
}{wxbitmapgetmask
},
\helpref{wxMask
}{wxmask
}
462 \membersection{wxBitmap::SetOk
}
464 \func{void
}{SetOk
}{\param{int
}{isOk
}}
466 Sets the validity member (does not affect the bitmap data).
468 \wxheading{Parameters
}
470 \docparam{isOk
}{Validity flag.
}
472 \membersection{wxBitmap::SetPalette
}\label{wxbitmapsetpalette
}
474 \func{void
}{SetPalette
}{\param{wxPalette*
}{palette
}}
476 Sets the associated palette: it will be deleted in the wxBitmap
477 destructor, so if you do not wish it to be deleted automatically,
478 reset the palette to NULL before the bitmap is deleted.
480 \wxheading{Parameters
}
482 \docparam{palette
}{The palette to set.
}
486 The bitmap object owns the palette once this has been called.
490 \helpref{wxPalette
}{wxpalette
}
492 \membersection{wxBitmap::SetWidth
}
494 \func{void
}{SetWidth
}{\param{int
}{width
}}
496 Sets the width member (does not affect the bitmap data).
498 \wxheading{Parameters
}
500 \docparam{width
}{Bitmap width in pixels.
}
502 \membersection{wxBitmap::operator $=$
}
504 \func{wxBitmap\&
}{operator $=$
}{\param{const wxBitmap\&
}{bitmap
}}
506 Assignment operator. This operator does not copy any data, but instead
507 passes a pointer to the data in
{\it bitmap
} and increments a reference
508 counter. It is a fast operation.
510 \wxheading{Parameters
}
512 \docparam{bitmap
}{Bitmap to assign.
}
514 \wxheading{Return value
}
516 Returns 'this' object.
518 \membersection{wxBitmap::operator $==$
}
520 \func{bool
}{operator $==$
}{\param{const wxBitmap\&
}{bitmap
}}
522 Equality operator. This operator tests whether the internal data pointers are
525 \wxheading{Parameters
}
527 \docparam{bitmap
}{Bitmap to compare with 'this'
}
529 \wxheading{Return value
}
531 Returns TRUE if the bitmaps were effectively equal, FALSE otherwise.
533 \membersection{wxBitmap::operator $!=$
}
535 \func{bool
}{operator $!=$
}{\param{const wxBitmap\&
}{bitmap
}}
537 Inequality operator. This operator tests whether the internal data pointers are
538 unequal (a fast test).
540 \wxheading{Parameters
}
542 \docparam{bitmap
}{Bitmap to compare with 'this'
}
544 \wxheading{Return value
}
546 Returns TRUE if the bitmaps were unequal, FALSE otherwise.
548 \section{\class{wxBitmapHandler
}}\label{wxbitmaphandler
}
550 \overview{Overview
}{wxbitmapoverview
}
552 This is the base class for implementing bitmap file loading/saving, and bitmap creation from data.
553 It is used within wxBitmap and is not normally seen by the application.
555 If you wish to extend the capabilities of wxBitmap, derive a class from wxBitmapHandler
556 and add the handler using
\helpref{wxBitmap::AddHandler
}{wxbitmapaddhandler
} in your
557 application initialisation.
559 \wxheading{Derived from
}
561 \helpref{wxObject
}{wxobject
}
563 \wxheading{Include files
}
569 \helpref{wxBitmap
}{wxbitmap
},
\helpref{wxIcon
}{wxicon
},
\helpref{wxCursor
}{wxcursor
}
571 \latexignore{\rtfignore{\wxheading{Members
}}}
573 \membersection{wxBitmapHandler::wxBitmapHandler
}\label{wxbitmaphandlerconstr
}
575 \func{}{wxBitmapHandler
}{\void}
577 Default constructor. In your own default constructor, initialise the members
578 m
\_name, m
\_extension and m
\_type.
580 \membersection{wxBitmapHandler::
\destruct{wxBitmapHandler
}}
582 \func{}{\destruct{wxBitmapHandler
}}{\void}
584 Destroys the wxBitmapHandler object.
586 \membersection{wxBitmapHandler::Create
}
588 \func{virtual bool
}{Create
}{\param{wxBitmap*
}{bitmap
},
\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
590 Creates a bitmap from the given data, which can be of arbitrary type. The wxBitmap object
{\it bitmap
} is
591 manipulated by this function.
593 \wxheading{Parameters
}
595 \docparam{bitmap
}{The wxBitmap object.
}
597 \docparam{width
}{The width of the bitmap in pixels.
}
599 \docparam{height
}{The height of the bitmap in pixels.
}
601 \docparam{depth
}{The depth of the bitmap in pixels. If this is -
1, the screen depth is used.
}
603 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
605 \docparam{type
}{A bitmap type identifier - see
\helpref{wxBitmapHandler::wxBitmapHandler
}{wxbitmapconstr
} for a list
608 \wxheading{Return value
}
610 TRUE if the call succeeded, FALSE otherwise (the default).
612 \membersection{wxBitmapHandler::GetName
}
614 \constfunc{wxString
}{GetName
}{\void}
616 Gets the name of this handler.
618 \membersection{wxBitmapHandler::GetExtension
}
620 \constfunc{wxString
}{GetExtension
}{\void}
622 Gets the file extension associated with this handler.
624 \membersection{wxBitmapHandler::GetType
}
626 \constfunc{long
}{GetType
}{\void}
628 Gets the bitmap type associated with this handler.
630 \membersection{wxBitmapHandler::LoadFile
}\label{wxbitmaphandlerloadfile
}
632 \func{bool
}{LoadFile
}{\param{wxBitmap*
}{bitmap
},
\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
634 Loads a bitmap from a file or resource, putting the resulting data into
{\it bitmap
}.
636 \wxheading{Parameters
}
638 \docparam{bitmap
}{The bitmap object which is to be affected by this operation.
}
640 \docparam{name
}{Either a filename or a Windows resource name.
641 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
643 \docparam{type
}{See
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for values this can take.
}
645 \wxheading{Return value
}
647 TRUE if the operation succeeded, FALSE otherwise.
651 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}\\
652 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}\\
653 \helpref{wxBitmapHandler::SaveFile
}{wxbitmaphandlersavefile
}
655 \membersection{wxBitmapHandler::SaveFile
}\label{wxbitmaphandlersavefile
}
657 \func{bool
}{SaveFile
}{\param{wxBitmap*
}{bitmap
},
\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
659 Saves a bitmap in the named file.
661 \wxheading{Parameters
}
663 \docparam{bitmap
}{The bitmap object which is to be affected by this operation.
}
665 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
667 \docparam{type
}{See
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for values this can take.
}
669 \docparam{palette
}{An optional palette used for saving the bitmap.
}
671 \wxheading{Return value
}
673 TRUE if the operation succeeded, FALSE otherwise.
677 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}\\
678 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}\\
679 \helpref{wxBitmapHandler::LoadFile
}{wxbitmaphandlerloadfile
}
681 \membersection{wxBitmapHandler::SetName
}
683 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
685 Sets the handler name.
687 \wxheading{Parameters
}
689 \docparam{name
}{Handler name.
}
691 \membersection{wxBitmapHandler::SetExtension
}
693 \func{void
}{SetExtension
}{\param{const wxString\&
}{extension
}}
695 Sets the handler extension.
697 \wxheading{Parameters
}
699 \docparam{extension
}{Handler extension.
}
701 \membersection{wxBitmapHandler::SetType
}
703 \func{void
}{SetType
}{\param{long
}{type
}}
705 Sets the handler type.
707 \wxheading{Parameters
}
709 \docparam{name
}{Handler type.
}