#ifndef SAVE_PALETTE_H
#define SAVE_PALETTE_H
#include "SFHash.h"
#include <GraphicsDefs.h>
enum {
WEB_SAFE_PALETTE = 0,
BEOS_SYSTEM_PALETTE,
GREYSCALE_PALETTE,
OPTIMAL_PALETTE
};
enum {
NO_TRANSPARENCY = 0,
AUTO_TRANSPARENCY,
COLOR_KEY_TRANSPARENCY
};
class BBitmap;
class SavePalette {
public:
SavePalette(int mode);
SavePalette(BBitmap* bitmap,
int32 maxSizeInBits = 8);
virtual ~SavePalette();
inline bool IsValid() const
{ return !fFatalError; }
uint8 IndexForColor(uint8 red, uint8 green,
uint8 blue, uint8 alpha = 255);
inline uint8 IndexForColor(const rgb_color& color);
inline bool UseTransparent() const
{ return fTransparentMode > NO_TRANSPARENCY; }
void PrepareForAutoTransparency();
inline int TransparentIndex() const
{ return fTransparentIndex; }
void SetTransparentColor(uint8 red,
uint8 green, uint8 blue);
inline int SizeInBits() const { return fSizeInBits; }
inline int BackgroundIndex() const
{ return fBackgroundIndex; }
void GetColors(uint8* buffer, int size) const;
rgb_color* pal;
private:
int fSize;
int fSizeInBits;
int fMode;
uint32 fTransparentMode;
int fTransparentIndex;
int fBackgroundIndex;
bool fFatalError;
};
inline uint8
SavePalette::IndexForColor(const rgb_color& color)
{
return IndexForColor(color.red, color.green, color.blue, color.alpha);
}
#endif