Questions tagged [getdibits]

26 questions
10
votes
5 answers

GetDIBits and loop through pixels using X, Y

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…
guitar-
  • 1,051
  • 5
  • 15
  • 21
10
votes
1 answer

Why does a call to GetDIBits fail on Win64?

I have a call to GetDIBits that works perfectly in 32-bit, but fails on 64-bit. Despite the different values for the handles the content of the bitmapinfo structure are the same. Here is the smallest (at least slightly structured) code example I…
Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130
10
votes
1 answer

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

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…
mackenir
  • 10,801
  • 16
  • 68
  • 100
6
votes
3 answers

c++ read pixels with GetDIBits()

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…
Mandera
  • 2,647
  • 3
  • 21
  • 26
6
votes
2 answers

Capturing a program window with BitBlt always returns the same image

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…
user1481126
5
votes
1 answer

What is the HDC for in GetDIBits?

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…
Adrian McCarthy
  • 45,555
  • 16
  • 123
  • 175
3
votes
2 answers

Getting Bitmap pixel values using the Windows GetDIBits function

I'm trying to get the pixels of a bitmap using the GetDIBits function. As I have not studied the Windows GDI/API, I'm very unsure about the first argument, HDC. I've searched countless posts here on SO and the web but have been unable to find…
Olumide
  • 5,397
  • 10
  • 55
  • 104
3
votes
2 answers

GetDiBits: different dimensions passed in BITMAPINFOHEADER

I have some questions regarding GetDiBits, based on my experience with this function. By mistake I have created a bitmap double the size I needed: HBITMAP hBmpSection = CreateCompatibleBitmap(ScreenDC, 2 * radius, 2 * radius); I did not notice…
sergiu reznicencu
  • 1,039
  • 1
  • 11
  • 31
3
votes
1 answer

Understanding GetDiBits. C++

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…
sergiu reznicencu
  • 1,039
  • 1
  • 11
  • 31
3
votes
2 answers

Bitmap transfer using Winsock, GetDIBits and SetDiBits

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 display it in a window. Both GetDIBits and SetDIBits functions succeed, the connection is…
Neo_b
  • 231
  • 5
  • 9
2
votes
0 answers

Trying to write TBitmaps to AVI file and getting only black frames (all zero data)

I have a Delphi application that reads JPEG frames from a file and writes them to an AVI file. Each JPEG frame is decoded to a TBitmap object and then written to an output AVI file using the services provided by the Windows API DLL for AVI…
Robert Oschler
  • 14,153
  • 18
  • 94
  • 227
1
vote
1 answer

Strange behavior with DrawIconEx and GetDIBits, with alpha as zero

I'm using this code to capture the screen + cursor: new System.Security.Permissions.UIPermission(System.Security.Permissions.UIPermissionWindow.AllWindows).Demand(); var success = Native.BitBlt(_compatibleDeviceContext, 0, 0, Width, Height,…
Nicke Manarin
  • 3,026
  • 4
  • 37
  • 79
1
vote
1 answer

Using GetDIBits to load a bitmap

I want to use GetDIBits to load a bitmap in C++. Here's the code I'm using: HBITMAP hBmp = LoadBitmap(hInstance, MAKEINTRESOURCE(id)); BITMAP BM; GetObject(hBmp, sizeof(BM), &BM); GLvoid* bits = NULL; BITMAPINFO bitmap_info; …
user3075425
  • 332
  • 1
  • 6
  • 23
1
vote
0 answers

Getting RGB data of a minimised window

I want to get RGB data of a particular part of a running window which is minimised and I'm not quite sure how to do it. Here is my piece of code for getting bitmap info of a window for a specified rectangle. BYTE* LoadBMPFromHandle(HWND hwnd, int…
0
votes
1 answer

Need device independent bitmap bits

I'm building a dll in C++ to be imported into a VB project. The dll exposes a function that will extract the preview image of a specified document through the Win Shell, and then writes it into a buffer to be used by the VB app. So far, I'm able to…
JString
  • 1
  • 1
1
2