Filtering Bitmaps

Posts 1–3 of 3 · Page 1 of 1
Filtering Bitmaps
Ok, so i know how to save a screen shot of my screen using a bit map. I don't know how to filter out the bits to find a certain RGB value I am looking for. I am planning to make a pixel aimbot. I just want to filter my bitmap for colors. Help appreciated and thanks in advance.

Code:
 #include <iostream>
#include <windows.h>
using namespace std;
 
int main() {
  // The pixel we're scanning for
  COLORREF tofind = RGB( 255, 0, 0 );
 
  // Screen size
  int screen_width = GetSystemMetrics( SM_CXSCREEN );
  int screen_height = GetSystemMetrics( SM_CYSCREEN );
 
  // Get HBITMAP from our HDC of the screen
  HDC hdc = GetDC( NULL );
  HDC hdcMem = CreateCompatibleDC( hdc );
 
  HBITMAP bmp = CreateCompatibleBitmap( hdcMem, screen_width, screen_height );
  SelectObject( hdcMem, bmp );
  BitBlt( hdcMem , 0, 0, screen_width, screen_height, hdc, 0, 0, SRCCOPY );
 
  // bmp now contains the screenshot
}
thanks, for your useful replies. (sarcasm)
Call SetDIBitsⓘ on your bitmap to get the bits for it. You probably have to make sure if the bitmap is 24 bits but 99.9% of the time you can just assume it is. Loop through each pixel and check against your test color.
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us