Hello, I have proble with my code. What I'm trying to do is grab colors for all pixels and turn them into RGB...
Well here comes the problems, RGB is off so I tried to use BGRA but it's still off. Can you assist me and maybe optimize my with me

Thanks.

Code:
#include "iostream"
#include <Windows.h>
using namespace std;

HDC hdc, hdcTemp;
int x, y;


void PixelFunction();   // Get the pixel rgb function

int main()
{
	PixelFunction();
	ReleaseDC(HWND_DESKTOP, hdc);
	cout<<"done";
	getchar();
	return 0;
}


void PixelFunction()
{
	BYTE* bitPointer;
	int red, green, blue, alpha;

	hdc = GetDC(HWND_DESKTOP);
	int MAX_WIDTH = GetDeviceCaps(hdc, HORZRES);
	int MAX_HEIGHT = GetDeviceCaps(hdc, VERTRES);

	hdcTemp = CreateCompatibleDC(hdc);
	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 = 32;
	bitmap.bmiHeader.biCompression = BI_RGB;
	bitmap.bmiHeader.biSizeImage = MAX_WIDTH * 4 * MAX_HEIGHT;
	bitmap.bmiHeader.biClrUsed = 0;
	bitmap.bmiHeader.biClrImportant = 0;
	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 i=0; i<MAX_HEIGHT; i ++)
	{
		for (int ii=0; ii<MAX_WIDTH; ii++)
		{

			{
				blue = (int)bitPointer[i];
				green = (int)bitPointer[i+1];
				red = (int)bitPointer[i+2];
				alpha = (int)bitPointer[i+3];

				cout << "Red " << red << ".\n";
				cout << "Green " << green << ".\n";
				cout << "Blue " << blue << ".\n";
				Sleep(500);
			}
		}

	}





}
~Home