getdibits

c++ read pixels with GetDIBits()

家住魔仙堡 提交于 2020-01-03 05:18:35
问题 I'm trying to create a function which is equivalent to the windows API GetPixel() function, but I want to create a bitmap of my screen and then read that buffer. This is what I've got (Mostly copy pasted from google searches), when I run it it only prints out 0's. I think I've got most of it right, and that my issue is that I don't know how to read the BYTE variable. So my question is, what do I need to do in order to get it to print out some random colors (R,G or B) with my for loop?

Bitmap transfer using Winsock, GetDIBits and SetDiBits [closed]

自作多情 提交于 2019-12-19 10:04:00
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I started working on something similar to a remote control application in c++. I wish to transfer a particular window's screenshot to another PC and

C++/Win32: How to get the alpha channel from an HBITMAP?

痴心易碎 提交于 2019-12-18 04:49:13
问题 I have an HBITMAP containing alpha channel data. I can successfully render this using the ::AlphaBlend GDI function. However, when I call the ::GetPixel GDI function, I never get back values with an alpha component. The documentation does say that it returns the RGB value of the pixel. Is there a way to retrieve the alpha channel values for pixels in an HBITMAP ? I want to be able to detect when to use ::AlphaBlend, and when to use an old-school method for treating a particular colour in the

What is the HDC for in GetDIBits?

此生再无相见时 提交于 2019-12-12 07:18:44
问题 I was using GetDIBits to get bitmap data from a screen compatible device context into a DIB of a certain format. I was under the impression that the DC was necessary only for synthesizing a color table when the source bitmap is 8 bits-per-pixel or less. Since my source bitmap was a full 32-bit color image and this was a one-off program and I didn't have the screen DC handy, I set the HDC parameter to NULL. This didn't work. Once I grabbed the screen DC and passed it in, it did start working.

Understanding GetDiBits. C++

馋奶兔 提交于 2019-12-11 00:24:13
问题 MSDN says that the bitmap used in GetDiBits should not be selected into a DC before calling this function. But from my experience(with BitBlt ) I know that I cannot draw an a bitmap unless it is selected. How does GetDiBits circumvents this? Can I just use an unselected, newly created bitmap as argument to this function? GetDiBits as well CreateDibSection returns an array. But MSDN says about the first function: "bits of the specified compatible bitmap" I thought DI stands for

Capturing a program window with BitBlt always returns the same image

半世苍凉 提交于 2019-12-10 15:19:19
问题 I wrote the following code (C++ Win32) to capture a game window screen and get pixel color array from the image. Function autoB() does the job. Then I draw the result array into my window to visually check what I got. The problem is that this program works only once after I start the computer, after the first time it "caches" the first screenshot taken from the game and I always get the same array of pixels. Even if I close and restart the program I get the same screenshot. The game is not

hwnd to ppm issue

Deadly 提交于 2019-12-08 13:09:50
问题 I have a function which save a hwnd into a ppm file. This function is inspired by a msdn example. Both the msdn sample and my function work but ... I have an issue ... But first, here is the function. int CaptureAnImage(HWND hWnd) { HDC hdcWindow; HDC hdcMemDC = NULL; HBITMAP hbmScreen = NULL; RECT rc; BITMAPINFOHEADER bi; DWORD dwBmpSize; HANDLE hDIB; char *lpbitmap; int w, h; FILE *f; // Retrieve the handle to a display device context for the client // area of the window. hdcWindow = GetDC

What is the HDC for in GetDIBits?

让人想犯罪 __ 提交于 2019-11-30 21:13:12
I was using GetDIBits to get bitmap data from a screen compatible device context into a DIB of a certain format. I was under the impression that the DC was necessary only for synthesizing a color table when the source bitmap is 8 bits-per-pixel or less. Since my source bitmap was a full 32-bit color image and this was a one-off program and I didn't have the screen DC handy, I set the HDC parameter to NULL. This didn't work. Once I grabbed the screen DC and passed it in, it did start working. That left me wondering why GetDIBits requires the device context. What is it used for? In: int

C++/Win32: How to get the alpha channel from an HBITMAP?

人走茶凉 提交于 2019-11-30 19:06:23
I have an HBITMAP containing alpha channel data. I can successfully render this using the ::AlphaBlend GDI function. However, when I call the ::GetPixel GDI function, I never get back values with an alpha component. The documentation does say that it returns the RGB value of the pixel. Is there a way to retrieve the alpha channel values for pixels in an HBITMAP ? I want to be able to detect when to use ::AlphaBlend, and when to use an old-school method for treating a particular colour in the source HBITMAP as transparent. HDC sourceHdc = ::CreateCompatibleDC(hdcDraw); ::SelectObject(sourceHdc,

GetDIBits and loop through pixels using X, Y

天大地大妈咪最大 提交于 2019-11-27 02:15:22
I'm grabbing a portion of the screen and scanning through the pixels for a certain color range. I looked at MSDN's Capturing an Image example and know how to use the functions. I can get the bits into an array, but I'm not sure how to do it in such a way that I can loop through it as I would an image. A pseudo-example (which I'm sure is way off): for ( x = 1; x <= Image.Width; x += 3 ) { for ( y = 1; y <= Image.Height; y += 3 ) { red = lpPixels[x]; green = lpPixels[x + 1]; blue = lpPixels[x + 2]; } } That's basically what I want to do, so if red, blue, and green is a certain color, I'll know