1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
void New(unsigned int SizeWidth, unsigned int SizeHeight, COLORREF BackColor=RGB(0,0,0))
{
int BufferSize = SizeWidth * SizeHeight * sizeof(unsigned int);
if(BufferMemory) VirtualFree(BufferMemory, 0,MEM_RELEASE);
BufferMemory = VirtualAlloc(0, BufferSize,MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
Pixels =static_cast<unsigned int *> (BufferMemory);
std::fill(Pixels, Pixels + SizeWidth * SizeHeight, BackColor);
Width = SizeWidth;
Height = SizeHeight;
BitInfo.bmiHeader.biSize = sizeof(BitInfo.bmiHeader);
BitInfo.bmiHeader.biWidth = Width;
BitInfo.bmiHeader.biHeight = -Height;
BitInfo.bmiHeader.biPlanes = 1;
BitInfo.bmiHeader.biBitCount = 32;
BitInfo.bmiHeader.biCompression = BI_RGB;
}
void Draw(HDC Destination, int PosY, int PosX)
{
if(BufferMemory)
{
StretchDIBits(Destination, PosX, PosY, Width, Height, 0,0, Width, Height,Pixels, &BitInfo,DIB_RGB_COLORS, SRCCOPY );
}
}
| |