home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- //
- // File: BITMAP.HPP
- // Path: ...\REHACK\graphics
- // Version: 1.1
- // Author: Dave Boynton
- // CIS Id: 71043,317
- // Created On: 6/26/93
- // Modified On: 7/25/93
- // Description: Bitmap class
- // Tabs: 4
- //
- //---------------------------------------------------------------------------
- // copyright (c) 1991,1993 by the GAMERS Forum, Rehack project team.
- // All rights reserved.
- #ifndef _BITMAP_HPP
- #define _BITMAP_HPP
-
- #include <stdio.h>
- #include "..\general\types.hpp"
- #include "..\general\misc.hpp"
-
- typedef Rect LocalRect, OwnerRect;
-
- typedef enum { detect, img, vga, pcx } BitmapFileType;
-
- class Bitmap {
- public:
-
- Rect localBounds, ownerBounds;
- Rect viewPort;
- int dropoutColor; // may be -1 to 255
- byte * bits;
- bool directFlag; // no lines, no waiting
- bool validFlag; // if false, no other member is valid
-
- Bitmap(const OwnerRect &Bounds);
-
- //assume 0,0 as topLeft
- Bitmap() { validFlag=false; bits=NULL; }
-
- Bitmap(word width, word height, bool Direct=false);
- Bitmap(char *filename, BitmapFileType fileType = detect);
- Bitmap(FILE *fp, BitmapFileType fileType = detect);
-
- ~Bitmap() { invalidate(); }
- const Rect getViewPort(void) { return viewPort; }
- void setViewPort(Rect &r) { viewPort=r & localBounds; }
- void moveViewPort(const Point &pt) { viewPort += pt; }
-
- static BitmapFileType detectFileType(char *filename);
- static long getBitSize(Rect &bounds);
- const Rect getOwnerBounds(void) { return ownerBounds; }
- void setOwnerBounds(const OwnerRect &r) { ownerBounds=r; }
- void moveOwnerBounds(const Point &pt) { ownerBounds+=pt; }
-
- const Rect getLocalBounds(void) { return localBounds; }
-
- void paint(Bitmap *dest, const Point &at);
-
- protected:
- void BitmapLoad(FILE *fp, BitmapFileType fileType);
- bool BitmapSetup(word width, word height);
-
- void invalidate(void);
- };
-
- class BitmapArray : public Bitmap {
- public:
- Point tileSize, index;
- word xTiles, yTiles;
-
- BitmapArray(char *filename, Point TileSize, word XTiles, word YTiles,
- BitmapFileType FileType=detect);
- BitmapArray(FILE *fp, Point TileSize, word XTiles, word YTiles,
- BitmapFileType FileType=detect);
- const Point * getIndex(void) { return &index; }
- void setIndex(word xIndex, word yIndex=0);
- };
- #endif //ifndef _BITMAP_HPP
-