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
}}
27 \func{}{wxBitmap
}{\param{const wxBitmap*
}{bitmap
}}
31 \func{}{wxBitmap
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
33 Creates a bitmap from the given data, which can be of arbitrary type.
35 \func{}{wxBitmap
}{\param{const char
}{ bits
[]},
\param{int
}{ width
},
\param{int
}{ height
}\\
36 \param{int
}{ depth =
1}}
38 Creates a bitmap from an array of bits.
40 \func{}{wxBitmap
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
44 \func{}{wxBitmap
}{\param{const char**
}{ bits
}}
46 Creates a bitmap from XPM data.
48 \func{}{wxBitmap
}{\param{const wxString\&
}{name
},
\param{long
}{ type
}}
50 Loads a bitmap from a file or resource.
52 \wxheading{Parameters
}
54 \docparam{bits
}{Specifies an array of pixel values.
}
56 \docparam{width
}{Specifies the width of the bitmap.
}
58 \docparam{height
}{Specifies the height of the bitmap.
}
60 \docparam{depth
}{Specifies the depth of the bitmap. If this is omitted, the display depth of the
63 \docparam{name
}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
64 Its meaning is determined by the
{\it flags
} parameter.
}
66 \docparam{type
}{May be one of the following:
70 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP}}}{Load a Windows bitmap file.
}
71 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_BMP\_RESOURCE}}}{Load a Windows bitmap from the resource database.
}
72 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_GIF}}}{Load a GIF bitmap file.
}
73 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XBM}}}{Load an X bitmap file.
}
74 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_XPM}}}{Load an XPM bitmap file.
}
75 \twocolitem{{\bf \indexit{wxBITMAP
\_TYPE\_RESOURCE}}}{Load a Windows resource name.
}
78 The validity of these flags depends on the platform and wxWindows configuration.
79 If all possible wxWindows settings are used, the Windows platform supports BMP, BMP
\_RESOURCE,
80 XPM
\_DATA, and XPM. Under X, the available formats are BMP, GIF, XBM, and XPM.
}
84 The first form constructs a bitmap object with no data; an assignment or another member function such as Create
85 or LoadFile must be called subsequently.
87 The second and third forms provide copy constructors. Note that these do not copy the
88 bitmap data, but instead a pointer to the data, keeping a reference count. They are therefore
89 very efficient operations.
91 The fourth form constructs a bitmap from data whose type and value depends on
92 the value of the
{\it type
} argument.
94 The fifth form constructs a (usually monochrome) bitmap from an array of pixel values, under both
97 The sixth form constructs a new bitmap.
99 The seventh form constructs a bitmap from pixmap (XPM) data, if wxWindows has been configured
100 to incorporate this feature.
102 To use this constructor, you must first include an XPM file. For
103 example, assuming that the file
{\tt mybitmap.xpm
} contains an XPM array
104 of character pointers called mybitmap:
107 #include "mybitmap.xpm"
111 wxBitmap *bitmap = new wxBitmap(mybitmap);
114 The eighth form constructs a bitmap from a file or resource.
{\it name
} can refer
115 to a resource name under MS Windows, or a filename under MS Windows and X.
117 Under Windows,
{\it type
} defaults to wxBITMAP
\_TYPE\_BMP\_RESOURCE.
118 Under X,
{\it type
} defaults to wxBITMAP
\_TYPE\_XBM.
122 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}
124 \membersection{wxBitmap::
\destruct{wxBitmap
}}
126 \func{}{\destruct{wxBitmap
}}{\void}
128 Destroys the wxBitmap object and possibly the underlying bitmap data.
129 Because reference counting is used, the bitmap may not actually be
130 destroyed at this point - only when the reference count is zero will the
133 If the application omits to delete the bitmap explicitly, the bitmap will be
134 destroyed automatically by wxWindows when the application exits.
136 Do not delete a bitmap that is selected into a memory device context.
138 \membersection{wxBitmap::AddHandler
}\label{wxbitmapaddhandler
}
140 \func{static void
}{AddHandler
}{\param{wxBitmapHandler*
}{ handler
}}
142 Adds a handler to the end of the static list of format handlers.
144 \docparam{handler
}{A new bitmap format handler object. There is usually only one instance
145 of a given handler class in an application session.
}
149 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
151 \membersection{wxBitmap::CleanUpHandlers
}
153 \func{static void
}{CleanUpHandlers
}{\void}
155 Deletes all bitmap handlers.
157 This function is called by wxWindows on exit.
159 \membersection{wxBitmap::Create
}
161 \func{virtual bool
}{Create
}{\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
163 Creates a fresh bitmap. If the final argument is omitted, the display depth of
166 \func{virtual bool
}{Create
}{\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
168 Creates a bitmap from the given data, which can be of arbitrary type.
170 \wxheading{Parameters
}
172 \docparam{width
}{The width of the bitmap in pixels.
}
174 \docparam{height
}{The height of the bitmap in pixels.
}
176 \docparam{depth
}{The depth of the bitmap in pixels. If this is -
1, the screen depth is used.
}
178 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
180 \docparam{type
}{A bitmap type identifier - see
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for a list
183 \wxheading{Return value
}
185 TRUE if the call succeeded, FALSE otherwise.
189 The first form works on all platforms. The portability of the second form depends on the
194 \helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
}
196 \membersection{wxBitmap::FindHandler
}
198 \func{static wxBitmapHandler*
}{FindHandler
}{\param{const wxString\&
}{name
}}
200 Finds the handler with the given name.
202 \func{static wxBitmapHandler*
}{FindHandler
}{\param{const wxString\&
}{extension
},
\param{long
}{ bitmapType
}}
204 Finds the handler associated with the given extension and type.
206 \func{static wxBitmapHandler*
}{FindHandler
}{\param{long
}{bitmapType
}}
208 Finds the handler associated with the given bitmap type.
210 \docparam{name
}{The handler name.
}
212 \docparam{extension
}{The file extension, such as ``bmp".
}
214 \docparam{bitmapType
}{The bitmap type, such as wxBITMAP
\_TYPE\_BMP.
}
216 \wxheading{Return value
}
218 A pointer to the handler if found, NULL otherwise.
222 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
224 \membersection{wxBitmap::GetDepth
}
226 \constfunc{int
}{GetDepth
}{\void}
228 Gets the colour depth of the bitmap. A value of
1 indicates a
231 \membersection{wxBitmap::GetHandlers
}
233 \func{static wxList\&
}{GetHandlers
}{\void}
235 Returns the static list of bitmap format handlers.
239 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
241 \membersection{wxBitmap::GetHeight
}\label{wxbitmapgetheight
}
243 \constfunc{int
}{GetHeight
}{\void}
245 Gets the height of the bitmap in pixels.
247 \membersection{wxBitmap::GetPalette
}\label{wxbitmapgetpalette
}
249 \constfunc{wxPalette*
}{GetPalette
}{\void}
251 Gets the associated palette (if any) which may have been loaded from a file
252 or set for the bitmap.
256 \helpref{wxPalette
}{wxpalette
}
258 \membersection{wxBitmap::GetMask
}\label{wxbitmapgetmask
}
260 \constfunc{wxMask*
}{GetMask
}{\void}
262 Gets the associated mask if any) which may have been loaded from a file
263 or set for the bitmap.
267 \helpref{wxBitmap::SetMask
}{wxbitmapsetmask
},
\helpref{wxMask
}{wxmask
}
269 \membersection{wxBitmap::GetWidth
}\label{wxbitmapgetwidth
}
271 \constfunc{int
}{GetWidth
}{\void}
273 Gets the width of the bitmap in pixels.
277 \helpref{wxBitmap::GetHeight
}{wxbitmapgetheight
}
279 \membersection{wxBitmap::InitStandardHandlers
}
281 \func{static void
}{InitStandardHandlers
}{\void}
283 Adds the standard bitmap format handlers, which, depending on wxWindows
284 configuration, can be handlers for Windows bitmap, Windows bitmap resource, and XPM.
286 This function is called by wxWindows on startup.
290 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
292 \membersection{wxBitmap::InsertHandler
}
294 \func{static void
}{InsertHandler
}{\param{wxBitmapHandler*
}{ handler
}}
296 Adds a handler at the start of the static list of format handlers.
298 \docparam{handler
}{A new bitmap format handler object. There is usually only one instance
299 of a given handler class in an application session.
}
303 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
305 \membersection{wxBitmap::LoadFile
}\label{wxbitmaploadfile
}
307 \func{bool
}{LoadFile
}{\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
309 Loads a bitmap from a file or resource.
311 \wxheading{Parameters
}
313 \docparam{name
}{Either a filename or a Windows resource name.
314 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
316 \docparam{type
}{One of the following values:
320 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Load a Windows bitmap file.
}
321 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP\_RESOURCE}}{Load a Windows bitmap from the resource database.
}
322 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Load a GIF bitmap file.
}
323 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Load an X bitmap file.
}
324 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Load an XPM bitmap file.
}
327 The validity of these flags depends on the platform and wxWindows configuration.
}
329 \wxheading{Return value
}
331 TRUE if the operation succeeded, FALSE otherwise.
335 A palette may be associated with the bitmap if one exists (especially for
336 colour Windows bitmaps), and if the code supports it. You can check
337 if one has been created by using the
\helpref{GetPalette
}{wxbitmapgetpalette
} member.
341 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}
343 \membersection{wxBitmap::Ok
}\label{wxbitmapok
}
345 \constfunc{bool
}{Ok
}{\void}
347 Returns TRUE if bitmap data is present.
349 \membersection{wxBitmap::RemoveHandler
}
351 \func{static bool
}{RemoveHandler
}{\param{const wxString\&
}{name
}}
353 Finds the handler with the given name, and removes it. The handler
356 \docparam{name
}{The handler name.
}
358 \wxheading{Return value
}
360 TRUE if the handler was found and removed, FALSE otherwise.
364 \helpref{wxBitmapHandler
}{wxbitmaphandler
}
366 \membersection{wxBitmap::SaveFile
}\label{wxbitmapsavefile
}
368 \func{bool
}{SaveFile
}{\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
370 Saves a bitmap in the named file.
372 \wxheading{Parameters
}
374 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
376 \docparam{type
}{One of the following values:
380 \twocolitem{{\bf wxBITMAP
\_TYPE\_BMP}}{Save a Windows bitmap file.
}
381 \twocolitem{{\bf wxBITMAP
\_TYPE\_GIF}}{Save a GIF bitmap file.
}
382 \twocolitem{{\bf wxBITMAP
\_TYPE\_XBM}}{Save an X bitmap file.
}
383 \twocolitem{{\bf wxBITMAP
\_TYPE\_XPM}}{Save an XPM bitmap file.
}
386 The validity of these flags depends on the platform and wxWindows configuration.
}
388 \docparam{palette
}{An optional palette used for saving the bitmap. TODO: this parameter should
389 probably be eliminated; instead the app should set the palette before saving.
}
391 \wxheading{Return value
}
393 TRUE if the operation succeeded, FALSE otherwise.
397 Depending on how wxWindows has been configured, not all formats may be available.
401 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}
403 \membersection{wxBitmap::SetDepth
}\label{wxbitmapsetdepth
}
405 \func{void
}{SetDepth
}{\param{int
}{depth
}}
407 Sets the depth member (does not affect the bitmap data).
409 \wxheading{Parameters
}
411 \docparam{depth
}{Bitmap depth.
}
413 \membersection{wxBitmap::SetHeight
}\label{wxbitmapsetheight
}
415 \func{void
}{SetHeight
}{\param{int
}{height
}}
417 Sets the height member (does not affect the bitmap data).
419 \wxheading{Parameters
}
421 \docparam{height
}{Bitmap height in pixels.
}
423 \membersection{wxBitmap::SetMask
}\label{wxbitmapsetmask
}
425 \func{void
}{SetMask
}{\param{wxMask*
}{mask
}}
427 Sets the mask for this bitmap.
431 The bitmap object owns the mask once this has been called.
435 \helpref{wxBitmap::GetMask
}{wxbitmapgetmask
},
\helpref{wxMask
}{wxmask
}
437 \membersection{wxBitmap::SetOk
}
439 \func{void
}{SetOk
}{\param{int
}{isOk
}}
441 Sets the validity member (does not affect the bitmap data).
443 \wxheading{Parameters
}
445 \docparam{isOk
}{Validity flag.
}
447 \membersection{wxBitmap::SetPalette
}\label{wxbitmapsetpalette
}
449 \func{void
}{SetPalette
}{\param{wxPalette*
}{palette
}}
451 Sets the associated palette: it will be deleted in the wxBitmap
452 destructor, so if you do not wish it to be deleted automatically,
453 reset the palette to NULL before the bitmap is deleted.
455 \wxheading{Parameters
}
457 \docparam{palette
}{The palette to set.
}
461 The bitmap object owns the palette once this has been called.
465 \helpref{wxPalette
}{wxpalette
}
467 \membersection{wxBitmap::SetWidth
}
469 \func{void
}{SetWidth
}{\param{int
}{width
}}
471 Sets the width member (does not affect the bitmap data).
473 \wxheading{Parameters
}
475 \docparam{width
}{Bitmap width in pixels.
}
477 \membersection{wxBitmap::operator $=$
}
479 \func{wxBitmap\&
}{operator $=$
}{\param{const wxBitmap\&
}{bitmap
}}
481 Assignment operator. This operator does not copy any data, but instead
482 passes a pointer to the data in
{\it bitmap
} and increments a reference
483 counter. It is a fast operation.
485 \wxheading{Parameters
}
487 \docparam{bitmap
}{Bitmap to assign.
}
489 \wxheading{Return value
}
491 Returns 'this' object.
493 \membersection{wxBitmap::operator $==$
}
495 \func{bool
}{operator $==$
}{\param{const wxBitmap\&
}{bitmap
}}
497 Equality operator. This operator tests whether the internal data pointers are
500 \wxheading{Parameters
}
502 \docparam{bitmap
}{Bitmap to compare with 'this'
}
504 \wxheading{Return value
}
506 Returns TRUE if the bitmaps were effectively equal, FALSE otherwise.
508 \membersection{wxBitmap::operator $!=$
}
510 \func{bool
}{operator $!=$
}{\param{const wxBitmap\&
}{bitmap
}}
512 Inequality operator. This operator tests whether the internal data pointers are
513 unequal (a fast test).
515 \wxheading{Parameters
}
517 \docparam{bitmap
}{Bitmap to compare with 'this'
}
519 \wxheading{Return value
}
521 Returns TRUE if the bitmaps were unequal, FALSE otherwise.
523 \section{\class{wxBitmapHandler
}}\label{wxbitmaphandler
}
525 \overview{Overview
}{wxbitmapoverview
}
527 This is the base class for implementing bitmap file loading/saving, and bitmap creation from data.
528 It is used within wxBitmap and is not normally seen by the application.
530 If you wish to extend the capabilities of wxBitmap, derive a class from wxBitmapHandler
531 and add the handler using
\helpref{wxBitmap::AddHandler
}{wxbitmapaddhandler
} in your
532 application initialisation.
534 \wxheading{Derived from
}
536 \helpref{wxObject
}{wxobject
}
540 \helpref{wxBitmap
}{wxbitmap
},
\helpref{wxIcon
}{wxicon
},
\helpref{wxCursor
}{wxcursor
}
542 \latexignore{\rtfignore{\wxheading{Members
}}}
544 \membersection{wxBitmapHandler::wxBitmapHandler
}\label{wxbitmaphandlerconstr
}
546 \func{}{wxBitmapHandler
}{\void}
548 Default constructor. In your own default constructor, initialise the members
549 m
\_name, m
\_extension and m
\_type.
551 \membersection{wxBitmapHandler::
\destruct{wxBitmapHandler
}}
553 \func{}{\destruct{wxBitmapHandler
}}{\void}
555 Destroys the wxBitmapHandler object.
557 \membersection{wxBitmapHandler::Create
}
559 \func{virtual bool
}{Create
}{\param{wxBitmap*
}{bitmap
},
\param{void*
}{ data
},
\param{int
}{ type
},
\param{int
}{ width
},
\param{int
}{ height
},
\param{int
}{ depth = -
1}}
561 Creates a bitmap from the given data, which can be of arbitrary type. The wxBitmap object
{\it bitmap
} is
562 manipulated by this function.
564 \wxheading{Parameters
}
566 \docparam{bitmap
}{The wxBitmap object.
}
568 \docparam{width
}{The width of the bitmap in pixels.
}
570 \docparam{height
}{The height of the bitmap in pixels.
}
572 \docparam{depth
}{The depth of the bitmap in pixels. If this is -
1, the screen depth is used.
}
574 \docparam{data
}{Data whose type depends on the value of
{\it type
}.
}
576 \docparam{type
}{A bitmap type identifier - see
\helpref{wxBitmapHandler::wxBitmapHandler
}{wxbitmapconstr
} for a list
579 \wxheading{Return value
}
581 TRUE if the call succeeded, FALSE otherwise (the default).
583 \membersection{wxBitmapHandler::GetName
}
585 \constfunc{wxString
}{GetName
}{\void}
587 Gets the name of this handler.
589 \membersection{wxBitmapHandler::GetExtension
}
591 \constfunc{wxString
}{GetExtension
}{\void}
593 Gets the file extension associated with this handler.
595 \membersection{wxBitmapHandler::GetType
}
597 \constfunc{long
}{GetType
}{\void}
599 Gets the bitmap type associated with this handler.
601 \membersection{wxBitmapHandler::LoadFile
}\label{wxbitmaphandlerloadfile
}
603 \func{bool
}{LoadFile
}{\param{wxBitmap*
}{bitmap
},
\param{const wxString\&
}{ name
},
\param{long
}{ type
}}
605 Loads a bitmap from a file or resource, putting the resulting data into
{\it bitmap
}.
607 \wxheading{Parameters
}
609 \docparam{bitmap
}{The bitmap object which is to be affected by this operation.
}
611 \docparam{name
}{Either a filename or a Windows resource name.
612 The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
614 \docparam{type
}{See
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for values this can take.
}
616 \wxheading{Return value
}
618 TRUE if the operation succeeded, FALSE otherwise.
622 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}\\
623 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}\\
624 \helpref{wxBitmapHandler::SaveFile
}{wxbitmaphandlersavefile
}
626 \membersection{wxBitmapHandler::SaveFile
}\label{wxbitmaphandlersavefile
}
628 \func{bool
}{SaveFile
}{\param{wxBitmap*
}{bitmap
},
\param{const wxString\&
}{name
},
\param{int
}{ type
},
\param{wxPalette*
}{palette = NULL
}}
630 Saves a bitmap in the named file.
632 \wxheading{Parameters
}
634 \docparam{bitmap
}{The bitmap object which is to be affected by this operation.
}
636 \docparam{name
}{A filename. The meaning of
{\it name
} is determined by the
{\it type
} parameter.
}
638 \docparam{type
}{See
\helpref{wxBitmap::wxBitmap
}{wxbitmapconstr
} for values this can take.
}
640 \docparam{palette
}{An optional palette used for saving the bitmap. TODO: this parameter should
641 probably be eliminated; instead the app should set the palette before saving.
}
643 \wxheading{Return value
}
645 TRUE if the operation succeeded, FALSE otherwise.
649 \helpref{wxBitmap::LoadFile
}{wxbitmaploadfile
}\\
650 \helpref{wxBitmap::SaveFile
}{wxbitmapsavefile
}\\
651 \helpref{wxBitmapHandler::LoadFile
}{wxbitmaphandlerloadfile
}
653 \membersection{wxBitmapHandler::SetName
}
655 \func{void
}{SetName
}{\param{const wxString\&
}{name
}}
657 Sets the handler name.
659 \wxheading{Parameters
}
661 \docparam{name
}{Handler name.
}
663 \membersection{wxBitmapHandler::SetExtension
}
665 \func{void
}{SetExtension
}{\param{const wxString\&
}{extension
}}
667 Sets the handler extension.
669 \wxheading{Parameters
}
671 \docparam{extension
}{Handler extension.
}
673 \membersection{wxBitmapHandler::SetType
}
675 \func{void
}{SetType
}{\param{long
}{type
}}
677 Sets the handler type.
679 \wxheading{Parameters
}
681 \docparam{name
}{Handler type.
}