home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctchnqs / 1991 / number2 / bitmask.cpp next >
C/C++ Source or Header  |  1991-03-08  |  1KB  |  51 lines

  1. //-------------------------------------------------------------//
  2. // File:   BitMask.Cpp                                         //
  3. // Desc:   Methods for the BitMask Class                       //
  4. // Author: Marv Luse, Autumn Hill Software                     //
  5. //-------------------------------------------------------------//
  6.  
  7. #include "fg.h"
  8. #include "string.h"
  9. #include "bitmask.hpp"
  10.  
  11. //........ default constructor
  12.  
  13. BitMask::BitMask( )
  14. {
  15.      width = height = rowbytes = 0;
  16.      mask = 0;
  17. }
  18.  
  19. //........ constructor using specified components
  20.  
  21. BitMask::BitMask( int w, int h, char *m )
  22. {
  23.      width    = w;
  24.      height   = h;
  25.      rowbytes = (w + 7) >> 3;
  26.      if( (mask = new char[height*rowbytes]) != 0 )
  27.         memcpy( mask, m, height*rowbytes );
  28. }
  29.  
  30. //........ default destructor- needed to deallocate memory
  31.  
  32. BitMask::~BitMask( )
  33. {
  34.      if( mask )
  35.         delete mask;
  36. }
  37.  
  38. //........ function to draw a bitmask using Zortech FG library
  39.  
  40. void BitMask::draw( int x, int y, int clr )
  41. {
  42.      fg_box_t  mask_area;
  43.  
  44.      mask_area[FG_X1] = mask_area[FG_Y1] = 0;
  45.      mask_area[FG_X2] = width -1;
  46.      mask_area[FG_Y2] = height -1;
  47.  
  48.      fg_drawmatrix( clr, FG_MODE_SET, -1, FG_ROT0,
  49.                     x, y, mask, mask_area, fg.displaybox );
  50. }
  51.