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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
void *BufferMemory;
BITMAPINFO BitInfo;
HWND HWNDConsoleWindow = GetConsoleWindow();
HDC HDCConsoleWindow = GetDC(HWNDConsoleWindow);
RECT rect;
GetClientRect(HWNDConsoleWindow, &rect);
int ConsoleWidth = rect.right - rect.left;
int ConsoleHeight = rect.bottom - rect.top;
BitInfo.bmiHeader.biSize = sizeof(BitInfo.bmiHeader);
BitInfo.bmiHeader.biWidth = ConsoleWidth;
BitInfo.bmiHeader.biHeight = ConsoleHeight;
BitInfo.bmiHeader.biPlanes = 1;
BitInfo.bmiHeader.biBitCount = 32;
BitInfo.bmiHeader.biCompression = BI_RGB;
int BufferSize = ConsoleWidth * ConsoleHeight * sizeof(unsigned int);
if(BufferMemory) VirtualFree(BufferMemory, 0,MEM_RELEASE);
BufferMemory = VirtualAlloc(0, BufferSize,MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
unsigned int *PixelColors = (unsigned int) BufferMemory;
do
{
for(int y=0; y<ConsoleHeight; y++)
{
for(int x=0, i=0; x<ConsoleWidth; x++)
{
if(i<GetLineDots.size() && GetLineDots[i].PosX == x && GetLineDots[i].PosY==y )
{
PixelColors[y*ConsoleWidth + x] = RGB(0,255,0);
//MessageBox(NULL, "error", "error", MB_OK);
i++;
}
else
{
PixelColors[y*ConsoleWidth + x] = RGB(0,0,255);
}
}
}
StretchDIBits(HDCConsoleWindow,0,0,ConsoleWidth, ConsoleHeight, 0,0, ConsoleWidth,ConsoleHeight, BufferMemory, &BitInfo,DIB_RGB_COLORS, SRCCOPY );
}while(!GetAsyncKeyState(VK_ESCAPE));
| |