include/df/bitmap.hpp

00001 #define BITMAP_BMP 0x01
00002 #define BITMAP_GIF 0x02
00003 #define BITMAP_JPEG 0x03
00004 #define BITMAP_ICON 0x04  //only save supported
00005 #define BITMAP_PNG 0x05
00006 
00007 class Bitmap : public Element {
00008     friend class Mouse;
00009     friend class Window;
00010     friend class TaskBarIcon;
00011   _PROTECTED_:
00012     BOOL bValid;                //floating Bitmap mode
00013     BOOL sharedImage;           //is img shared with other Bitmaps?
00014     int32 tpx, tpy;  //turtle point (MoveTo() , LineTo(), etc.)
00015 
00016     uint32 xybypp, xbypp; //optz
00017     BOOL usekeyclr;       //use transparent color?
00018     uint32 keyclr;        //transparent color
00019 
00020     void binitvalues();
00021     BOOL _LoadBMP(File *f);
00022     BOOL _SaveBMP(File *f, BOOL noheader = FALSE, BOOL icon = FALSE);  //noheader/icon needed for _SaveICON()
00023 
00024     BOOL _LoadGIF(File *f, uint32 imgidx = 0);
00025     BOOL _SaveGIF(File *f, BOOL append = FALSE);
00026 
00027     BOOL _LoadJPEG(File *f);
00028     BOOL _SaveJPEG(File *f);
00029 
00030     BOOL _LoadICON(File *f);  //not supported!
00031     BOOL _SaveICON(File *f);  //only 1 image per file supported
00032 
00033     BOOL _LoadPNG(File *f);
00034     BOOL _SavePNG(File *f);
00035 
00036   public:
00037     union {
00038       uint32 imgi32;
00039       PTR img;
00040       uint8 *img8;
00041       uint16 *img16;
00042       uint32 *img32;
00043     };
00044 
00045     uint32 bpp, bypp;     //bits/pixel , bytes/pixel
00046 
00047     uint8 JPEGCompressionLevel;     //default = 75% (10=fast, 100=slow)
00048 
00049     Bitmap();
00050     ~Bitmap();
00051     //Public Members
00052     BOOL Load(char *fn, uint8 fmt = BITMAP_BMP);  //load in a bitmap (fmt=BITMAP_...)
00053     BOOL Load(File *f, uint8 fmt = BITMAP_BMP);   //load from an open file
00054     BOOL Save(char *fn, uint8 fmt = BITMAP_BMP);  //save file
00055     BOOL Save(File *f, uint8 fmt = BITMAP_BMP);   //save to an open file
00056 
00057     void SetKeyClr(uint32 _trans) {keyclr = _trans;}
00058     uint32 GetKeyClr() { return keyclr;}
00059     void SetKeyMode(int _mode) {usekeyclr = _mode;}  //default = OPAQUE
00060 
00061     void SetSize(uint32 x, uint32 y);
00062     void Destroy();
00063     void SetSharedImage(BOOL state);
00064 
00065     void Put(PTR, int, int, int, int);
00066     void PutKeyClr(PTR, int, int, int, int, uint32);
00067     void Get(PTR, int, int, int, int);
00068 
00069     void Put(Bitmap *, int32 _x, int32 _y);
00070     void Put(Bitmap *, int32 dx, int32 dy, int32 sx, int32 sy, int32 xl, int32 yl);
00071 
00072     //grafix primatives
00073     void MoveTo(int32 x, int32 y);   //move turtle graphics location to (x,y)
00074     void Line(int32 x1, int32 y1, int32 x2, int32 y2, uint32 clr);  //draw line
00075     void LineDash(int32 x1, int32 y1, int32 x2, int32 y2, uint32 clr);  //draw line dashed
00076     void LineTo(int32 x, int32 y, uint32 clr) {     //draw line from turtle loc.
00077       Line(tpx, tpy, x, y, clr);
00078     }
00079     void LineDashTo(int32 x, int32 y, uint32 clr) {  //draw line dashed
00080       LineDash(tpx, tpy, x, y, clr);
00081     }
00082     void PutPixel(int32 x, int32 y, uint32 clr);
00083     uint32 GetPixel(int32 x, int32 y);
00084     void Box(int32 x1, int32 y1, int32 x2, int32 y2, uint32 clr);
00085     void BoxDash(int32 x1, int32 y1, int32 x2, int32 y2, uint32 clr);
00086     void BoxFill(int32 x1, int32 y1, int32 x2, int32 y2, uint32 clr);
00087 
00088     void Draw();
00089 
00090     void Create(Bitmap *);  //create from another bitmap
00091     BOOL Create(int _xpos, int _ypos, int _x, int _y, int _Style, Element *_Parent);
00092 
00093     Bitmap & operator =(Bitmap &x);
00094 };
00095 

Generated on Mon Mar 5 09:49:13 2007 for DigiForce by  doxygen 1.4.7