home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / rehack / graphics / bitmap.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-26  |  2.4 KB  |  81 lines

  1. //---------------------------------------------------------------------------
  2. //
  3. //      File:           BITMAP.HPP
  4. //      Path:           ...\REHACK\graphics
  5. //      Version:                1.1
  6. //      Author:         Dave Boynton
  7. //      CIS Id:            71043,317
  8. //      Created On:     6/26/93
  9. //      Modified On:    7/25/93
  10. //      Description:    Bitmap class
  11. //      Tabs:           4
  12. //
  13. //---------------------------------------------------------------------------
  14. // copyright (c) 1991,1993 by the GAMERS Forum, Rehack project team.
  15. // All rights reserved.
  16. #ifndef _BITMAP_HPP
  17. #define _BITMAP_HPP
  18.  
  19. #include <stdio.h>
  20. #include "..\general\types.hpp"
  21. #include "..\general\misc.hpp"
  22.  
  23. typedef Rect LocalRect, OwnerRect;
  24.  
  25. typedef enum { detect, img, vga, pcx } BitmapFileType;
  26.  
  27. class Bitmap {
  28.     public:
  29.  
  30.     Rect    localBounds, ownerBounds;
  31.     Rect    viewPort;
  32.     int        dropoutColor;    // may be -1 to 255
  33.     byte *    bits;
  34.     bool    directFlag;     // no lines, no waiting
  35.     bool    validFlag;        // if false, no other member is valid
  36.  
  37.     Bitmap(const OwnerRect &Bounds);
  38.  
  39.     //assume 0,0 as topLeft
  40.     Bitmap() { validFlag=false; bits=NULL; }
  41.  
  42.     Bitmap(word width, word height, bool Direct=false);
  43.     Bitmap(char *filename, BitmapFileType fileType = detect);
  44.     Bitmap(FILE *fp, BitmapFileType fileType = detect);
  45.  
  46.     ~Bitmap() { invalidate(); }
  47.     const Rect getViewPort(void) { return viewPort; }
  48.     void setViewPort(Rect &r) { viewPort=r & localBounds; }
  49.     void moveViewPort(const Point &pt) { viewPort += pt; }
  50.  
  51.     static BitmapFileType detectFileType(char *filename);
  52.     static long getBitSize(Rect &bounds);
  53.     const Rect getOwnerBounds(void) { return ownerBounds; }
  54.     void setOwnerBounds(const OwnerRect &r) { ownerBounds=r; }
  55.     void moveOwnerBounds(const Point &pt) { ownerBounds+=pt; }
  56.  
  57.     const Rect getLocalBounds(void) { return localBounds; }
  58.  
  59.     void paint(Bitmap *dest, const Point &at);
  60.  
  61.     protected:
  62.     void BitmapLoad(FILE *fp, BitmapFileType fileType);
  63.     bool BitmapSetup(word width, word height);
  64.  
  65.     void invalidate(void);
  66. };
  67.  
  68. class BitmapArray : public Bitmap {
  69.     public:
  70.         Point tileSize, index;
  71.         word xTiles, yTiles;
  72.  
  73.         BitmapArray(char *filename, Point TileSize, word XTiles, word YTiles,
  74.                 BitmapFileType FileType=detect);
  75.         BitmapArray(FILE *fp, Point TileSize, word XTiles, word YTiles,
  76.                 BitmapFileType FileType=detect);
  77.         const Point * getIndex(void) { return &index; }
  78.         void setIndex(word xIndex, word yIndex=0);
  79. };
  80. #endif //ifndef _BITMAP_HPP
  81.