- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 - 41
 - 42
 - 43
 - 44
 - 45
 - 46
 - 47
 - 48
 - 49
 - 50
 - 51
 - 52
 - 53
 - 54
 - 55
 - 56
 - 57
 - 58
 - 59
 - 60
 - 61
 - 62
 - 63
 - 64
 - 65
 - 66
 - 67
 - 68
 - 69
 - 70
 - 71
 - 72
 - 73
 - 74
 - 75
 - 76
 - 77
 - 78
 - 79
 - 80
 - 81
 - 82
 - 83
 - 84
 - 85
 - 86
 - 87
 - 88
 - 89
 - 90
 - 91
 
                        typedef unsigned char byte;
byte masks[] =
{
	0,
	0x1,
	0x3,
	0x7,
	0xF,
	0x1F,
	0x3F,
	0x7F,
	0xFF
};
class RegionBool
{
public:
	RegionBool(unsigned int width, unsigned int height) : w_(width), h_(height), arr_(0), lineLenBytes_(0)
	{
		double lineLenBytes = 0;	// байт на строку
		byte strLenAddBits = static_cast<byte>(modf(static_cast<double>(w_) / 8, &lineLenBytes) * 8);
		lineLenBytes_ = static_cast<long>(lineLenBytes) + ((strLenAddBits > 0) ? 1 : 0);
		long bytes = lineLenBytes_ * h_;
		arr_ = new byte[bytes];
		memset(arr_, 0, bytes);
	}
	virtual ~RegionBool()
	{
		delete[] arr_;
	}
	inline byte* createLineMask(int x, int w)
	{
		// Hey! Attention, animal! Me is you. Listen: you can replace "masks[i]" with "(0xFF >> (8-i))". ХЗ, хав ит фастер.
		byte* mask = new byte[lineLenBytes_];
		memset(mask, 0, lineLenBytes_);
		double skipBytes = 0;
		byte startSkipBits = static_cast<byte>(modf(static_cast<double>(x) / 8, &skipBytes) * 8);
		byte* pmask = mask + static_cast<int>(skipBytes);
		byte before = (startSkipBits) ? (8 - startSkipBits) : 0;
		if (before > w)
			*pmask |= (masks[w] << startSkipBits);
		else
		{
			if (before)
				*pmask++ |= (masks[before] << startSkipBits);
			double fillBytes = 0;
			byte after = static_cast<byte>(modf(static_cast<double>(w - before) / 8, &fillBytes) * 8);
			
			if (fillBytes)
			{
				memset(pmask, 0xFF, static_cast<int>(fillBytes));
				pmask += static_cast<int>(fillBytes);
			}
			if (after)
				*pmask |= masks[after];
		}
		return mask;
	}
	virtual void OR(int x, int y, unsigned int w, unsigned int h)
	{
		byte* mask = createLineMask(x,w);
		unsigned int lim = y + h;
		byte* cur = arr_ + (y * lineLenBytes_);
		for (unsigned int ty = y; ty < lim; ty++)
		{
			byte* m = mask;
			for (int i = 0; i < lineLenBytes_; i++)
				*cur++ |= *m++;
		}
		delete[] mask;
	}
private:
	long lineLenBytes_;
	unsigned int w_;
	unsigned int h_;
	unsigned char* arr_;
};
                                     
        
            Простите, что много букв.
Подобие региона, в котором пиксель представлен битом. Операции предполагаются только с прямоугольниками, подразумевается, что прямоугольники вмещаются в регион.
Рассказывайте мне про меня))