]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/bitmap.tex
Added wxAutomationObject documentation, changed some BC++ makefiles
[wxWidgets.git] / docs / latex / wx / bitmap.tex
... / ...
CommitLineData
1\section{\class{wxBitmap}}\label{wxbitmap}
2
3%\overview{Overview}{wxbitmapoverview}
4%
5This class encapsulates the concept of a platform-dependent bitmap,
6either monochrome or colour.
7
8\wxheading{Derived from}
9
10\helpref{wxGDIObject}{wxgdiobject}\\
11\helpref{wxObject}{wxobject}
12
13\wxheading{See also}
14
15\helpref{wxBitmap overview}{wxbitmapoverview}, \helpref{wxDC::Blit}{wxdcblit}, \helpref{wxIcon}{wxicon}, \helpref{wxCursor}{wxcursor}, \helpref{wxMemoryDC}{wxmemorydc}
16
17\latexignore{\rtfignore{\wxheading{Members}}}
18
19\membersection{wxBitmap::wxBitmap}\label{wxbitmapconstr}
20
21\func{}{wxBitmap}{\void}
22
23Default constructor.
24
25\func{}{wxBitmap}{\param{const wxBitmap\& }{bitmap}}
26
27\func{}{wxBitmap}{\param{const wxBitmap* }{bitmap}}
28
29Copy constructors.
30
31\func{}{wxBitmap}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
32
33Creates a bitmap from the given data, which can be of arbitrary type.
34
35\func{}{wxBitmap}{\param{const char}{ bits[]}, \param{int}{ width}, \param{int}{ height}\\
36 \param{int}{ depth = 1}}
37
38Creates a bitmap from an array of bits.
39
40\func{}{wxBitmap}{\param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
41
42Creates a new bitmap.
43
44\func{}{wxBitmap}{\param{const char**}{ bits}}
45
46Creates a bitmap from XPM data.
47
48\func{}{wxBitmap}{\param{const wxString\& }{name}, \param{long}{ type}}
49
50Loads a bitmap from a file or resource.
51
52\wxheading{Parameters}
53
54\docparam{bits}{Specifies an array of pixel values.}
55
56\docparam{width}{Specifies the width of the bitmap.}
57
58\docparam{height}{Specifies the height of the bitmap.}
59
60\docparam{depth}{Specifies the depth of the bitmap. If this is omitted, the display depth of the
61screen is used.}
62
63\docparam{name}{This can refer to a resource name under MS Windows, or a filename under MS Windows and X.
64Its meaning is determined by the {\it flags} parameter.}
65
66\docparam{type}{May be one of the following:
67
68\twocolwidtha{5cm}
69\begin{twocollist}
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.}
76\end{twocollist}
77
78The validity of these flags depends on the platform and wxWindows configuration.
79If all possible wxWindows settings are used, the Windows platform supports BMP, BMP\_RESOURCE,
80XPM\_DATA, and XPM. Under X, the available formats are BMP, GIF, XBM, and XPM.}
81
82\wxheading{Remarks}
83
84The first form constructs a bitmap object with no data; an assignment or another member function such as Create
85or LoadFile must be called subsequently.
86
87The second and third forms provide copy constructors. Note that these do not copy the
88bitmap data, but instead a pointer to the data, keeping a reference count. They are therefore
89very efficient operations.
90
91The fourth form constructs a bitmap from data whose type and value depends on
92the value of the {\it type} argument.
93
94The fifth form constructs a (usually monochrome) bitmap from an array of pixel values, under both
95X and Windows.
96
97The sixth form constructs a new bitmap.
98
99The seventh form constructs a bitmap from pixmap (XPM) data, if wxWindows has been configured
100to incorporate this feature.
101
102To use this constructor, you must first include an XPM file. For
103example, assuming that the file {\tt mybitmap.xpm} contains an XPM array
104of character pointers called mybitmap:
105
106\begin{verbatim}
107#include "mybitmap.xpm"
108
109...
110
111wxBitmap *bitmap = new wxBitmap(mybitmap);
112\end{verbatim}
113
114The eighth form constructs a bitmap from a file or resource. {\it name} can refer
115to a resource name under MS Windows, or a filename under MS Windows and X.
116
117Under Windows, {\it type} defaults to wxBITMAP\_TYPE\_BMP\_RESOURCE.
118Under X, {\it type} defaults to wxBITMAP\_TYPE\_XBM.
119
120\wxheading{See also}
121
122\helpref{wxBitmap::LoadFile}{wxbitmaploadfile}
123
124\membersection{wxBitmap::\destruct{wxBitmap}}
125
126\func{}{\destruct{wxBitmap}}{\void}
127
128Destroys the wxBitmap object and possibly the underlying bitmap data.
129Because reference counting is used, the bitmap may not actually be
130destroyed at this point - only when the reference count is zero will the
131data be deleted.
132
133If the application omits to delete the bitmap explicitly, the bitmap will be
134destroyed automatically by wxWindows when the application exits.
135
136Do not delete a bitmap that is selected into a memory device context.
137
138\membersection{wxBitmap::AddHandler}\label{wxbitmapaddhandler}
139
140\func{static void}{AddHandler}{\param{wxBitmapHandler*}{ handler}}
141
142Adds a handler to the end of the static list of format handlers.
143
144\docparam{handler}{A new bitmap format handler object. There is usually only one instance
145of a given handler class in an application session.}
146
147\wxheading{See also}
148
149\helpref{wxBitmapHandler}{wxbitmaphandler}
150
151\membersection{wxBitmap::CleanUpHandlers}
152
153\func{static void}{CleanUpHandlers}{\void}
154
155Deletes all bitmap handlers.
156
157This function is called by wxWindows on exit.
158
159\membersection{wxBitmap::Create}
160
161\func{virtual bool}{Create}{\param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
162
163Creates a fresh bitmap. If the final argument is omitted, the display depth of
164the screen is used.
165
166\func{virtual bool}{Create}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
167
168Creates a bitmap from the given data, which can be of arbitrary type.
169
170\wxheading{Parameters}
171
172\docparam{width}{The width of the bitmap in pixels.}
173
174\docparam{height}{The height of the bitmap in pixels.}
175
176\docparam{depth}{The depth of the bitmap in pixels. If this is -1, the screen depth is used.}
177
178\docparam{data}{Data whose type depends on the value of {\it type}.}
179
180\docparam{type}{A bitmap type identifier - see \helpref{wxBitmap::wxBitmap}{wxbitmapconstr} for a list
181of possible values.}
182
183\wxheading{Return value}
184
185TRUE if the call succeeded, FALSE otherwise.
186
187\wxheading{Remarks}
188
189The first form works on all platforms. The portability of the second form depends on the
190type of data.
191
192\wxheading{See also}
193
194\helpref{wxBitmap::wxBitmap}{wxbitmapconstr}
195
196\membersection{wxBitmap::FindHandler}
197
198\func{static wxBitmapHandler*}{FindHandler}{\param{const wxString\& }{name}}
199
200Finds the handler with the given name.
201
202\func{static wxBitmapHandler*}{FindHandler}{\param{const wxString\& }{extension}, \param{long}{ bitmapType}}
203
204Finds the handler associated with the given extension and type.
205
206\func{static wxBitmapHandler*}{FindHandler}{\param{long }{bitmapType}}
207
208Finds the handler associated with the given bitmap type.
209
210\docparam{name}{The handler name.}
211
212\docparam{extension}{The file extension, such as ``bmp".}
213
214\docparam{bitmapType}{The bitmap type, such as wxBITMAP\_TYPE\_BMP.}
215
216\wxheading{Return value}
217
218A pointer to the handler if found, NULL otherwise.
219
220\wxheading{See also}
221
222\helpref{wxBitmapHandler}{wxbitmaphandler}
223
224\membersection{wxBitmap::GetDepth}
225
226\constfunc{int}{GetDepth}{\void}
227
228Gets the colour depth of the bitmap. A value of 1 indicates a
229monochrome bitmap.
230
231\membersection{wxBitmap::GetHandlers}
232
233\func{static wxList\&}{GetHandlers}{\void}
234
235Returns the static list of bitmap format handlers.
236
237\wxheading{See also}
238
239\helpref{wxBitmapHandler}{wxbitmaphandler}
240
241\membersection{wxBitmap::GetHeight}\label{wxbitmapgetheight}
242
243\constfunc{int}{GetHeight}{\void}
244
245Gets the height of the bitmap in pixels.
246
247\membersection{wxBitmap::GetPalette}\label{wxbitmapgetpalette}
248
249\constfunc{wxPalette*}{GetPalette}{\void}
250
251Gets the associated palette (if any) which may have been loaded from a file
252or set for the bitmap.
253
254\wxheading{See also}
255
256\helpref{wxPalette}{wxpalette}
257
258\membersection{wxBitmap::GetMask}\label{wxbitmapgetmask}
259
260\constfunc{wxMask*}{GetMask}{\void}
261
262Gets the associated mask if any) which may have been loaded from a file
263or set for the bitmap.
264
265\wxheading{See also}
266
267\helpref{wxBitmap::SetMask}{wxbitmapsetmask}, \helpref{wxMask}{wxmask}
268
269\membersection{wxBitmap::GetWidth}\label{wxbitmapgetwidth}
270
271\constfunc{int}{GetWidth}{\void}
272
273Gets the width of the bitmap in pixels.
274
275\wxheading{See also}
276
277\helpref{wxBitmap::GetHeight}{wxbitmapgetheight}
278
279\membersection{wxBitmap::InitStandardHandlers}
280
281\func{static void}{InitStandardHandlers}{\void}
282
283Adds the standard bitmap format handlers, which, depending on wxWindows
284configuration, can be handlers for Windows bitmap, Windows bitmap resource, and XPM.
285
286This function is called by wxWindows on startup.
287
288\wxheading{See also}
289
290\helpref{wxBitmapHandler}{wxbitmaphandler}
291
292\membersection{wxBitmap::InsertHandler}
293
294\func{static void}{InsertHandler}{\param{wxBitmapHandler*}{ handler}}
295
296Adds a handler at the start of the static list of format handlers.
297
298\docparam{handler}{A new bitmap format handler object. There is usually only one instance
299of a given handler class in an application session.}
300
301\wxheading{See also}
302
303\helpref{wxBitmapHandler}{wxbitmaphandler}
304
305\membersection{wxBitmap::LoadFile}\label{wxbitmaploadfile}
306
307\func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type}}
308
309Loads a bitmap from a file or resource.
310
311\wxheading{Parameters}
312
313\docparam{name}{Either a filename or a Windows resource name.
314The meaning of {\it name} is determined by the {\it type} parameter.}
315
316\docparam{type}{One of the following values:
317
318\twocolwidtha{5cm}
319\begin{twocollist}
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.}
325\end{twocollist}
326
327The validity of these flags depends on the platform and wxWindows configuration.}
328
329\wxheading{Return value}
330
331TRUE if the operation succeeded, FALSE otherwise.
332
333\wxheading{Remarks}
334
335A palette may be associated with the bitmap if one exists (especially for
336colour Windows bitmaps), and if the code supports it. You can check
337if one has been created by using the \helpref{GetPalette}{wxbitmapgetpalette} member.
338
339\wxheading{See also}
340
341\helpref{wxBitmap::SaveFile}{wxbitmapsavefile}
342
343\membersection{wxBitmap::Ok}\label{wxbitmapok}
344
345\constfunc{bool}{Ok}{\void}
346
347Returns TRUE if bitmap data is present.
348
349\membersection{wxBitmap::RemoveHandler}
350
351\func{static bool}{RemoveHandler}{\param{const wxString\& }{name}}
352
353Finds the handler with the given name, and removes it. The handler
354is not deleted.
355
356\docparam{name}{The handler name.}
357
358\wxheading{Return value}
359
360TRUE if the handler was found and removed, FALSE otherwise.
361
362\wxheading{See also}
363
364\helpref{wxBitmapHandler}{wxbitmaphandler}
365
366\membersection{wxBitmap::SaveFile}\label{wxbitmapsavefile}
367
368\func{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}, \param{wxPalette* }{palette = NULL}}
369
370Saves a bitmap in the named file.
371
372\wxheading{Parameters}
373
374\docparam{name}{A filename. The meaning of {\it name} is determined by the {\it type} parameter.}
375
376\docparam{type}{One of the following values:
377
378\twocolwidtha{5cm}
379\begin{twocollist}
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.}
384\end{twocollist}
385
386The validity of these flags depends on the platform and wxWindows configuration.}
387
388\docparam{palette}{An optional palette used for saving the bitmap. TODO: this parameter should
389probably be eliminated; instead the app should set the palette before saving.}
390
391\wxheading{Return value}
392
393TRUE if the operation succeeded, FALSE otherwise.
394
395\wxheading{Remarks}
396
397Depending on how wxWindows has been configured, not all formats may be available.
398
399\wxheading{See also}
400
401\helpref{wxBitmap::LoadFile}{wxbitmaploadfile}
402
403\membersection{wxBitmap::SetDepth}\label{wxbitmapsetdepth}
404
405\func{void}{SetDepth}{\param{int }{depth}}
406
407Sets the depth member (does not affect the bitmap data).
408
409\wxheading{Parameters}
410
411\docparam{depth}{Bitmap depth.}
412
413\membersection{wxBitmap::SetHeight}\label{wxbitmapsetheight}
414
415\func{void}{SetHeight}{\param{int }{height}}
416
417Sets the height member (does not affect the bitmap data).
418
419\wxheading{Parameters}
420
421\docparam{height}{Bitmap height in pixels.}
422
423\membersection{wxBitmap::SetMask}\label{wxbitmapsetmask}
424
425\func{void}{SetMask}{\param{wxMask* }{mask}}
426
427Sets the mask for this bitmap.
428
429\wxheading{Remarks}
430
431The bitmap object owns the mask once this has been called.
432
433\wxheading{See also}
434
435\helpref{wxBitmap::GetMask}{wxbitmapgetmask}, \helpref{wxMask}{wxmask}
436
437\membersection{wxBitmap::SetOk}
438
439\func{void}{SetOk}{\param{int }{isOk}}
440
441Sets the validity member (does not affect the bitmap data).
442
443\wxheading{Parameters}
444
445\docparam{isOk}{Validity flag.}
446
447\membersection{wxBitmap::SetPalette}\label{wxbitmapsetpalette}
448
449\func{void}{SetPalette}{\param{wxPalette* }{palette}}
450
451Sets the associated palette: it will be deleted in the wxBitmap
452destructor, so if you do not wish it to be deleted automatically,
453reset the palette to NULL before the bitmap is deleted.
454
455\wxheading{Parameters}
456
457\docparam{palette}{The palette to set.}
458
459\wxheading{Remarks}
460
461The bitmap object owns the palette once this has been called.
462
463\wxheading{See also}
464
465\helpref{wxPalette}{wxpalette}
466
467\membersection{wxBitmap::SetWidth}
468
469\func{void}{SetWidth}{\param{int }{width}}
470
471Sets the width member (does not affect the bitmap data).
472
473\wxheading{Parameters}
474
475\docparam{width}{Bitmap width in pixels.}
476
477\membersection{wxBitmap::operator $=$}
478
479\func{wxBitmap\& }{operator $=$}{\param{const wxBitmap\& }{bitmap}}
480
481Assignment operator. This operator does not copy any data, but instead
482passes a pointer to the data in {\it bitmap} and increments a reference
483counter. It is a fast operation.
484
485\wxheading{Parameters}
486
487\docparam{bitmap}{Bitmap to assign.}
488
489\wxheading{Return value}
490
491Returns 'this' object.
492
493\membersection{wxBitmap::operator $==$}
494
495\func{bool}{operator $==$}{\param{const wxBitmap\& }{bitmap}}
496
497Equality operator. This operator tests whether the internal data pointers are
498equal (a fast test).
499
500\wxheading{Parameters}
501
502\docparam{bitmap}{Bitmap to compare with 'this'}
503
504\wxheading{Return value}
505
506Returns TRUE if the bitmaps were effectively equal, FALSE otherwise.
507
508\membersection{wxBitmap::operator $!=$}
509
510\func{bool}{operator $!=$}{\param{const wxBitmap\& }{bitmap}}
511
512Inequality operator. This operator tests whether the internal data pointers are
513unequal (a fast test).
514
515\wxheading{Parameters}
516
517\docparam{bitmap}{Bitmap to compare with 'this'}
518
519\wxheading{Return value}
520
521Returns TRUE if the bitmaps were unequal, FALSE otherwise.
522
523\section{\class{wxBitmapHandler}}\label{wxbitmaphandler}
524
525\overview{Overview}{wxbitmapoverview}
526
527This is the base class for implementing bitmap file loading/saving, and bitmap creation from data.
528It is used within wxBitmap and is not normally seen by the application.
529
530If you wish to extend the capabilities of wxBitmap, derive a class from wxBitmapHandler
531and add the handler using \helpref{wxBitmap::AddHandler}{wxbitmapaddhandler} in your
532application initialisation.
533
534\wxheading{Derived from}
535
536\helpref{wxObject}{wxobject}
537
538\wxheading{See also}
539
540\helpref{wxBitmap}{wxbitmap}, \helpref{wxIcon}{wxicon}, \helpref{wxCursor}{wxcursor}
541
542\latexignore{\rtfignore{\wxheading{Members}}}
543
544\membersection{wxBitmapHandler::wxBitmapHandler}\label{wxbitmaphandlerconstr}
545
546\func{}{wxBitmapHandler}{\void}
547
548Default constructor. In your own default constructor, initialise the members
549m\_name, m\_extension and m\_type.
550
551\membersection{wxBitmapHandler::\destruct{wxBitmapHandler}}
552
553\func{}{\destruct{wxBitmapHandler}}{\void}
554
555Destroys the wxBitmapHandler object.
556
557\membersection{wxBitmapHandler::Create}
558
559\func{virtual bool}{Create}{\param{wxBitmap* }{bitmap}, \param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
560
561Creates a bitmap from the given data, which can be of arbitrary type. The wxBitmap object {\it bitmap} is
562manipulated by this function.
563
564\wxheading{Parameters}
565
566\docparam{bitmap}{The wxBitmap object.}
567
568\docparam{width}{The width of the bitmap in pixels.}
569
570\docparam{height}{The height of the bitmap in pixels.}
571
572\docparam{depth}{The depth of the bitmap in pixels. If this is -1, the screen depth is used.}
573
574\docparam{data}{Data whose type depends on the value of {\it type}.}
575
576\docparam{type}{A bitmap type identifier - see \helpref{wxBitmapHandler::wxBitmapHandler}{wxbitmapconstr} for a list
577of possible values.}
578
579\wxheading{Return value}
580
581TRUE if the call succeeded, FALSE otherwise (the default).
582
583\membersection{wxBitmapHandler::GetName}
584
585\constfunc{wxString}{GetName}{\void}
586
587Gets the name of this handler.
588
589\membersection{wxBitmapHandler::GetExtension}
590
591\constfunc{wxString}{GetExtension}{\void}
592
593Gets the file extension associated with this handler.
594
595\membersection{wxBitmapHandler::GetType}
596
597\constfunc{long}{GetType}{\void}
598
599Gets the bitmap type associated with this handler.
600
601\membersection{wxBitmapHandler::LoadFile}\label{wxbitmaphandlerloadfile}
602
603\func{bool}{LoadFile}{\param{wxBitmap* }{bitmap}, \param{const wxString\&}{ name}, \param{long}{ type}}
604
605Loads a bitmap from a file or resource, putting the resulting data into {\it bitmap}.
606
607\wxheading{Parameters}
608
609\docparam{bitmap}{The bitmap object which is to be affected by this operation.}
610
611\docparam{name}{Either a filename or a Windows resource name.
612The meaning of {\it name} is determined by the {\it type} parameter.}
613
614\docparam{type}{See \helpref{wxBitmap::wxBitmap}{wxbitmapconstr} for values this can take.}
615
616\wxheading{Return value}
617
618TRUE if the operation succeeded, FALSE otherwise.
619
620\wxheading{See also}
621
622\helpref{wxBitmap::LoadFile}{wxbitmaploadfile}\\
623\helpref{wxBitmap::SaveFile}{wxbitmapsavefile}\\
624\helpref{wxBitmapHandler::SaveFile}{wxbitmaphandlersavefile}
625
626\membersection{wxBitmapHandler::SaveFile}\label{wxbitmaphandlersavefile}
627
628\func{bool}{SaveFile}{\param{wxBitmap* }{bitmap}, \param{const wxString\& }{name}, \param{int}{ type}, \param{wxPalette* }{palette = NULL}}
629
630Saves a bitmap in the named file.
631
632\wxheading{Parameters}
633
634\docparam{bitmap}{The bitmap object which is to be affected by this operation.}
635
636\docparam{name}{A filename. The meaning of {\it name} is determined by the {\it type} parameter.}
637
638\docparam{type}{See \helpref{wxBitmap::wxBitmap}{wxbitmapconstr} for values this can take.}
639
640\docparam{palette}{An optional palette used for saving the bitmap. TODO: this parameter should
641probably be eliminated; instead the app should set the palette before saving.}
642
643\wxheading{Return value}
644
645TRUE if the operation succeeded, FALSE otherwise.
646
647\wxheading{See also}
648
649\helpref{wxBitmap::LoadFile}{wxbitmaploadfile}\\
650\helpref{wxBitmap::SaveFile}{wxbitmapsavefile}\\
651\helpref{wxBitmapHandler::LoadFile}{wxbitmaphandlerloadfile}
652
653\membersection{wxBitmapHandler::SetName}
654
655\func{void}{SetName}{\param{const wxString\& }{name}}
656
657Sets the handler name.
658
659\wxheading{Parameters}
660
661\docparam{name}{Handler name.}
662
663\membersection{wxBitmapHandler::SetExtension}
664
665\func{void}{SetExtension}{\param{const wxString\& }{extension}}
666
667Sets the handler extension.
668
669\wxheading{Parameters}
670
671\docparam{extension}{Handler extension.}
672
673\membersection{wxBitmapHandler::SetType}
674
675\func{void}{SetType}{\param{long }{type}}
676
677Sets the handler type.
678
679\wxheading{Parameters}
680
681\docparam{name}{Handler type.}
682
683