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. 67*47852bffSJohn Scipione 68*47852bffSJohn 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. 83a33f8fbdSAdrien Destugues \param screenID ??? 84*47852bffSJohn Scipione 85*47852bffSJohn Scipione \since Haiku R1 86a33f8fbdSAdrien Destugues*/ 87a33f8fbdSAdrien Destugues 88a33f8fbdSAdrien Destugues 89a33f8fbdSAdrien Destugues/*! 90a33f8fbdSAdrien Destugues \fn BBitmap::BBitmap(BRect bounds, color_space colorSpace, 91a33f8fbdSAdrien Destugues bool acceptsViews, bool needsContiguous) 92a33f8fbdSAdrien Destugues \brief Creates and initializes a BBitmap object. 93a33f8fbdSAdrien Destugues 94a33f8fbdSAdrien Destugues \param bounds The bitmap dimensions. 95a33f8fbdSAdrien Destugues \param colorSpace The bitmap's color space. 96a33f8fbdSAdrien Destugues \param acceptsViews \c true, if the bitmap shall accept BViews, i.e. if 97a33f8fbdSAdrien Destugues it shall be possible to attach BView to the bitmap and draw into 98a33f8fbdSAdrien Destugues it. 99a33f8fbdSAdrien Destugues \param needsContiguous If \c true a physically contiguous chunk of memory 100a33f8fbdSAdrien Destugues will be allocated. 101*47852bffSJohn Scipione 102*47852bffSJohn Scipione \since BeOS R3 103a33f8fbdSAdrien Destugues*/ 104a33f8fbdSAdrien Destugues 105a33f8fbdSAdrien Destugues 106a33f8fbdSAdrien Destugues/*! 107a33f8fbdSAdrien Destugues \fn BBitmap::BBitmap(const BBitmap* source, bool acceptsViews, 108a33f8fbdSAdrien Destugues bool needsContiguous) 109a33f8fbdSAdrien Destugues \brief Creates a BBitmap object as a clone of another bitmap. 110a33f8fbdSAdrien Destugues 111a33f8fbdSAdrien Destugues \param source The source bitmap. 112a33f8fbdSAdrien Destugues \param acceptsViews \c true, if the bitmap shall accept BViews, i.e. if 113a33f8fbdSAdrien Destugues it shall be possible to attach BView to the bitmap and draw into 114a33f8fbdSAdrien Destugues it. 115a33f8fbdSAdrien Destugues \param needsContiguous If \c true a physically contiguous chunk of memory 116a33f8fbdSAdrien Destugues will be allocated. 117*47852bffSJohn Scipione 118*47852bffSJohn Scipione \since Haiku R1 119a33f8fbdSAdrien Destugues*/ 120a33f8fbdSAdrien Destugues 121a33f8fbdSAdrien Destugues 122a33f8fbdSAdrien Destugues/*! 123a33f8fbdSAdrien Destugues \fn BBitmap::BBitmap(const BBitmap& source, uint32 flags) 124a33f8fbdSAdrien Destugues \brief Creates a BBitmap object as a clone of another bitmap. 125a33f8fbdSAdrien Destugues 126a33f8fbdSAdrien Destugues \param source The source bitmap. 127a33f8fbdSAdrien Destugues \param flags Creation flags. 128*47852bffSJohn Scipione 129*47852bffSJohn Scipione \since Haiku R1 130a33f8fbdSAdrien Destugues*/ 131a33f8fbdSAdrien Destugues 132a33f8fbdSAdrien Destugues 133a33f8fbdSAdrien Destugues/*! 134a33f8fbdSAdrien Destugues \fn BBitmap::BBitmap(const BBitmap& source) 135a33f8fbdSAdrien Destugues \brief Creates a BBitmap object as a clone of another bitmap. 136a33f8fbdSAdrien Destugues 137a33f8fbdSAdrien Destugues \param source The source bitmap. 138*47852bffSJohn Scipione 139*47852bffSJohn Scipione \since Haiku R1 140*47852bffSJohn Scipione*/ 141*47852bffSJohn Scipione 142*47852bffSJohn Scipione 143*47852bffSJohn Scipione/*! 144*47852bffSJohn Scipione \fn BBitmap::BBitmap(BMessage* data) 145*47852bffSJohn Scipione \brief Unarchives a bitmap from a BMessage. 146*47852bffSJohn Scipione 147*47852bffSJohn Scipione \param data The archive. 148*47852bffSJohn Scipione 149*47852bffSJohn Scipione \since BeOS R3 150a33f8fbdSAdrien Destugues*/ 151a33f8fbdSAdrien Destugues 152a33f8fbdSAdrien Destugues 153a33f8fbdSAdrien Destugues/*! 154a33f8fbdSAdrien Destugues \fn BBitmap::~BBitmap() 155a33f8fbdSAdrien Destugues \brief Destructor Method 156a33f8fbdSAdrien Destugues 157a33f8fbdSAdrien Destugues Frees all resources associated with this object. 158*47852bffSJohn Scipione 159*47852bffSJohn Scipione \since BeOS R3 160a33f8fbdSAdrien Destugues*/ 161a33f8fbdSAdrien Destugues 162a33f8fbdSAdrien Destugues 163a33f8fbdSAdrien Destugues/*! 164a33f8fbdSAdrien Destugues \name Archiving 165a33f8fbdSAdrien Destugues*/ 166a33f8fbdSAdrien Destugues 167a33f8fbdSAdrien Destugues 168a33f8fbdSAdrien Destugues//! @{ 169a33f8fbdSAdrien Destugues 170a33f8fbdSAdrien Destugues 171a33f8fbdSAdrien Destugues/*! 172a33f8fbdSAdrien Destugues \fn BArchivable* BBitmap::Instantiate(BMessage* data) 173a33f8fbdSAdrien Destugues \brief Instantiates a BBitmap from an archive. 174a33f8fbdSAdrien Destugues 175a33f8fbdSAdrien Destugues \param data The archive. 176*47852bffSJohn Scipione \return A bitmap reconstructed from the archive or \c NULL if an error 177a33f8fbdSAdrien Destugues occurred. 178*47852bffSJohn Scipione 179*47852bffSJohn Scipione \since BeOS R3 180a33f8fbdSAdrien Destugues*/ 181a33f8fbdSAdrien Destugues 182a33f8fbdSAdrien Destugues 183a33f8fbdSAdrien Destugues/*! 184a33f8fbdSAdrien Destugues \fn status_t BBitmap::Archive(BMessage* data, bool deep) const 185a33f8fbdSAdrien Destugues \brief Archives the BBitmap object. 186a33f8fbdSAdrien Destugues 187a33f8fbdSAdrien Destugues \param data The archive. 188a33f8fbdSAdrien Destugues \param deep if \c true, child object will be archived as well. 189*47852bffSJohn Scipione 190a33f8fbdSAdrien Destugues \return \c B_OK, if everything went fine, an error code otherwise. 191*47852bffSJohn Scipione 192*47852bffSJohn Scipione \since BeOS R3 193a33f8fbdSAdrien Destugues*/ 194a33f8fbdSAdrien Destugues 195a33f8fbdSAdrien Destugues 196a33f8fbdSAdrien Destugues//! @} 197a33f8fbdSAdrien Destugues 198a33f8fbdSAdrien Destugues 199a33f8fbdSAdrien Destugues/*! 200a33f8fbdSAdrien Destugues \fn status_t BBitmap::InitCheck() const 201a33f8fbdSAdrien Destugues \brief Gets the status of the constructor. 202a33f8fbdSAdrien Destugues 203a33f8fbdSAdrien Destugues \returns B_OK if initialization succeeded, otherwise returns an 204a33f8fbdSAdrien Destugues error status. 205*47852bffSJohn Scipione 206*47852bffSJohn Scipione 207*47852bffSJohn Scipione \since Haiku R1 208a33f8fbdSAdrien Destugues*/ 209a33f8fbdSAdrien Destugues 210a33f8fbdSAdrien Destugues 211a33f8fbdSAdrien Destugues/*! 212a33f8fbdSAdrien Destugues \fn bool BBitmap::IsValid() const 213a33f8fbdSAdrien Destugues \brief Determines whether or not the BBitmap object is valid. 214a33f8fbdSAdrien Destugues 215a33f8fbdSAdrien Destugues \return \c true, if the object is properly initialized, \c false otherwise. 216*47852bffSJohn Scipione 217*47852bffSJohn Scipione \since BeOS R3 218a33f8fbdSAdrien Destugues*/ 219a33f8fbdSAdrien Destugues 220a33f8fbdSAdrien Destugues 221a33f8fbdSAdrien Destugues/*! 222a33f8fbdSAdrien Destugues \name Locking 223a33f8fbdSAdrien Destugues*/ 224a33f8fbdSAdrien Destugues 225a33f8fbdSAdrien Destugues 226a33f8fbdSAdrien Destugues//! @{ 227a33f8fbdSAdrien Destugues 228a33f8fbdSAdrien Destugues 229a33f8fbdSAdrien Destugues/*! 230a33f8fbdSAdrien Destugues \fn status_t BBitmap::LockBits(uint32* state) 231a33f8fbdSAdrien Destugues \brief Locks the bitmap bits so that they cannot be relocated. 232a33f8fbdSAdrien Destugues 233a33f8fbdSAdrien Destugues This is currently only used for overlay bitmaps; whenever you 234a33f8fbdSAdrien Destugues need to access their Bits() you must lock them first. 235a33f8fbdSAdrien Destugues On resolution change overlay bitmaps can be relocated in memory; 236a33f8fbdSAdrien Destugues using this call prevents you from accessing an invalid pointer 237a33f8fbdSAdrien Destugues and clobbering memory that doesn't belong you. 238a33f8fbdSAdrien Destugues 239a33f8fbdSAdrien Destugues \param state Unused 240a33f8fbdSAdrien Destugues \returns \c B_OK on success or an error status code. 241*47852bffSJohn Scipione 242*47852bffSJohn Scipione \since Haiku R1 243a33f8fbdSAdrien Destugues*/ 244a33f8fbdSAdrien Destugues 245a33f8fbdSAdrien Destugues 246a33f8fbdSAdrien Destugues/*! 247a33f8fbdSAdrien Destugues \fn void BBitmap::UnlockBits() 248a33f8fbdSAdrien Destugues \brief Unlocks the bitmap's buffer. 249a33f8fbdSAdrien Destugues 250a33f8fbdSAdrien Destugues Counterpart to BBitmap::LockBits(). 251*47852bffSJohn Scipione 252*47852bffSJohn Scipione \since Haiku R1 253a33f8fbdSAdrien Destugues*/ 254a33f8fbdSAdrien Destugues 255a33f8fbdSAdrien Destugues 256a33f8fbdSAdrien Destugues/*! 257a33f8fbdSAdrien Destugues \fn bool BBitmap::Lock() 258a33f8fbdSAdrien Destugues \brief Locks the off-screen window that belongs to the bitmap. 259a33f8fbdSAdrien Destugues 260a33f8fbdSAdrien Destugues The bitmap must accept views, if locking should work. 261a33f8fbdSAdrien Destugues 262a33f8fbdSAdrien Destugues \returns \c true, if the lock was acquired successfully. 263*47852bffSJohn Scipione 264*47852bffSJohn Scipione \since BeOS R3 265a33f8fbdSAdrien Destugues*/ 266a33f8fbdSAdrien Destugues 267a33f8fbdSAdrien Destugues 268a33f8fbdSAdrien Destugues/*! 269a33f8fbdSAdrien Destugues \fn void BBitmap::Unlock() 270a33f8fbdSAdrien Destugues \brief Unlocks the off-screen window that belongs to the bitmap. 271a33f8fbdSAdrien Destugues 272a33f8fbdSAdrien Destugues The bitmap must accept views, if locking should work. 273*47852bffSJohn Scipione 274*47852bffSJohn Scipione \since BeOS R3 275a33f8fbdSAdrien Destugues*/ 276a33f8fbdSAdrien Destugues 277a33f8fbdSAdrien Destugues 278a33f8fbdSAdrien Destugues/*! 279a33f8fbdSAdrien Destugues \fn bool BBitmap::IsLocked() const 280a33f8fbdSAdrien Destugues \brief Determines whether or not the bitmap's off-screen window is locked. 281a33f8fbdSAdrien Destugues 282a33f8fbdSAdrien Destugues The bitmap must accept views, if locking should work. 283a33f8fbdSAdrien Destugues 284a33f8fbdSAdrien Destugues \return \c true, if the caller owns a lock , \c false otherwise. 285*47852bffSJohn Scipione 286*47852bffSJohn Scipione \since BeOS R4 287a33f8fbdSAdrien Destugues*/ 288a33f8fbdSAdrien Destugues 289a33f8fbdSAdrien Destugues 290a33f8fbdSAdrien Destugues//! @} 291a33f8fbdSAdrien Destugues 292a33f8fbdSAdrien Destugues 293a33f8fbdSAdrien Destugues/*! 294a33f8fbdSAdrien Destugues \name Accessors 295a33f8fbdSAdrien Destugues*/ 296a33f8fbdSAdrien Destugues 297a33f8fbdSAdrien Destugues 298a33f8fbdSAdrien Destugues//! @{ 299a33f8fbdSAdrien Destugues 300a33f8fbdSAdrien Destugues 301a33f8fbdSAdrien Destugues/*! 302a33f8fbdSAdrien Destugues \fn area_id BBitmap::Area() const 303a33f8fbdSAdrien Destugues \brief Gets the ID of the area the bitmap data reside in. 304a33f8fbdSAdrien Destugues 305a33f8fbdSAdrien Destugues \return The ID of the area the bitmap data reside in. 306*47852bffSJohn Scipione 307*47852bffSJohn Scipione \since Haiku R1 308a33f8fbdSAdrien Destugues*/ 309a33f8fbdSAdrien Destugues 310a33f8fbdSAdrien Destugues 311a33f8fbdSAdrien Destugues/*! 312a33f8fbdSAdrien Destugues \fn void* BBitmap::Bits() const 313a33f8fbdSAdrien Destugues \brief Gets the pointer to the bitmap data. 314a33f8fbdSAdrien Destugues 315a33f8fbdSAdrien Destugues \return The pointer to the bitmap data. 316*47852bffSJohn Scipione 317*47852bffSJohn Scipione \since BeOS R3 318a33f8fbdSAdrien Destugues*/ 319a33f8fbdSAdrien Destugues 320a33f8fbdSAdrien Destugues 321a33f8fbdSAdrien Destugues/*! 322a33f8fbdSAdrien Destugues \fn int32 BBitmap::BitsLength() const 323a33f8fbdSAdrien Destugues \brief Gets the length of the bitmap data. 324a33f8fbdSAdrien Destugues 325a33f8fbdSAdrien Destugues \return The length of the bitmap data as an int32. 326*47852bffSJohn Scipione 327*47852bffSJohn Scipione \since BeOS R3 328a33f8fbdSAdrien Destugues*/ 329a33f8fbdSAdrien Destugues 330a33f8fbdSAdrien Destugues 331a33f8fbdSAdrien Destugues/*! 332a33f8fbdSAdrien Destugues \fn int32 BBitmap::BytesPerRow() const 333a33f8fbdSAdrien Destugues \brief Gets the number of bytes used to store a row of bitmap data. 334a33f8fbdSAdrien Destugues 335a33f8fbdSAdrien Destugues \return The number of bytes used to store a row of bitmap data. 336*47852bffSJohn Scipione 337*47852bffSJohn Scipione \since BeOS R3 338a33f8fbdSAdrien Destugues*/ 339a33f8fbdSAdrien Destugues 340a33f8fbdSAdrien Destugues 341a33f8fbdSAdrien Destugues/*! 342a33f8fbdSAdrien Destugues \fn color_space BBitmap::ColorSpace() const 343a33f8fbdSAdrien Destugues \brief Gets the bitmap's color space. 344a33f8fbdSAdrien Destugues 345a33f8fbdSAdrien Destugues \return The bitmap's color space. 346*47852bffSJohn Scipione 347*47852bffSJohn Scipione \since BeOS R3 348a33f8fbdSAdrien Destugues*/ 349a33f8fbdSAdrien Destugues 350a33f8fbdSAdrien Destugues 351a33f8fbdSAdrien Destugues/*! 352a33f8fbdSAdrien Destugues \fn BRect BBitmap::Bounds() const 353a33f8fbdSAdrien Destugues \brief Gets a BRect the size of the bitmap's dimensions. 354a33f8fbdSAdrien Destugues 355a33f8fbdSAdrien Destugues \return A BRect the size of the bitmap's dimensions. 356*47852bffSJohn Scipione 357*47852bffSJohn Scipione \since BeOS R3 358a33f8fbdSAdrien Destugues*/ 359a33f8fbdSAdrien Destugues 360a33f8fbdSAdrien Destugues 361a33f8fbdSAdrien Destugues/*! 362a33f8fbdSAdrien Destugues \fn uint32 BBitmap::Flags() const 363a33f8fbdSAdrien Destugues \brief Accesses the bitmap's creation flags. 364a33f8fbdSAdrien Destugues 365a33f8fbdSAdrien Destugues This method informs about which flags have been used to create the 366a33f8fbdSAdrien Destugues bitmap. It would for example tell you wether this is an overlay 367a33f8fbdSAdrien Destugues bitmap. If bitmap creation succeeded, all flags are fulfilled. 368a33f8fbdSAdrien Destugues 369a33f8fbdSAdrien Destugues \return The bitmap's creation flags. 370*47852bffSJohn Scipione 371*47852bffSJohn Scipione \since Haiku R1 372a33f8fbdSAdrien Destugues*/ 373a33f8fbdSAdrien Destugues 374a33f8fbdSAdrien Destugues 375a33f8fbdSAdrien Destugues/*! 376*47852bffSJohn Scipione \fn status_t BBitmap::GetOverlayRestrictions( 377*47852bffSJohn Scipione overlay_restrictions* restrictions) const 378a33f8fbdSAdrien Destugues \brief Gets the overlay_restrictions structure for this bitmap. 379a33f8fbdSAdrien Destugues 380a33f8fbdSAdrien Destugues \param restrictions The overlay restrictions flag 381a33f8fbdSAdrien Destugues 382a33f8fbdSAdrien Destugues \retval B_OK The overlay restriction structure was found. 383a33f8fbdSAdrien Destugues \retval B_BAD_TYPE The overlay restriction structure for the bitmap could 384a33f8fbdSAdrien Destugues not be found. 385*47852bffSJohn Scipione 386*47852bffSJohn Scipione \since Haiku R1 387a33f8fbdSAdrien Destugues*/ 388a33f8fbdSAdrien Destugues 389a33f8fbdSAdrien Destugues 390a33f8fbdSAdrien Destugues//! @} 391a33f8fbdSAdrien Destugues 392a33f8fbdSAdrien Destugues 393a33f8fbdSAdrien Destugues/*! 394a33f8fbdSAdrien Destugues \name Setters 395a33f8fbdSAdrien Destugues*/ 396a33f8fbdSAdrien Destugues 397a33f8fbdSAdrien Destugues 398a33f8fbdSAdrien Destugues//! @{ 399a33f8fbdSAdrien Destugues 400a33f8fbdSAdrien Destugues 401a33f8fbdSAdrien Destugues/*! 402a33f8fbdSAdrien Destugues \fn void BBitmap::SetBits(const void* data, int32 length, int32 offset, 403a33f8fbdSAdrien Destugues color_space colorSpace) 404a33f8fbdSAdrien Destugues \brief Assigns data to the bitmap. 405a33f8fbdSAdrien Destugues 406a33f8fbdSAdrien Destugues Data are directly written into the bitmap's data buffer, being converted 407a33f8fbdSAdrien Destugues beforehand, if necessary. Some conversions do not work intuitively: 408a33f8fbdSAdrien Destugues - \c B_RGB32: The source buffer is supposed to contain \c B_RGB24_BIG 409a33f8fbdSAdrien Destugues data without padding at the end of the rows. 410a33f8fbdSAdrien Destugues - \c B_RGB32: The source buffer is supposed to contain \c B_CMAP8 411a33f8fbdSAdrien Destugues data without padding at the end of the rows. 412a33f8fbdSAdrien Destugues - other color spaces: The source buffer is supposed to contain data 413a33f8fbdSAdrien Destugues according to the specified color space being padded to int32 row-wise. 414a33f8fbdSAdrien Destugues 415a33f8fbdSAdrien Destugues The currently supported source/target color spaces are 416a33f8fbdSAdrien Destugues <code>B_RGB{32,24,16,15}[_BIG]</code>, \c B_CMAP8 and 417a33f8fbdSAdrien Destugues <code>B_GRAY{8,1}</code>. 418a33f8fbdSAdrien Destugues 419a33f8fbdSAdrien Destugues \note Since this methods is a bit strange to use, Haiku has introduced 420a33f8fbdSAdrien Destugues the ImportBits() method which is the recommended replacement. 421a33f8fbdSAdrien Destugues 422a33f8fbdSAdrien Destugues \param data The data to be copied. 423a33f8fbdSAdrien Destugues \param length The length in bytes of the data to be copied. 424a33f8fbdSAdrien Destugues \param offset The offset (in bytes) relative to beginning of the bitmap 425a33f8fbdSAdrien Destugues data specifying the position at which the source data shall be 426a33f8fbdSAdrien Destugues written. 427a33f8fbdSAdrien Destugues \param colorSpace Color space of the source data. 428*47852bffSJohn Scipione 429*47852bffSJohn Scipione \since BeOS R3 430a33f8fbdSAdrien Destugues*/ 431a33f8fbdSAdrien Destugues 432a33f8fbdSAdrien Destugues 433a33f8fbdSAdrien Destugues/*! 434a33f8fbdSAdrien Destugues \fn status_t BBitmap::ImportBits(const void* data, int32 length, int32 bpr, 435a33f8fbdSAdrien Destugues int32 offset, color_space colorSpace) 436a33f8fbdSAdrien Destugues \brief Assigns data to the bitmap. 437a33f8fbdSAdrien Destugues 438a33f8fbdSAdrien Destugues Data are directly written into the bitmap's data buffer, being converted 439a33f8fbdSAdrien Destugues beforehand, if necessary. Unlike for SetBits(), the meaning of 440a33f8fbdSAdrien Destugues \a colorSpace is exactly the expected one here, i.e. the source buffer 441a33f8fbdSAdrien Destugues is supposed to contain data of that color space. \a bpr specifies how 442a33f8fbdSAdrien Destugues many bytes the source contains per row. \c B_ANY_BYTES_PER_ROW can be 443a33f8fbdSAdrien Destugues supplied, if standard padding to int32 is used. 444a33f8fbdSAdrien Destugues 445a33f8fbdSAdrien Destugues The currently supported source/target color spaces are 446a33f8fbdSAdrien Destugues <code>B_RGB{32,24,16,15}[_BIG]</code>, \c B_CMAP8 and 447a33f8fbdSAdrien Destugues <code>B_GRAY{8,1}</code>. 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 bpr The number of bytes per row in the source data. 452a33f8fbdSAdrien Destugues \param offset The offset (in bytes) relative to beginning of the bitmap 453a33f8fbdSAdrien Destugues data specifying the position at which the source data shall be 454a33f8fbdSAdrien Destugues written. 455a33f8fbdSAdrien Destugues \param colorSpace Color space of the source data. 456a33f8fbdSAdrien Destugues 457a33f8fbdSAdrien Destugues \retval B_OK The bits were imported into the bitmap. 458a33f8fbdSAdrien Destugues \retval B_BAD_VALUE \c NULL \a data, invalid \a bpr or \a offset, or 459a33f8fbdSAdrien Destugues unsupported \a colorSpace. 460*47852bffSJohn Scipione 461*47852bffSJohn Scipione \since Haiku R1 462a33f8fbdSAdrien Destugues*/ 463a33f8fbdSAdrien Destugues 464a33f8fbdSAdrien Destugues 465a33f8fbdSAdrien Destugues/*! 466a33f8fbdSAdrien Destugues \fn status_t BBitmap::ImportBits(const void* data, int32 length, 467a33f8fbdSAdrien Destugues int32 bpr, color_space colorSpace, BPoint from, BPoint to, 468a33f8fbdSAdrien Destugues int32 width, int32 height) 469a33f8fbdSAdrien Destugues \brief Assigns data to the bitmap. 470a33f8fbdSAdrien Destugues 471a33f8fbdSAdrien Destugues Allows for a BPoint offset in the source and in the bitmap. The region 472a33f8fbdSAdrien Destugues of the source at \a from extending \a width and \a height is assigned 473a33f8fbdSAdrien Destugues (and converted if necessary) to the bitmap at \a to. 474a33f8fbdSAdrien Destugues 475a33f8fbdSAdrien Destugues The currently supported source/target color spaces are 476a33f8fbdSAdrien Destugues <code>B_RGB{32,24,16,15}[_BIG]</code>, \c B_CMAP8 and 477a33f8fbdSAdrien Destugues <code>B_GRAY{8,1}</code>. 478a33f8fbdSAdrien Destugues 479a33f8fbdSAdrien Destugues \param data The data to be copied. 480a33f8fbdSAdrien Destugues \param length The length in bytes of the data to be copied. 481a33f8fbdSAdrien Destugues \param bpr The number of bytes per row in the source data. 482a33f8fbdSAdrien Destugues \param colorSpace Color space of the source data. 483a33f8fbdSAdrien Destugues \param from The offset in the source where reading should begin. 484a33f8fbdSAdrien Destugues \param to The offset in the bitmap where the source should be written. 485a33f8fbdSAdrien Destugues \param width The width (in pixels) to be imported. 486a33f8fbdSAdrien Destugues \param height The height (in pixels) to be imported. 487a33f8fbdSAdrien Destugues 488a33f8fbdSAdrien Destugues \retval B_OK The bits were imported into the bitmap. 489a33f8fbdSAdrien Destugues \retval B_BAD_VALUE: \c NULL \a data, invalid \a bpr, unsupported 490a33f8fbdSAdrien Destugues \a colorSpace or invalid \a width or \a height. 491*47852bffSJohn Scipione 492*47852bffSJohn Scipione \since Haiku R1 493a33f8fbdSAdrien Destugues*/ 494a33f8fbdSAdrien Destugues 495a33f8fbdSAdrien Destugues 496a33f8fbdSAdrien Destugues/*! 497a33f8fbdSAdrien Destugues \fn status_t BBitmap::ImportBits(const BBitmap* bitmap) 498a33f8fbdSAdrien Destugues \brief Assigns another bitmap's data to this bitmap. 499a33f8fbdSAdrien Destugues 500a33f8fbdSAdrien Destugues The supplied bitmap must have the exactly same dimensions as this bitmap. 501a33f8fbdSAdrien Destugues Its data is converted to the color space of this bitmap. 502a33f8fbdSAdrien Destugues 503a33f8fbdSAdrien Destugues The currently supported source/target color spaces are 504a33f8fbdSAdrien Destugues <code>B_RGB{32,24,16,15}[_BIG]</code>, \c B_CMAP8 and 505a33f8fbdSAdrien Destugues <code>B_GRAY{8,1}</code>. 506a33f8fbdSAdrien Destugues 507a33f8fbdSAdrien Destugues \param bitmap The source bitmap. 508a33f8fbdSAdrien Destugues 509a33f8fbdSAdrien Destugues \retval B_OK The bits were imported into the bitmap. 510a33f8fbdSAdrien Destugues \retval B_BAD_VALUE \c NULL \a bitmap, or \a bitmap has other dimensions, 511a33f8fbdSAdrien Destugues or the conversion from or to one of the color spaces is not supported. 512*47852bffSJohn Scipione 513*47852bffSJohn Scipione \since Haiku R1 514a33f8fbdSAdrien Destugues*/ 515a33f8fbdSAdrien Destugues 516a33f8fbdSAdrien Destugues 517a33f8fbdSAdrien Destugues/*! 518a33f8fbdSAdrien Destugues \fn status_t BBitmap::ImportBits(const BBitmap* bitmap, BPoint from, 519a33f8fbdSAdrien Destugues BPoint to,int32 width, int32 height) 520a33f8fbdSAdrien Destugues \brief Assigns data to the bitmap. 521a33f8fbdSAdrien Destugues 522a33f8fbdSAdrien Destugues Allows for a BPoint offset in the source and in the bitmap. The region 523a33f8fbdSAdrien Destugues of the source at \a from extending \a width and \a height is assigned 524a33f8fbdSAdrien Destugues (and converted if necessary) to the bitmap at \a to. The source bitmap is 525a33f8fbdSAdrien Destugues clipped to the bitmap and they don't need to have the same dimensions. 526a33f8fbdSAdrien Destugues 527a33f8fbdSAdrien Destugues The currently supported source/target color spaces are 528a33f8fbdSAdrien Destugues <code>B_RGB{32,24,16,15}[_BIG]</code>, \c B_CMAP8 and 529a33f8fbdSAdrien Destugues <code>B_GRAY{8,1}</code>. 530a33f8fbdSAdrien Destugues 531a33f8fbdSAdrien Destugues \param bitmap The source bitmap. 532a33f8fbdSAdrien Destugues \param from The offset in the source where reading should begin. 533a33f8fbdSAdrien Destugues \param to The offset in the bitmap where the source should be written. 534a33f8fbdSAdrien Destugues \param width The width (in pixels) to be imported. 535a33f8fbdSAdrien Destugues \param height The height (in pixels) to be imported. 536a33f8fbdSAdrien Destugues 537a33f8fbdSAdrien Destugues \retval B_OK The bits were imported into the bitmap. 538a33f8fbdSAdrien Destugues \retval B_BAD_VALUE \c NULL \a bitmap, the conversion from or to one of 539a33f8fbdSAdrien Destugues the color spaces is not supported, or invalid \a width or \a height. 540*47852bffSJohn Scipione 541*47852bffSJohn Scipione \since Haiku R1 542a33f8fbdSAdrien Destugues*/ 543a33f8fbdSAdrien Destugues 544a33f8fbdSAdrien Destugues 545a33f8fbdSAdrien Destugues//! @} 546a33f8fbdSAdrien Destugues 547a33f8fbdSAdrien Destugues 548a33f8fbdSAdrien Destugues/*! 549*47852bffSJohn Scipione \name View Hierarchy 550a33f8fbdSAdrien Destugues*/ 551a33f8fbdSAdrien Destugues 552a33f8fbdSAdrien Destugues 553a33f8fbdSAdrien Destugues//! @{ 554a33f8fbdSAdrien Destugues 555a33f8fbdSAdrien Destugues 556a33f8fbdSAdrien Destugues/*! 557a33f8fbdSAdrien Destugues \fn void BBitmap::AddChild(BView* view) 558a33f8fbdSAdrien Destugues \brief Adds a BView to the bitmap's view hierarchy. 559a33f8fbdSAdrien Destugues 560a33f8fbdSAdrien Destugues The bitmap must accept views and the supplied view must not be child of 561a33f8fbdSAdrien Destugues another parent. 562a33f8fbdSAdrien Destugues 563a33f8fbdSAdrien Destugues \param view The view to be added. 564*47852bffSJohn Scipione 565*47852bffSJohn Scipione \since BeOS R3 566a33f8fbdSAdrien Destugues*/ 567a33f8fbdSAdrien Destugues 568a33f8fbdSAdrien Destugues 569a33f8fbdSAdrien Destugues/*! 570a33f8fbdSAdrien Destugues \fn bool BBitmap::RemoveChild(BView* view) 571a33f8fbdSAdrien Destugues \brief Removes a BView from the bitmap's view hierarchy. 572a33f8fbdSAdrien Destugues 573a33f8fbdSAdrien Destugues \param view The view to be removed. 574*47852bffSJohn Scipione 575*47852bffSJohn Scipione \since BeOS R3 576a33f8fbdSAdrien Destugues*/ 577a33f8fbdSAdrien Destugues 578a33f8fbdSAdrien Destugues 579a33f8fbdSAdrien Destugues/*! 580a33f8fbdSAdrien Destugues \fn int32 BBitmap::CountChildren() const 581a33f8fbdSAdrien Destugues \brief Gets the number of BViews currently belonging to the bitmap. 582a33f8fbdSAdrien Destugues 583a33f8fbdSAdrien Destugues \returns The number of BViews currently belonging to the bitmap. 584*47852bffSJohn Scipione 585*47852bffSJohn Scipione \since BeOS R3 586a33f8fbdSAdrien Destugues*/ 587a33f8fbdSAdrien Destugues 588a33f8fbdSAdrien Destugues 589a33f8fbdSAdrien Destugues/*! 590a33f8fbdSAdrien Destugues \fn BView* BBitmap::ChildAt(int32 index) const 591a33f8fbdSAdrien Destugues \brief Gets the BView at a certain index in the bitmap's list of views. 592a33f8fbdSAdrien Destugues 593a33f8fbdSAdrien Destugues \param index The index of the BView to be returned. 594a33f8fbdSAdrien Destugues \returns The BView at index \a index or \c NULL if the index is out of 595a33f8fbdSAdrien Destugues range. 596*47852bffSJohn Scipione 597*47852bffSJohn Scipione \since BeOS R3 598a33f8fbdSAdrien Destugues*/ 599a33f8fbdSAdrien Destugues 600a33f8fbdSAdrien Destugues 601a33f8fbdSAdrien Destugues/*! 602a33f8fbdSAdrien Destugues \fn BView* BBitmap::FindView(const char* viewName) const 603a33f8fbdSAdrien Destugues \brief Accesses a bitmap's child BView with a the name \a viewName. 604a33f8fbdSAdrien Destugues 605a33f8fbdSAdrien Destugues \param viewName The name of the BView to be returned. 606a33f8fbdSAdrien Destugues \returns The BView with the name \a name or \c NULL if the bitmap doesn't 607a33f8fbdSAdrien Destugues know a view with that name. 608*47852bffSJohn Scipione 609*47852bffSJohn Scipione \since BeOS R3 610a33f8fbdSAdrien Destugues*/ 611a33f8fbdSAdrien Destugues 612a33f8fbdSAdrien Destugues 613a33f8fbdSAdrien Destugues/*! 614a33f8fbdSAdrien Destugues \fn BView* BBitmap::FindView(BPoint point) const 615a33f8fbdSAdrien Destugues \brief Accesses a bitmap's BView at a certain location. 616a33f8fbdSAdrien Destugues 617a33f8fbdSAdrien Destugues \param point The location. 618a33f8fbdSAdrien Destugues \returns The BView with located at \a point or \c NULL if the bitmap 619a33f8fbdSAdrien Destugues doesn't know a view at this location. 620*47852bffSJohn Scipione 621*47852bffSJohn Scipione \since BeOS R3 622a33f8fbdSAdrien Destugues*/ 623a33f8fbdSAdrien Destugues 624a33f8fbdSAdrien Destugues 625a33f8fbdSAdrien Destugues//! @} 626