Jump to content
  • Advertisement
Sign in to follow this  
Biberpelztrompete

Paint on screen using WinAPI

This topic is 4956 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You could use CreateDIBSection().

Here is the official description:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_233i.asp

I'd linkify that but I'm an AP.



Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!