BitMap.cpp 600 B

12345678910111213141516171819202122232425262728
  1. // This code is in the public domain -- castanyo@yahoo.es
  2. #include "BitMap.h"
  3. using namespace nv;
  4. void BitMap::resize(uint w, uint h, bool initValue)
  5. {
  6. BitArray tmp(w*h);
  7. if (initValue) tmp.setAll();
  8. else tmp.clearAll();
  9. // @@ Copying one bit at a time. This could be much faster.
  10. for (uint y = 0; y < m_height; y++)
  11. {
  12. for (uint x = 0; x < m_width; x++)
  13. {
  14. //tmp.setBitAt(y*w + x, bitAt(x, y));
  15. if (bitAt(x, y) != initValue) tmp.toggleBitAt(y*w + x);
  16. }
  17. }
  18. swap(m_bitArray, tmp);
  19. m_width = w;
  20. m_height = h;
  21. }