BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / translators / gif / SavePalette.h
blob61155ea511f413ac9bf8dcb552cc8135690b80f2
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: SavePalette.h
4 //
5 // Date: December 1999
6 //
7 // Author: Daniel Switkin
8 //
9 // Copyright 2003 (c) by Daniel Switkin. This file is made publically available
10 // under the BSD license, with the stipulations that this complete header must
11 // remain at the top of the file indefinitely, and credit must be given to the
12 // original author in any about box using this software.
14 ////////////////////////////////////////////////////////////////////////////////
16 // Additional authors: John Scipione, <jscipione@gmail.com>
18 #ifndef SAVE_PALETTE_H
19 #define SAVE_PALETTE_H
22 #include "SFHash.h"
23 #include <GraphicsDefs.h>
25 enum {
26 WEB_SAFE_PALETTE = 0,
27 BEOS_SYSTEM_PALETTE,
28 GREYSCALE_PALETTE,
29 OPTIMAL_PALETTE
32 enum {
33 NO_TRANSPARENCY = 0,
34 AUTO_TRANSPARENCY,
35 COLOR_KEY_TRANSPARENCY
39 class BBitmap;
41 class SavePalette {
42 public:
43 SavePalette(int mode);
44 SavePalette(BBitmap* bitmap,
45 int32 maxSizeInBits = 8);
46 virtual ~SavePalette();
48 inline bool IsValid() const
49 { return !fFatalError; }
51 uint8 IndexForColor(uint8 red, uint8 green,
52 uint8 blue, uint8 alpha = 255);
53 inline uint8 IndexForColor(const rgb_color& color);
55 inline bool UseTransparent() const
56 { return fTransparentMode > NO_TRANSPARENCY; }
58 void PrepareForAutoTransparency();
59 inline int TransparentIndex() const
60 { return fTransparentIndex; }
61 void SetTransparentColor(uint8 red,
62 uint8 green, uint8 blue);
64 inline int SizeInBits() const { return fSizeInBits; }
66 inline int BackgroundIndex() const
67 { return fBackgroundIndex; }
69 void GetColors(uint8* buffer, int size) const;
71 rgb_color* pal;
73 private:
74 int fSize;
75 int fSizeInBits;
76 int fMode;
77 uint32 fTransparentMode;
78 int fTransparentIndex;
79 int fBackgroundIndex;
80 bool fFatalError;
84 inline uint8
85 SavePalette::IndexForColor(const rgb_color& color)
87 return IndexForColor(color.red, color.green, color.blue, color.alpha);
91 #endif // SAVE_PALETTE_H