1 // BitmapBuffer.h 2 3 #include "ServerBitmap.h" 4 5 #include "BitmapBuffer.h" 6 7 // TODO: It should be more or less guaranteed that this object 8 // is not used if InitCheck() returns an error, so the checks 9 // in all thos functions should probably be removed... 10 11 // constructor 12 BitmapBuffer::BitmapBuffer(ServerBitmap* bitmap) 13 : fBitmap(bitmap) 14 { 15 } 16 17 // destructor 18 BitmapBuffer::~BitmapBuffer() 19 { 20 // We don't own the ServerBitmap 21 } 22 23 // InitCheck 24 status_t 25 BitmapBuffer::InitCheck() const 26 { 27 status_t ret = B_NO_INIT; 28 if (fBitmap) 29 ret = fBitmap->IsValid() ? B_OK : B_ERROR; 30 return ret; 31 } 32 33 // ColorSpace 34 color_space 35 BitmapBuffer::ColorSpace() const 36 { 37 if (InitCheck() >= B_OK) 38 return fBitmap->ColorSpace(); 39 return B_NO_COLOR_SPACE; 40 } 41 42 // Bits 43 void* 44 BitmapBuffer::Bits() const 45 { 46 if (InitCheck() >= B_OK) 47 return fBitmap->Bits(); 48 return NULL; 49 } 50 51 // BytesPerRow 52 uint32 53 BitmapBuffer::BytesPerRow() const 54 { 55 if (InitCheck() >= B_OK) 56 return fBitmap->BytesPerRow(); 57 return 0; 58 } 59 60 // Width 61 uint32 62 BitmapBuffer::Width() const 63 { 64 if (InitCheck() >= B_OK) 65 return fBitmap->Width(); 66 return 0; 67 } 68 69 // Height 70 uint32 71 BitmapBuffer::Height() const 72 { 73 if (InitCheck() >= B_OK) 74 return fBitmap->Height(); 75 return 0; 76 } 77 78