repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / haikudepot / ui_generic / SharedBitmap.h
blobe7e58c0ad04d8642d2e53b955e2731fb17dcdb81
1 /*
2 * Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5 #ifndef SHARED_BITMAP_H
6 #define SHARED_BITMAP_H
9 #include <Referenceable.h>
10 #include <String.h>
12 #include "List.h"
15 class BBitmap;
16 class BPositionIO;
19 class SharedBitmap : public BReferenceable {
20 public:
21 enum Size {
22 SIZE_ANY = -1,
23 SIZE_16 = 0,
24 SIZE_22 = 1,
25 SIZE_32 = 2,
26 SIZE_64 = 3
29 SharedBitmap(BBitmap* bitmap);
30 SharedBitmap(int32 resourceID);
31 SharedBitmap(const char* mimeType);
32 SharedBitmap(BPositionIO& data);
33 ~SharedBitmap();
35 const BBitmap* Bitmap(Size which);
37 private:
38 BBitmap* _CreateBitmapFromResource(int32 size) const;
39 BBitmap* _CreateBitmapFromBuffer(int32 size) const;
40 BBitmap* _CreateBitmapFromMimeType(int32 size) const;
42 BBitmap* _LoadBitmapFromBuffer(const void* buffer,
43 size_t dataSize) const;
44 BBitmap* _LoadArchivedBitmapFromStream(
45 BPositionIO& stream) const;
46 BBitmap* _LoadTranslatorBitmapFromStream(
47 BPositionIO& stream) const;
48 BBitmap* _LoadIconFromBuffer(const void* buffer,
49 size_t dataSize, int32 size) const;
51 private:
52 int32 fResourceID;
53 uint8* fBuffer;
54 off_t fSize;
55 BString fMimeType;
56 BBitmap* fBitmap[4];
60 typedef BReference<SharedBitmap> BitmapRef;
61 typedef List<BitmapRef, false> BitmapList;
64 #endif // SHARED_BITMAP_H