vfs: check userland buffers before reading them.
[haiku.git] / src / servers / app / drawing / BBitmapBuffer.cpp
blobacb00005409bcb07d4234e4275e6332b6134ee98
1 // BBitmapBuffer.h
3 #include <Bitmap.h>
5 #include "BBitmapBuffer.h"
7 // constructor
8 BBitmapBuffer::BBitmapBuffer(BBitmap* bitmap)
9 : fBitmap(bitmap)
13 // destructor
14 BBitmapBuffer::~BBitmapBuffer()
16 delete fBitmap;
19 // InitCheck
20 status_t
21 BBitmapBuffer::InitCheck() const
23 status_t ret = B_NO_INIT;
24 if (fBitmap)
25 ret = fBitmap->InitCheck();
26 return ret;
29 // ColorSpace
30 color_space
31 BBitmapBuffer::ColorSpace() const
33 if (InitCheck() >= B_OK)
34 return fBitmap->ColorSpace();
35 return B_NO_COLOR_SPACE;
38 // Bits
39 void*
40 BBitmapBuffer::Bits() const
42 if (InitCheck() >= B_OK)
43 return fBitmap->Bits();
44 return NULL;
47 // BytesPerRow
48 uint32
49 BBitmapBuffer::BytesPerRow() const
51 if (InitCheck() >= B_OK)
52 return fBitmap->BytesPerRow();
53 return 0;
56 // Width
57 uint32
58 BBitmapBuffer::Width() const
60 if (InitCheck() >= B_OK)
61 return fBitmap->Bounds().IntegerWidth() + 1;
62 return 0;
65 // Height
66 uint32
67 BBitmapBuffer::Height() const
69 if (InitCheck() >= B_OK)
70 return fBitmap->Bounds().IntegerHeight() + 1;
71 return 0;