1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2005, Haiku, Inc. 3 // 4 // Distributed under the terms of the MIT license. 5 // 6 // File Name: Bitmap.h 7 // Author: Ingo Weinhold (bonefish@users.sf.net) 8 // Description: BBitmap objects represent off-screen windows that 9 // contain bitmap data. 10 //------------------------------------------------------------------------------ 11 12 #ifndef _BITMAP_H 13 #define _BITMAP_H 14 15 #include <Archivable.h> 16 #include <InterfaceDefs.h> 17 #include <Rect.h> 18 19 enum { 20 B_BITMAP_CLEAR_TO_WHITE = 0x00000001, 21 B_BITMAP_ACCEPTS_VIEWS = 0x00000002, 22 B_BITMAP_IS_AREA = 0x00000004, 23 B_BITMAP_IS_LOCKED = 0x00000008 | B_BITMAP_IS_AREA, 24 B_BITMAP_IS_CONTIGUOUS = 0x00000010 | B_BITMAP_IS_LOCKED, 25 B_BITMAP_IS_OFFSCREEN = 0x00000020, 26 B_BITMAP_WILL_OVERLAY = 0x00000040 | B_BITMAP_IS_OFFSCREEN, 27 B_BITMAP_RESERVE_OVERLAY_CHANNEL = 0x00000080, 28 B_BITMAP_NO_SERVER_LINK = 0x00000100 29 }; 30 31 #define B_ANY_BYTES_PER_ROW -1 32 33 //----------------------------------------------------------------// 34 //----- BBitmap class --------------------------------------------// 35 36 class BBitmap : public BArchivable { 37 public: 38 BBitmap(BRect bounds, uint32 flags, color_space colorSpace, 39 int32 bytesPerRow = B_ANY_BYTES_PER_ROW, 40 screen_id screenID = B_MAIN_SCREEN_ID); 41 BBitmap(BRect bounds, color_space colorSpace, bool acceptsViews = false, 42 bool needsContiguous = false); 43 BBitmap(const BBitmap *source, bool acceptsViews = false, 44 bool needsContiguous = false); 45 virtual ~BBitmap(); 46 47 // Archiving 48 BBitmap(BMessage *data); 49 static BArchivable *Instantiate(BMessage *data); 50 virtual status_t Archive(BMessage *data, bool deep = true) const; 51 52 status_t InitCheck() const; 53 bool IsValid() const; 54 55 status_t LockBits(uint32 *state = NULL); 56 void UnlockBits(); 57 58 area_id Area() const; 59 void *Bits() const; 60 int32 BitsLength() const; 61 int32 BytesPerRow() const; 62 color_space ColorSpace() const; 63 BRect Bounds() const; 64 65 void SetBits(const void *data, int32 length, int32 offset, 66 color_space colorSpace); 67 68 // not part of the R5 API 69 status_t ImportBits(const void *data, int32 length, int32 bpr, 70 int32 offset, color_space colorSpace); 71 status_t ImportBits(const BBitmap *bitmap); 72 73 status_t GetOverlayRestrictions(overlay_restrictions *restrictions) const; 74 75 //----- Private or reserved -----------------------------------------// 76 77 virtual status_t Perform(perform_code d, void *arg); 78 79 private: 80 virtual void _ReservedBitmap1(); 81 virtual void _ReservedBitmap2(); 82 virtual void _ReservedBitmap3(); 83 84 BBitmap(const BBitmap &); 85 BBitmap &operator=(const BBitmap &); 86 87 char *get_shared_pointer() const; 88 int32 get_server_token() const; 89 void InitObject(BRect bounds, color_space colorSpace, uint32 flags, 90 int32 bytesPerRow, screen_id screenID); 91 void CleanUp(); 92 93 void AssertPtr(); 94 95 void *fBasePtr; 96 int32 fSize; 97 color_space fColorSpace; 98 BRect fBounds; 99 int32 fBytesPerRow; 100 int32 fServerToken; 101 int32 fToken; 102 uint8 unused; 103 area_id fArea; 104 area_id fOrigArea; 105 uint32 fFlags; 106 status_t fInitError; 107 }; 108 109 /*-------------------------------------------------------------*/ 110 /*-------------------------------------------------------------*/ 111 112 #endif // _BITMAP_H 113