#ifndef Bitmap_First #define Bitmap_First #ifdef __GNUG__ #pragma interface #endif #include "Types.h" #include "Rectangle.h" #include "Ink.h" class DevBitmap; class ColorMapper; //---- Bitmap ------------------------------------------------------------------ class Bitmap : public Ink { public: MetaDef(Bitmap); Bitmap(const Point &sz, u_short depth, ColorMapper *cmapper); Bitmap(const Point &sz, u_short depth= 1); Bitmap(const Point &sz, u_short *data); Bitmap(int w, int h, u_short *data); Bitmap(DevBitmap*); Bitmap(const char *name); Bitmap(const char *xpmdata[]); ~Bitmap(); ColorMapper *GetColorMapper(); DevBitmap *GetDevBitmap(); void SetDevBitmap(DevBitmap*); void SetInk(Port *p); void SetPixel(u_int x, u_int y, u_long value); u_long GetPixel(u_int x, u_int y); void SetRGB(u_int x, u_int y, RGB *rgb); void GetRGB(u_int x, u_int y, RGB *result); u_long MaxPixelValue(); void PixelToRGB(u_long pixel, RGB *result); bool RGB2Pixel(RGB *rgb, u_long *pixel); bool ChangeRGB(u_long pixel, RGB *rgb); void Fill(u_long pixel); void FillRect(const Rectangle &r, u_long pixel); void CopyPixel(const Rectangle &to, Bitmap *from, const Point &fromorigin); void ExpandDepth(); int GetDepth(); Point Size(); int ShortsPerLine(); int BytesPerLine(); int Shorts(); int Bytes(); virtual void Show(Rectangle *r, Port *port); OStream& PrintOn(OStream&); IStream& ReadFrom(IStream&); char *ReadXPM(char *data[]); Object *deepclone(); protected: ColorMapper *cmapper; DevBitmap *dbm; }; inline ColorMapper *Bitmap::GetColorMapper() { return cmapper; } inline DevBitmap *Bitmap::GetDevBitmap() { return dbm; } inline int Bitmap::Shorts() { return ShortsPerLine() * Size().y; } inline int Bitmap::Bytes() { return Shorts() * 2; } //---- SmartBitmap ------------------------------------------------------------- class SmartBitmap { public: SmartBitmap(int w, int h, u_short *b); SmartBitmap(const Point &s, u_short *b); SmartBitmap(const char *nm); SmartBitmap(const char *xpm[]); SmartBitmap(char *xpm[]); ~SmartBitmap(); Bitmap *MakeBitmap(); operator Bitmap* (); protected: Point size; int tag; union { Bitmap *bm; u_short *bits; const char *name; const char **xpmdata; } u; }; inline SmartBitmap::operator Bitmap* () { return (tag > 0) ? MakeBitmap() : u.bm; } #endif