HaikuDepot/SharedBitmap: switched to use BPositionIO...
...instead of BMallocIO specifically.
This commit is contained in:
@@ -64,16 +64,26 @@ SharedBitmap::SharedBitmap(const char* mimeType)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SharedBitmap::SharedBitmap(const BMallocIO& data)
|
SharedBitmap::SharedBitmap(BPositionIO& data)
|
||||||
:
|
:
|
||||||
BReferenceable(),
|
BReferenceable(),
|
||||||
fResourceID(-1),
|
fResourceID(-1),
|
||||||
fBuffer(new(std::nothrow) uint8[data.BufferLength()]),
|
fBuffer(NULL),
|
||||||
fSize(data.BufferLength()),
|
fSize(0),
|
||||||
fMimeType()
|
fMimeType()
|
||||||
{
|
{
|
||||||
if (fBuffer != NULL)
|
status_t status = data.GetSize(&fSize);
|
||||||
memcpy(fBuffer, data.Buffer(), fSize);
|
if (status == B_OK && fSize > 0 && fSize <= 64 * 1024) {
|
||||||
|
fBuffer = new(std::nothrow) uint8[fSize];
|
||||||
|
|
||||||
|
data.Seek(0, SEEK_SET);
|
||||||
|
ssize_t read = data.Read(fBuffer, fSize);
|
||||||
|
if (read != fSize) {
|
||||||
|
delete[] fBuffer;
|
||||||
|
fBuffer = NULL;
|
||||||
|
fSize = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fBitmap[0] = NULL;
|
fBitmap[0] = NULL;
|
||||||
fBitmap[1] = NULL;
|
fBitmap[1] = NULL;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
class BMallocIO;
|
class BPositionIO;
|
||||||
|
|
||||||
|
|
||||||
class SharedBitmap : public BReferenceable {
|
class SharedBitmap : public BReferenceable {
|
||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
SharedBitmap(BBitmap* bitmap);
|
SharedBitmap(BBitmap* bitmap);
|
||||||
SharedBitmap(int32 resourceID);
|
SharedBitmap(int32 resourceID);
|
||||||
SharedBitmap(const char* mimeType);
|
SharedBitmap(const char* mimeType);
|
||||||
SharedBitmap(const BMallocIO& data);
|
SharedBitmap(BPositionIO& data);
|
||||||
~SharedBitmap();
|
~SharedBitmap();
|
||||||
|
|
||||||
const BBitmap* Bitmap(Size which);
|
const BBitmap* Bitmap(Size which);
|
||||||
@@ -49,7 +49,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
int32 fResourceID;
|
int32 fResourceID;
|
||||||
uint8* fBuffer;
|
uint8* fBuffer;
|
||||||
size_t fSize;
|
off_t fSize;
|
||||||
BString fMimeType;
|
BString fMimeType;
|
||||||
BBitmap* fBitmap[3];
|
BBitmap* fBitmap[3];
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user