History: Get Average Col
<=code_cpp=>
#include <stdio.h>
#include <Windows.h>
#include <Time.h>

int _tmain(int argc, _TCHAR* argv[])
{
	HDC hdc, hdcTemp;
	RECT rect;
	BYTE* bitPointer;
	//int x, y;
	u_char red, green, blue, alpha;
	HWND win;

    // Get the device context for the screen
	win = GetDesktopWindow();
	GetWindowRect(win, &rect);
	int MAX_WIDTH = rect.right;
	int MAX_HEIGHT = rect.bottom;
	BITMAPINFO bitmap;
	bitmap.bmiHeader.biSize = sizeof(bitmap.bmiHeader);
	bitmap.bmiHeader.biWidth = MAX_WIDTH;
	bitmap.bmiHeader.biHeight = MAX_HEIGHT;
	bitmap.bmiHeader.biPlanes = 1;
	bitmap.bmiHeader.biBitCount = 24;
	bitmap.bmiHeader.biCompression = BI_RGB;
	bitmap.bmiHeader.biSizeImage = MAX_WIDTH * 3 * MAX_HEIGHT;
	bitmap.bmiHeader.biClrUsed = 0;
	bitmap.bmiHeader.biClrImportant = 0;

	u_int r=0,g=0,b=0;

	while(true)
	{
		hdc = GetDC(HWND_DESKTOP);
		hdcTemp = CreateCompatibleDC(hdc);
		HBITMAP hBitmap2 = CreateDIBSection(hdcTemp, &bitmap, DIB_RGB_COLORS, (void**)(&bitPointer), NULL, NULL);
		SelectObject(hdcTemp, hBitmap2);
		BitBlt(hdcTemp, 0, 0, MAX_WIDTH, MAX_HEIGHT, hdc, 0, 0, SRCCOPY);

		for( int y=0, i=0; y<MAX_HEIGHT; y+=1 )
		for( int x=0; x<MAX_WIDTH; x+=1 )
		{
			i = (x + (MAX_HEIGHT-y-1)*MAX_WIDTH)*3;

			blue = (u_char)bitPointer[i];
			green = (u_char)bitPointer[i+1];
			red = (u_char)bitPointer[i+2];

			r += red;
			g += green;
			b += blue;

		}

		printf("%d %d %d\n", r/(MAX_WIDTH*MAX_HEIGHT), g/(MAX_WIDTH*MAX_HEIGHT), b/(MAX_WIDTH*MAX_HEIGHT));
		r=0;g=0;b=0;

		DeleteObject( hdcTemp );
		DeleteObject( hBitmap2 );
		ReleaseDC(HWND_DESKTOP, hdc);
		Sleep(150);
	}
	
	return 0;
}
Code.Tode.cz by Henry - 2014
Získejte registraci domén s tld .online, .space, .store, .tech zdarma!
Stačí si k jedné z těchto domén vybrat hosting Plus nebo Mega a registraci domény od nás dostanete za 0 Kč!
Objednat