Skip to main content
GameDev.net gamedev.net
🔒 Locked

Paint on screen using WinAPI

Started by Biberpelztrompete Nov 25, 2004 at 6:20 PM 1 replies 850+ views
Original Post
Biberpelztrompete
Biberpelztrompete
Hey ! Can somebody point me to a resource that explains how to access the screen on pixel-level ? I get the DC using GetDC(0), and I think I have to use SetDIBits() and GetDIBits(), but they just refuse to work. Thanks a lot !!

	HDC dc = GetDC(0);
	void *p = NULL;

	HBITMAP bitmap = CreateCompatibleBitmap(dc, 1280, 1024);
	SelectObject(dc, bitmap);

	BITMAPINFO info;
	memset(&info, 0, sizeof(info));
	info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	GetDIBits(dc, bitmap, 0, 1024, &p, &info, DIB_RGB_COLORS);
Aprosenf
Aprosenf
You have to allocate the memory yourself. GetDIBits() just copies the pixel data into your array, it does not allocate it for you. See MSDN.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.