xref: /haiku/docs/user/interface/Bitmap.dox (revision 984f843b917a1c4e077915c5961a6ef1cf8dabc7)
1a33f8fbdSAdrien Destugues/*
2819863d8SJohn Scipione * Copyright 2011 Haiku, Inc. All rights reserved.
3820dca4dSJohn Scipione * Distributed under the terms of the MIT License.
4a33f8fbdSAdrien Destugues *
5820dca4dSJohn Scipione * Authors:
6820dca4dSJohn Scipione *		Axel Dörfler, axeld@pinc-software.de
7820dca4dSJohn Scipione *		John Scipione, jscipione@gmail.com
8820dca4dSJohn Scipione *
9a33f8fbdSAdrien Destugues * Corresponds to:
10131261d2SJohn Scipione *		headers/os/interface/Bitmap.h	 rev 42274
11131261d2SJohn Scipione *		src/kits/interface/Bitmap.cpp	 rev 42274
12a33f8fbdSAdrien Destugues */
13a33f8fbdSAdrien Destugues
14820dca4dSJohn Scipione
15a33f8fbdSAdrien Destugues/*!
16a33f8fbdSAdrien Destugues	\file Bitmap.h
17820dca4dSJohn Scipione	\ingroup interface
18820dca4dSJohn Scipione	\ingroup libbe
19a33f8fbdSAdrien Destugues	\brief Defines the BBitmap class and global operators and functions for
20a33f8fbdSAdrien Destugues	       handling bitmaps.
21a33f8fbdSAdrien Destugues*/
22a33f8fbdSAdrien Destugues
23a33f8fbdSAdrien Destugues
24a33f8fbdSAdrien Destugues/*!
25a33f8fbdSAdrien Destugues	\class BBitmap
26a33f8fbdSAdrien Destugues	\ingroup interface
27a33f8fbdSAdrien Destugues	\ingroup libbe
28a33f8fbdSAdrien Destugues	\brief Access and manipulate digital images commonly known as bitmaps.
29a33f8fbdSAdrien Destugues
30a33f8fbdSAdrien Destugues	A BBitmap is a rectangular map of pixel data. The BBitmap class allows you
31a33f8fbdSAdrien Destugues	to create a bitmap by specifying its pixel data and has operations for
32a33f8fbdSAdrien Destugues	altering and accessing the properties of bitmaps.
33a33f8fbdSAdrien Destugues
34a33f8fbdSAdrien Destugues	To create a BBitmap object use one of the constructor methods below. You
35a33f8fbdSAdrien Destugues	can determine if initialization was successful by calling the InitCheck()
36a33f8fbdSAdrien Destugues	method. You can determine if a BBitmap object is valid at any time by
37a33f8fbdSAdrien Destugues	calling the IsValid() method.
38a33f8fbdSAdrien Destugues
39a33f8fbdSAdrien Destugues	An example of creating a new 32x32 pixel BBitmap object and assigning the
40a33f8fbdSAdrien Destugues	icon of the current application looks like this:
41820dca4dSJohn Scipione
42a33f8fbdSAdrien Destugues\code
43a33f8fbdSAdrien DestuguesBBitmap iconBitmap = new BBitmap(BRect(0, 0, 31, 31), B_RGBA32));
44a33f8fbdSAdrien DestuguesappFileInfo.GetIcon(iconBitmap, B_LARGE_ICON);
45a33f8fbdSAdrien Destugues\endcode
46a33f8fbdSAdrien Destugues
47a33f8fbdSAdrien Destugues	You can access the properties of a bitmap by calling the Bounds(),
48a33f8fbdSAdrien Destugues	Flags(), ColorSpace(), Area(), Bits(), BitsLength(), BytesPerRow(),
49a33f8fbdSAdrien Destugues	and GetOverlayRestrictions() methods.
50a33f8fbdSAdrien Destugues
51a33f8fbdSAdrien Destugues	To directly set the pixel data of a bitmap call the Bits() or SetBits()
52a33f8fbdSAdrien Destugues	methods or you can use the ImportBits() method to copy the bits from an
53a33f8fbdSAdrien Destugues	existing bitmap.
54a33f8fbdSAdrien Destugues
55a33f8fbdSAdrien Destugues	You can also draw into a bitmap by attaching a child BView to the bitmap.
56a33f8fbdSAdrien Destugues	To add and remove child BView's to a bitmap call the AddChild() and
57a33f8fbdSAdrien Destugues	RemoveChild() methods respectively. You can access the child views of a
58a33f8fbdSAdrien Destugues	bitmap by calling the CountChildren(), ChildAt(), and FindView() methods.
59a33f8fbdSAdrien Destugues
60a33f8fbdSAdrien Destugues	For off-screen bitmaps it is important to lock the bitmap before drawing
61a33f8fbdSAdrien Destugues	the pixels and then unlock the bitmap when you are done to prevent
62a33f8fbdSAdrien Destugues	flickering. To lock and unlock a bitmap call the LockBits() and UnLockBits()
63a33f8fbdSAdrien Destugues	methods respectively. To lock and unlock the off-screen window that a
64a33f8fbdSAdrien Destugues	bitmap resides in you should call the Lock() and UnLock() methods. To
65a33f8fbdSAdrien Destugues	determine is a bitmap is currently locked you can call the IsLocked()
66a33f8fbdSAdrien Destugues	method.
6747852bffSJohn Scipione
6847852bffSJohn Scipione	\since BeOS R3
69a33f8fbdSAdrien Destugues*/
70a33f8fbdSAdrien Destugues
71a33f8fbdSAdrien Destugues
72a33f8fbdSAdrien Destugues/*!
73a33f8fbdSAdrien Destugues	\fn BBitmap::BBitmap(BRect bounds, uint32 flags, color_space colorSpace,
74a33f8fbdSAdrien Destugues		int32 bytesPerRow, screen_id screenID)
75a33f8fbdSAdrien Destugues	\brief Creates and initializes a BBitmap object.
76a33f8fbdSAdrien Destugues
77a33f8fbdSAdrien Destugues	\param bounds The bitmap dimensions.
78a33f8fbdSAdrien Destugues	\param flags Creation flags.
79a33f8fbdSAdrien Destugues	\param colorSpace The bitmap's color space.
80a33f8fbdSAdrien Destugues	\param bytesPerRow The number of bytes per row the bitmap should use.
81a33f8fbdSAdrien Destugues		   \c B_ANY_BYTES_PER_ROW to let the constructor choose an appropriate
82a33f8fbdSAdrien Destugues		   value.
83*984f843bSZardshard	\param screenID Currently unused. May be used for multi-monitor support in
84*984f843bSZardshard		   the future.
8547852bffSJohn Scipione
8647852bffSJohn Scipione	\since Haiku R1
87a33f8fbdSAdrien Destugues*/
88a33f8fbdSAdrien Destugues
89a33f8fbdSAdrien Destugues
90a33f8fbdSAdrien Destugues/*!
91a33f8fbdSAdrien Destugues	\fn BBitmap::BBitmap(BRect bounds, color_space colorSpace,
92a33f8fbdSAdrien Destugues		bool acceptsViews, bool needsContiguous)
93a33f8fbdSAdrien Destugues	\brief Creates and initializes a BBitmap object.
94a33f8fbdSAdrien Destugues
95a33f8fbdSAdrien Destugues	\param bounds The bitmap dimensions.
96a33f8fbdSAdrien Destugues	\param colorSpace The bitmap's color space.
97a33f8fbdSAdrien Destugues	\param acceptsViews \c true, if the bitmap shall accept BViews, i.e. if
98a33f8fbdSAdrien Destugues		   it shall be possible to attach BView to the bitmap and draw into
99a33f8fbdSAdrien Destugues		   it.
100a33f8fbdSAdrien Destugues	\param needsContiguous If \c true a physically contiguous chunk of memory
101a33f8fbdSAdrien Destugues		   will be allocated.
10247852bffSJohn Scipione
10347852bffSJohn Scipione	\since BeOS R3
104a33f8fbdSAdrien Destugues*/
105a33f8fbdSAdrien Destugues
106a33f8fbdSAdrien Destugues
107a33f8fbdSAdrien Destugues/*!
108a33f8fbdSAdrien Destugues	\fn BBitmap::BBitmap(const BBitmap* source, bool acceptsViews,
109a33f8fbdSAdrien Destugues		bool needsContiguous)
110a33f8fbdSAdrien Destugues	\brief Creates a BBitmap object as a clone of another bitmap.
111a33f8fbdSAdrien Destugues
112a33f8fbdSAdrien Destugues	\param source The source bitmap.
113a33f8fbdSAdrien Destugues	\param acceptsViews \c true, if the bitmap shall accept BViews, i.e. if
114a33f8fbdSAdrien Destugues		   it shall be possible to attach BView to the bitmap and draw into
115a33f8fbdSAdrien Destugues		   it.
116a33f8fbdSAdrien Destugues	\param needsContiguous If \c true a physically contiguous chunk of memory
117a33f8fbdSAdrien Destugues		   will be allocated.
11847852bffSJohn Scipione
11947852bffSJohn Scipione	\since Haiku R1
120a33f8fbdSAdrien Destugues*/
121a33f8fbdSAdrien Destugues
122a33f8fbdSAdrien Destugues
123a33f8fbdSAdrien Destugues/*!
124a33f8fbdSAdrien Destugues	\fn BBitmap::BBitmap(const BBitmap& source, uint32 flags)
125a33f8fbdSAdrien Destugues	\brief Creates a BBitmap object as a clone of another bitmap.
126a33f8fbdSAdrien Destugues
127a33f8fbdSAdrien Destugues	\param source The source bitmap.
128a33f8fbdSAdrien Destugues	\param flags Creation flags.
12947852bffSJohn Scipione
13047852bffSJohn Scipione	\since Haiku R1
131a33f8fbdSAdrien Destugues*/
132a33f8fbdSAdrien Destugues
133a33f8fbdSAdrien Destugues
134a33f8fbdSAdrien Destugues/*!
135a33f8fbdSAdrien Destugues	\fn BBitmap::BBitmap(const BBitmap& source)
136a33f8fbdSAdrien Destugues	\brief Creates a BBitmap object as a clone of another bitmap.
137a33f8fbdSAdrien Destugues
138a33f8fbdSAdrien Destugues	\param source The source bitmap.
13947852bffSJohn Scipione
14047852bffSJohn Scipione	\since Haiku R1
14147852bffSJohn Scipione*/
14247852bffSJohn Scipione
14347852bffSJohn Scipione
14447852bffSJohn Scipione/*!
145*984f843bSZardshard	\fn BBitmap::BBitmap(area_id area, ptrdiff_t areaOffset,
146*984f843bSZardshard		BRect bounds, uint32 flags, color_space colorSpace,
147*984f843bSZardshard		int32 bytesPerRow, screen_id screenID)
148*984f843bSZardshard	\brief Creates a BBitmap object inside of an existing memory area.
149*984f843bSZardshard
150*984f843bSZardshard	This method is useful if you want to create a BBitmap on top of existing
151*984f843bSZardshard	memory or want to share a BBitmap between two or more applications.
152*984f843bSZardshard
153*984f843bSZardshard	This BBitmap should be deleted before the area is deleted.
154*984f843bSZardshard
155*984f843bSZardshard	\param area The memory area to use
156*984f843bSZardshard	\param areaOffset Offset within the memory area to place bitmap.
157*984f843bSZardshard	\param bounds The bitmap dimensions.
158*984f843bSZardshard	\param flags Creation flags.
159*984f843bSZardshard	\param colorSpace The bitmap's color space.
160*984f843bSZardshard	\param bytesPerRow The number of bytes per row the bitmap should use.
161*984f843bSZardshard		   \c B_ANY_BYTES_PER_ROW to let the constructor choose an appropriate
162*984f843bSZardshard		   value.
163*984f843bSZardshard	\param screenID Currently unused. May be used for multi-monitor support in
164*984f843bSZardshard		   the future.
165*984f843bSZardshard
166*984f843bSZardshard	\since Haiku R1
167*984f843bSZardshard*/
168*984f843bSZardshard
169*984f843bSZardshard
170*984f843bSZardshard/*!
17147852bffSJohn Scipione	\fn BBitmap::BBitmap(BMessage* data)
17247852bffSJohn Scipione	\brief Unarchives a bitmap from a BMessage.
17347852bffSJohn Scipione
17447852bffSJohn Scipione	\param data The archive.
17547852bffSJohn Scipione
17647852bffSJohn Scipione	\since BeOS R3
177a33f8fbdSAdrien Destugues*/
178a33f8fbdSAdrien Destugues
179a33f8fbdSAdrien Destugues
180a33f8fbdSAdrien Destugues/*!
181a33f8fbdSAdrien Destugues	\fn BBitmap::~BBitmap()
182a33f8fbdSAdrien Destugues	\brief Destructor Method
183a33f8fbdSAdrien Destugues
184a33f8fbdSAdrien Destugues	Frees all resources associated with this object.
18547852bffSJohn Scipione
18647852bffSJohn Scipione	\since BeOS R3
187a33f8fbdSAdrien Destugues*/
188a33f8fbdSAdrien Destugues
189a33f8fbdSAdrien Destugues
190a33f8fbdSAdrien Destugues/*!
191a33f8fbdSAdrien Destugues	\name Archiving
192a33f8fbdSAdrien Destugues*/
193a33f8fbdSAdrien Destugues
194a33f8fbdSAdrien Destugues
195a33f8fbdSAdrien Destugues//! @{
196a33f8fbdSAdrien Destugues
197a33f8fbdSAdrien Destugues
198a33f8fbdSAdrien Destugues/*!
199a33f8fbdSAdrien Destugues	\fn BArchivable* BBitmap::Instantiate(BMessage* data)
200a33f8fbdSAdrien Destugues	\brief Instantiates a BBitmap from an archive.
201a33f8fbdSAdrien Destugues
202a33f8fbdSAdrien Destugues	\param data The archive.
20347852bffSJohn Scipione	\return A bitmap reconstructed from the archive or \c NULL if an error
204a33f8fbdSAdrien Destugues	        occurred.
20547852bffSJohn Scipione
20647852bffSJohn Scipione	\since BeOS R3
207a33f8fbdSAdrien Destugues*/
208a33f8fbdSAdrien Destugues
209a33f8fbdSAdrien Destugues
210a33f8fbdSAdrien Destugues/*!
211a33f8fbdSAdrien Destugues	\fn status_t BBitmap::Archive(BMessage* data, bool deep) const
212a33f8fbdSAdrien Destugues	\brief Archives the BBitmap object.
213a33f8fbdSAdrien Destugues
214a33f8fbdSAdrien Destugues	\param data The archive.
215a33f8fbdSAdrien Destugues	\param deep if \c true, child object will be archived as well.
21647852bffSJohn Scipione
217a33f8fbdSAdrien Destugues	\return \c B_OK, if everything went fine, an error code otherwise.
21847852bffSJohn Scipione
21947852bffSJohn Scipione	\since BeOS R3
220a33f8fbdSAdrien Destugues*/
221a33f8fbdSAdrien Destugues
222a33f8fbdSAdrien Destugues
223a33f8fbdSAdrien Destugues//! @}
224a33f8fbdSAdrien Destugues
225a33f8fbdSAdrien Destugues
226a33f8fbdSAdrien Destugues/*!
227a33f8fbdSAdrien Destugues	\fn status_t BBitmap::InitCheck() const
228a33f8fbdSAdrien Destugues	\brief Gets the status of the constructor.
229a33f8fbdSAdrien Destugues
230a33f8fbdSAdrien Destugues	\returns B_OK if initialization succeeded, otherwise returns an
231a33f8fbdSAdrien Destugues	         error status.
23247852bffSJohn Scipione
23347852bffSJohn Scipione
23447852bffSJohn Scipione	\since Haiku R1
235a33f8fbdSAdrien Destugues*/
236a33f8fbdSAdrien Destugues
237a33f8fbdSAdrien Destugues
238a33f8fbdSAdrien Destugues/*!
239a33f8fbdSAdrien Destugues	\fn bool BBitmap::IsValid() const
240a33f8fbdSAdrien Destugues	\brief Determines whether or not the BBitmap object is valid.
241a33f8fbdSAdrien Destugues
242a33f8fbdSAdrien Destugues	\return \c true, if the object is properly initialized, \c false otherwise.
24347852bffSJohn Scipione
24447852bffSJohn Scipione	\since BeOS R3
245a33f8fbdSAdrien Destugues*/
246a33f8fbdSAdrien Destugues
247a33f8fbdSAdrien Destugues
248a33f8fbdSAdrien Destugues/*!
249a33f8fbdSAdrien Destugues	\name Locking
250a33f8fbdSAdrien Destugues*/
251a33f8fbdSAdrien Destugues
252a33f8fbdSAdrien Destugues
253a33f8fbdSAdrien Destugues//! @{
254a33f8fbdSAdrien Destugues
255a33f8fbdSAdrien Destugues
256a33f8fbdSAdrien Destugues/*!
257a33f8fbdSAdrien Destugues	\fn status_t BBitmap::LockBits(uint32* state)
258a33f8fbdSAdrien Destugues	\brief Locks the bitmap bits so that they cannot be relocated.
259a33f8fbdSAdrien Destugues
260a33f8fbdSAdrien Destugues	This is currently only used for overlay bitmaps; whenever you
261a33f8fbdSAdrien Destugues	need to access their Bits() you must lock them first.
262a33f8fbdSAdrien Destugues	On resolution change overlay bitmaps can be relocated in memory;
263a33f8fbdSAdrien Destugues	using this call prevents you from accessing an invalid pointer
264a33f8fbdSAdrien Destugues	and clobbering memory that doesn't belong you.
265a33f8fbdSAdrien Destugues
266a33f8fbdSAdrien Destugues	\param state Unused
267a33f8fbdSAdrien Destugues	\returns \c B_OK on success or an error status code.
26847852bffSJohn Scipione
26947852bffSJohn Scipione	\since Haiku R1
270a33f8fbdSAdrien Destugues*/
271a33f8fbdSAdrien Destugues
272a33f8fbdSAdrien Destugues
273a33f8fbdSAdrien Destugues/*!
274a33f8fbdSAdrien Destugues	\fn void BBitmap::UnlockBits()
275a33f8fbdSAdrien Destugues	\brief Unlocks the bitmap's buffer.
276a33f8fbdSAdrien Destugues
277a33f8fbdSAdrien Destugues	Counterpart to BBitmap::LockBits().
27847852bffSJohn Scipione
27947852bffSJohn Scipione	\since Haiku R1
280a33f8fbdSAdrien Destugues*/
281a33f8fbdSAdrien Destugues
282a33f8fbdSAdrien Destugues
283a33f8fbdSAdrien Destugues/*!
284a33f8fbdSAdrien Destugues	\fn bool BBitmap::Lock()
285a33f8fbdSAdrien Destugues	\brief Locks the off-screen window that belongs to the bitmap.
286a33f8fbdSAdrien Destugues
287a33f8fbdSAdrien Destugues	The bitmap must accept views, if locking should work.
288a33f8fbdSAdrien Destugues
289a33f8fbdSAdrien Destugues	\returns \c true, if the lock was acquired successfully.
29047852bffSJohn Scipione
29147852bffSJohn Scipione	\since BeOS R3
292a33f8fbdSAdrien Destugues*/
293a33f8fbdSAdrien Destugues
294a33f8fbdSAdrien Destugues
295a33f8fbdSAdrien Destugues/*!
296a33f8fbdSAdrien Destugues	\fn void BBitmap::Unlock()
297a33f8fbdSAdrien Destugues	\brief Unlocks the off-screen window that belongs to the bitmap.
298a33f8fbdSAdrien Destugues
299a33f8fbdSAdrien Destugues	The bitmap must accept views, if locking should work.
30047852bffSJohn Scipione
30147852bffSJohn Scipione	\since BeOS R3
302a33f8fbdSAdrien Destugues*/
303a33f8fbdSAdrien Destugues
304a33f8fbdSAdrien Destugues
305a33f8fbdSAdrien Destugues/*!
306a33f8fbdSAdrien Destugues	\fn bool BBitmap::IsLocked() const
307a33f8fbdSAdrien Destugues	\brief Determines whether or not the bitmap's off-screen window is locked.
308a33f8fbdSAdrien Destugues
309a33f8fbdSAdrien Destugues	The bitmap must accept views, if locking should work.
310a33f8fbdSAdrien Destugues
311a33f8fbdSAdrien Destugues	\return \c true, if the caller owns a lock , \c false otherwise.
31247852bffSJohn Scipione
31347852bffSJohn Scipione	\since BeOS R4
314a33f8fbdSAdrien Destugues*/
315a33f8fbdSAdrien Destugues
316a33f8fbdSAdrien Destugues
317a33f8fbdSAdrien Destugues//! @}
318a33f8fbdSAdrien Destugues
319a33f8fbdSAdrien Destugues
320a33f8fbdSAdrien Destugues/*!
321a33f8fbdSAdrien Destugues	\name Accessors
322a33f8fbdSAdrien Destugues*/
323a33f8fbdSAdrien Destugues
324a33f8fbdSAdrien Destugues
325a33f8fbdSAdrien Destugues//! @{
326a33f8fbdSAdrien Destugues
327a33f8fbdSAdrien Destugues
328a33f8fbdSAdrien Destugues/*!
329a33f8fbdSAdrien Destugues	\fn area_id BBitmap::Area() const
330a33f8fbdSAdrien Destugues	\brief Gets the ID of the area the bitmap data reside in.
331a33f8fbdSAdrien Destugues
332a33f8fbdSAdrien Destugues	\return The ID of the area the bitmap data reside in.
33347852bffSJohn Scipione
33447852bffSJohn Scipione	\since Haiku R1
335a33f8fbdSAdrien Destugues*/
336a33f8fbdSAdrien Destugues
337a33f8fbdSAdrien Destugues
338a33f8fbdSAdrien Destugues/*!
339a33f8fbdSAdrien Destugues	\fn void* BBitmap::Bits() const
340a33f8fbdSAdrien Destugues	\brief Gets the pointer to the bitmap data.
341a33f8fbdSAdrien Destugues
342a33f8fbdSAdrien Destugues	\return The pointer to the bitmap data.
34347852bffSJohn Scipione
34447852bffSJohn Scipione	\since BeOS R3
345a33f8fbdSAdrien Destugues*/
346a33f8fbdSAdrien Destugues
347a33f8fbdSAdrien Destugues
348a33f8fbdSAdrien Destugues/*!
349a33f8fbdSAdrien Destugues	\fn int32 BBitmap::BitsLength() const
350a33f8fbdSAdrien Destugues	\brief Gets the length of the bitmap data.
351a33f8fbdSAdrien Destugues
352a33f8fbdSAdrien Destugues	\return The length of the bitmap data as an int32.
35347852bffSJohn Scipione
35447852bffSJohn Scipione	\since BeOS R3
355a33f8fbdSAdrien Destugues*/
356a33f8fbdSAdrien Destugues
357a33f8fbdSAdrien Destugues
358a33f8fbdSAdrien Destugues/*!
359a33f8fbdSAdrien Destugues	\fn int32 BBitmap::BytesPerRow() const
360a33f8fbdSAdrien Destugues	\brief Gets the number of bytes used to store a row of bitmap data.
361a33f8fbdSAdrien Destugues
362a33f8fbdSAdrien Destugues	\return The number of bytes used to store a row of bitmap data.
36347852bffSJohn Scipione
36447852bffSJohn Scipione	\since BeOS R3
365a33f8fbdSAdrien Destugues*/
366a33f8fbdSAdrien Destugues
367a33f8fbdSAdrien Destugues
368a33f8fbdSAdrien Destugues/*!
369a33f8fbdSAdrien Destugues	\fn color_space BBitmap::ColorSpace() const
370a33f8fbdSAdrien Destugues	\brief Gets the bitmap's color space.
371a33f8fbdSAdrien Destugues
372a33f8fbdSAdrien Destugues	\return The bitmap's color space.
37347852bffSJohn Scipione
37447852bffSJohn Scipione	\since BeOS R3
375a33f8fbdSAdrien Destugues*/
376a33f8fbdSAdrien Destugues
377a33f8fbdSAdrien Destugues
378a33f8fbdSAdrien Destugues/*!
379a33f8fbdSAdrien Destugues	\fn BRect BBitmap::Bounds() const
380a33f8fbdSAdrien Destugues	\brief Gets a BRect the size of the bitmap's dimensions.
381a33f8fbdSAdrien Destugues
382a33f8fbdSAdrien Destugues	\return A BRect the size of the bitmap's dimensions.
38347852bffSJohn Scipione
38447852bffSJohn Scipione	\since BeOS R3
385a33f8fbdSAdrien Destugues*/
386a33f8fbdSAdrien Destugues
387a33f8fbdSAdrien Destugues
388a33f8fbdSAdrien Destugues/*!
389a33f8fbdSAdrien Destugues	\fn uint32 BBitmap::Flags() const
390a33f8fbdSAdrien Destugues	\brief Accesses the bitmap's creation flags.
391a33f8fbdSAdrien Destugues
392a33f8fbdSAdrien Destugues	This method informs about which flags have been used to create the
393a33f8fbdSAdrien Destugues	bitmap. It would for example tell you wether this is an overlay
394a33f8fbdSAdrien Destugues	bitmap. If bitmap creation succeeded, all flags are fulfilled.
395a33f8fbdSAdrien Destugues
396a33f8fbdSAdrien Destugues	\return The bitmap's creation flags.
39747852bffSJohn Scipione
39847852bffSJohn Scipione	\since Haiku R1
399a33f8fbdSAdrien Destugues*/
400a33f8fbdSAdrien Destugues
401a33f8fbdSAdrien Destugues
402a33f8fbdSAdrien Destugues/*!
40347852bffSJohn Scipione	\fn status_t BBitmap::GetOverlayRestrictions(
40447852bffSJohn Scipione		overlay_restrictions* restrictions) const
405a33f8fbdSAdrien Destugues	\brief Gets the overlay_restrictions structure for this bitmap.
406a33f8fbdSAdrien Destugues
407a33f8fbdSAdrien Destugues	\param restrictions The overlay restrictions flag
408a33f8fbdSAdrien Destugues
409a33f8fbdSAdrien Destugues	\retval B_OK The overlay restriction structure was found.
410a33f8fbdSAdrien Destugues	\retval B_BAD_TYPE The overlay restriction structure for the bitmap could
411a33f8fbdSAdrien Destugues		not be found.
41247852bffSJohn Scipione
41347852bffSJohn Scipione	\since Haiku R1
414a33f8fbdSAdrien Destugues*/
415a33f8fbdSAdrien Destugues
416a33f8fbdSAdrien Destugues
417a33f8fbdSAdrien Destugues//! @}
418a33f8fbdSAdrien Destugues
419a33f8fbdSAdrien Destugues
420a33f8fbdSAdrien Destugues/*!
421a33f8fbdSAdrien Destugues	\name Setters
422a33f8fbdSAdrien Destugues*/
423a33f8fbdSAdrien Destugues
424a33f8fbdSAdrien Destugues
425a33f8fbdSAdrien Destugues//! @{
426a33f8fbdSAdrien Destugues
427a33f8fbdSAdrien Destugues
428a33f8fbdSAdrien Destugues/*!
429a33f8fbdSAdrien Destugues	\fn void BBitmap::SetBits(const void* data, int32 length, int32 offset,
430a33f8fbdSAdrien Destugues		color_space colorSpace)
431a33f8fbdSAdrien Destugues	\brief Assigns data to the bitmap.
432a33f8fbdSAdrien Destugues
433a33f8fbdSAdrien Destugues	Data are directly written into the bitmap's data buffer, being converted
434a33f8fbdSAdrien Destugues	beforehand, if necessary. Some conversions do not work intuitively:
435a33f8fbdSAdrien Destugues	- \c B_RGB32: The source buffer is supposed to contain \c B_RGB24_BIG
436a33f8fbdSAdrien Destugues	  data without padding at the end of the rows.
437a33f8fbdSAdrien Destugues	- \c B_RGB32: The source buffer is supposed to contain \c B_CMAP8
438a33f8fbdSAdrien Destugues	  data without padding at the end of the rows.
439a33f8fbdSAdrien Destugues	- other color spaces: The source buffer is supposed to contain data
440a33f8fbdSAdrien Destugues	  according to the specified color space being padded to int32 row-wise.
441a33f8fbdSAdrien Destugues
442a33f8fbdSAdrien Destugues	The currently supported source/target color spaces are
443a33f8fbdSAdrien Destugues	<code>B_RGB{32,24,16,15}[_BIG]</code>, \c B_CMAP8 and
444a33f8fbdSAdrien Destugues	<code>B_GRAY{8,1}</code>.
445a33f8fbdSAdrien Destugues
446a33f8fbdSAdrien Destugues	\note Since this methods is a bit strange to use, Haiku has introduced
447a33f8fbdSAdrien Destugues		the ImportBits() method which is the recommended replacement.
448a33f8fbdSAdrien Destugues
449a33f8fbdSAdrien Destugues	\param data The data to be copied.
450a33f8fbdSAdrien Destugues	\param length The length in bytes of the data to be copied.
451a33f8fbdSAdrien Destugues	\param offset The offset (in bytes) relative to beginning of the bitmap
452a33f8fbdSAdrien Destugues		   data specifying the position at which the source data shall be
453a33f8fbdSAdrien Destugues		   written.
454a33f8fbdSAdrien Destugues	\param colorSpace Color space of the source data.
45547852bffSJohn Scipione
45647852bffSJohn Scipione	\since BeOS R3
457a33f8fbdSAdrien Destugues*/
458a33f8fbdSAdrien Destugues
459a33f8fbdSAdrien Destugues
460a33f8fbdSAdrien Destugues/*!
461a33f8fbdSAdrien Destugues	\fn status_t BBitmap::ImportBits(const void* data, int32 length, int32 bpr,
462a33f8fbdSAdrien Destugues		int32 offset, color_space colorSpace)
463a33f8fbdSAdrien Destugues	\brief Assigns data to the bitmap.
464a33f8fbdSAdrien Destugues
465a33f8fbdSAdrien Destugues	Data are directly written into the bitmap's data buffer, being converted
466a33f8fbdSAdrien Destugues	beforehand, if necessary. Unlike for SetBits(), the meaning of
467a33f8fbdSAdrien Destugues	\a colorSpace is exactly the expected one here, i.e. the source buffer
468a33f8fbdSAdrien Destugues	is supposed to contain data of that color space. \a bpr specifies how
469a33f8fbdSAdrien Destugues	many bytes the source contains per row. \c B_ANY_BYTES_PER_ROW can be
470a33f8fbdSAdrien Destugues	supplied, if standard padding to int32 is used.
471a33f8fbdSAdrien Destugues
472a33f8fbdSAdrien Destugues	The currently supported source/target color spaces are
473a33f8fbdSAdrien Destugues	<code>B_RGB{32,24,16,15}[_BIG]</code>, \c B_CMAP8 and
474a33f8fbdSAdrien Destugues	<code>B_GRAY{8,1}</code>.
475a33f8fbdSAdrien Destugues
476a33f8fbdSAdrien Destugues	\param data The data to be copied.
477a33f8fbdSAdrien Destugues	\param length The length in bytes of the data to be copied.
478a33f8fbdSAdrien Destugues	\param bpr The number of bytes per row in the source data.
479a33f8fbdSAdrien Destugues	\param offset The offset (in bytes) relative to beginning of the bitmap
480a33f8fbdSAdrien Destugues		   data specifying the position at which the source data shall be
481a33f8fbdSAdrien Destugues		   written.
482a33f8fbdSAdrien Destugues	\param colorSpace Color space of the source data.
483a33f8fbdSAdrien Destugues
484a33f8fbdSAdrien Destugues	\retval B_OK The bits were imported into the bitmap.
485a33f8fbdSAdrien Destugues	\retval B_BAD_VALUE \c NULL \a data, invalid \a bpr or \a offset, or
486a33f8fbdSAdrien Destugues	        unsupported \a colorSpace.
48747852bffSJohn Scipione
48847852bffSJohn Scipione	\since Haiku R1
489a33f8fbdSAdrien Destugues*/
490a33f8fbdSAdrien Destugues
491a33f8fbdSAdrien Destugues
492a33f8fbdSAdrien Destugues/*!
493a33f8fbdSAdrien Destugues	\fn status_t BBitmap::ImportBits(const void* data, int32 length,
494a33f8fbdSAdrien Destugues		int32 bpr, color_space colorSpace, BPoint from, BPoint to,
495a33f8fbdSAdrien Destugues		int32 width, int32 height)
496a33f8fbdSAdrien Destugues	\brief Assigns data to the bitmap.
497a33f8fbdSAdrien Destugues
498a33f8fbdSAdrien Destugues	Allows for a BPoint offset in the source and in the bitmap. The region
499a33f8fbdSAdrien Destugues	of the source at \a from extending \a width and \a height is assigned
500a33f8fbdSAdrien Destugues	(and converted if necessary) to the bitmap at \a to.
501a33f8fbdSAdrien Destugues
502a33f8fbdSAdrien Destugues	The currently supported source/target color spaces are
503a33f8fbdSAdrien Destugues	<code>B_RGB{32,24,16,15}[_BIG]</code>, \c B_CMAP8 and
504a33f8fbdSAdrien Destugues	<code>B_GRAY{8,1}</code>.
505a33f8fbdSAdrien Destugues
506a33f8fbdSAdrien Destugues	\param data The data to be copied.
507a33f8fbdSAdrien Destugues	\param length The length in bytes of the data to be copied.
508a33f8fbdSAdrien Destugues	\param bpr The number of bytes per row in the source data.
509a33f8fbdSAdrien Destugues	\param colorSpace Color space of the source data.
510a33f8fbdSAdrien Destugues	\param from The offset in the source where reading should begin.
511a33f8fbdSAdrien Destugues	\param to The offset in the bitmap where the source should be written.
512a33f8fbdSAdrien Destugues	\param width The width (in pixels) to be imported.
513a33f8fbdSAdrien Destugues	\param height The height (in pixels) to be imported.
514a33f8fbdSAdrien Destugues
515a33f8fbdSAdrien Destugues	\retval B_OK The bits were imported into the bitmap.
516a33f8fbdSAdrien Destugues	\retval B_BAD_VALUE: \c NULL \a data, invalid \a bpr, unsupported
517a33f8fbdSAdrien Destugues		\a colorSpace or invalid \a width or \a height.
51847852bffSJohn Scipione
51947852bffSJohn Scipione	\since Haiku R1
520a33f8fbdSAdrien Destugues*/
521a33f8fbdSAdrien Destugues
522a33f8fbdSAdrien Destugues
523a33f8fbdSAdrien Destugues/*!
524a33f8fbdSAdrien Destugues	\fn status_t BBitmap::ImportBits(const BBitmap* bitmap)
525a33f8fbdSAdrien Destugues	\brief Assigns another bitmap's data to this bitmap.
526a33f8fbdSAdrien Destugues
5271621d71aSHumdinger	The supplied bitmap must have the exact same dimensions as this bitmap.
528a33f8fbdSAdrien Destugues	Its data is converted to the color space of this bitmap.
529a33f8fbdSAdrien Destugues
530a33f8fbdSAdrien Destugues	The currently supported source/target color spaces are
531a33f8fbdSAdrien Destugues	<code>B_RGB{32,24,16,15}[_BIG]</code>, \c B_CMAP8 and
532a33f8fbdSAdrien Destugues	<code>B_GRAY{8,1}</code>.
533a33f8fbdSAdrien Destugues
534a33f8fbdSAdrien Destugues	\param bitmap The source bitmap.
535a33f8fbdSAdrien Destugues
536a33f8fbdSAdrien Destugues	\retval B_OK The bits were imported into the bitmap.
537a33f8fbdSAdrien Destugues	\retval B_BAD_VALUE \c NULL \a bitmap, or \a bitmap has other dimensions,
538a33f8fbdSAdrien Destugues		or the conversion from or to one of the color spaces is not supported.
53947852bffSJohn Scipione
54047852bffSJohn Scipione	\since Haiku R1
541a33f8fbdSAdrien Destugues*/
542a33f8fbdSAdrien Destugues
543a33f8fbdSAdrien Destugues
544a33f8fbdSAdrien Destugues/*!
545a33f8fbdSAdrien Destugues	\fn status_t BBitmap::ImportBits(const BBitmap* bitmap, BPoint from,
546a33f8fbdSAdrien Destugues		BPoint to,int32 width, int32 height)
547a33f8fbdSAdrien Destugues	\brief Assigns data to the bitmap.
548a33f8fbdSAdrien Destugues
549a33f8fbdSAdrien Destugues	Allows for a BPoint offset in the source and in the bitmap. The region
550a33f8fbdSAdrien Destugues	of the source at \a from extending \a width and \a height is assigned
551a33f8fbdSAdrien Destugues	(and converted if necessary) to the bitmap at \a to. The source bitmap is
552a33f8fbdSAdrien Destugues	clipped to the bitmap and they don't need to have the same dimensions.
553a33f8fbdSAdrien Destugues
554a33f8fbdSAdrien Destugues	The currently supported source/target color spaces are
555a33f8fbdSAdrien Destugues	<code>B_RGB{32,24,16,15}[_BIG]</code>, \c B_CMAP8 and
556a33f8fbdSAdrien Destugues	<code>B_GRAY{8,1}</code>.
557a33f8fbdSAdrien Destugues
558a33f8fbdSAdrien Destugues	\param bitmap The source bitmap.
559a33f8fbdSAdrien Destugues	\param from The offset in the source where reading should begin.
560a33f8fbdSAdrien Destugues	\param to The offset in the bitmap where the source should be written.
561a33f8fbdSAdrien Destugues	\param width The width (in pixels) to be imported.
562a33f8fbdSAdrien Destugues	\param height The height (in pixels) to be imported.
563a33f8fbdSAdrien Destugues
564a33f8fbdSAdrien Destugues	\retval B_OK The bits were imported into the bitmap.
565a33f8fbdSAdrien Destugues	\retval B_BAD_VALUE \c NULL \a bitmap, the conversion from or to one of
566a33f8fbdSAdrien Destugues	  	the color spaces is not supported, or invalid \a width or \a height.
56747852bffSJohn Scipione
56847852bffSJohn Scipione	\since Haiku R1
569a33f8fbdSAdrien Destugues*/
570a33f8fbdSAdrien Destugues
571a33f8fbdSAdrien Destugues
572a33f8fbdSAdrien Destugues//! @}
573a33f8fbdSAdrien Destugues
574a33f8fbdSAdrien Destugues
575a33f8fbdSAdrien Destugues/*!
57647852bffSJohn Scipione	\name View Hierarchy
577a33f8fbdSAdrien Destugues*/
578a33f8fbdSAdrien Destugues
579a33f8fbdSAdrien Destugues
580a33f8fbdSAdrien Destugues//! @{
581a33f8fbdSAdrien Destugues
582a33f8fbdSAdrien Destugues
583a33f8fbdSAdrien Destugues/*!
584a33f8fbdSAdrien Destugues	\fn void BBitmap::AddChild(BView* view)
585a33f8fbdSAdrien Destugues	\brief Adds a BView to the bitmap's view hierarchy.
586a33f8fbdSAdrien Destugues
587a33f8fbdSAdrien Destugues	The bitmap must accept views and the supplied view must not be child of
588a33f8fbdSAdrien Destugues	another parent.
589a33f8fbdSAdrien Destugues
590a33f8fbdSAdrien Destugues	\param view The view to be added.
59147852bffSJohn Scipione
59247852bffSJohn Scipione	\since BeOS R3
593a33f8fbdSAdrien Destugues*/
594a33f8fbdSAdrien Destugues
595a33f8fbdSAdrien Destugues
596a33f8fbdSAdrien Destugues/*!
597a33f8fbdSAdrien Destugues	\fn bool BBitmap::RemoveChild(BView* view)
598a33f8fbdSAdrien Destugues	\brief Removes a BView from the bitmap's view hierarchy.
599a33f8fbdSAdrien Destugues
600a33f8fbdSAdrien Destugues	\param view The view to be removed.
60147852bffSJohn Scipione
60247852bffSJohn Scipione	\since BeOS R3
603a33f8fbdSAdrien Destugues*/
604a33f8fbdSAdrien Destugues
605a33f8fbdSAdrien Destugues
606a33f8fbdSAdrien Destugues/*!
607a33f8fbdSAdrien Destugues	\fn int32 BBitmap::CountChildren() const
608a33f8fbdSAdrien Destugues	\brief Gets the number of BViews currently belonging to the bitmap.
609a33f8fbdSAdrien Destugues
610a33f8fbdSAdrien Destugues	\returns The number of BViews currently belonging to the bitmap.
61147852bffSJohn Scipione
61247852bffSJohn Scipione	\since BeOS R3
613a33f8fbdSAdrien Destugues*/
614a33f8fbdSAdrien Destugues
615a33f8fbdSAdrien Destugues
616a33f8fbdSAdrien Destugues/*!
617a33f8fbdSAdrien Destugues	\fn BView* BBitmap::ChildAt(int32 index) const
618a33f8fbdSAdrien Destugues	\brief Gets the BView at a certain index in the bitmap's list of views.
619a33f8fbdSAdrien Destugues
620a33f8fbdSAdrien Destugues	\param index The index of the BView to be returned.
621a33f8fbdSAdrien Destugues	\returns The BView at index \a index or \c NULL if the index is out of
622a33f8fbdSAdrien Destugues		range.
62347852bffSJohn Scipione
62447852bffSJohn Scipione	\since BeOS R3
625a33f8fbdSAdrien Destugues*/
626a33f8fbdSAdrien Destugues
627a33f8fbdSAdrien Destugues
628a33f8fbdSAdrien Destugues/*!
629a33f8fbdSAdrien Destugues	\fn BView* BBitmap::FindView(const char* viewName) const
6301621d71aSHumdinger	\brief Accesses a bitmap's child BView with the name \a viewName.
631a33f8fbdSAdrien Destugues
632a33f8fbdSAdrien Destugues	\param viewName The name of the BView to be returned.
633a33f8fbdSAdrien Destugues	\returns The BView with the name \a name or \c NULL if the bitmap doesn't
634a33f8fbdSAdrien Destugues		know a view with that name.
63547852bffSJohn Scipione
63647852bffSJohn Scipione	\since BeOS R3
637a33f8fbdSAdrien Destugues*/
638a33f8fbdSAdrien Destugues
639a33f8fbdSAdrien Destugues
640a33f8fbdSAdrien Destugues/*!
641a33f8fbdSAdrien Destugues	\fn BView* BBitmap::FindView(BPoint point) const
642a33f8fbdSAdrien Destugues	\brief Accesses a bitmap's BView at a certain location.
643a33f8fbdSAdrien Destugues
644a33f8fbdSAdrien Destugues	\param point The location.
645a33f8fbdSAdrien Destugues	\returns The BView with located at \a point or \c NULL if the bitmap
646a33f8fbdSAdrien Destugues		doesn't know a view at this location.
64747852bffSJohn Scipione
64847852bffSJohn Scipione	\since BeOS R3
649a33f8fbdSAdrien Destugues*/
650a33f8fbdSAdrien Destugues
651a33f8fbdSAdrien Destugues
652a33f8fbdSAdrien Destugues//! @}
653