Questions tagged [hbitmap]

A handle to a bitmap (one of Windows Data Types)

HBITMAP is pointer to any type. But usually it is used for pointing on BITMAP object (one of Windows Data Types). See it's declaration:

typedef HANDLE HBITMAP; // see WinDef.h
typedef PVOID HANDLE;   // see WinNT.h
typedef void *PVOID;    // see WinNT.h
96 questions
22
votes
5 answers

Save HBITMAP to *.bmp file using only Win32

I have a HBITMAP in my pure Win32 project (no external libraries are used). Can I export it to a *.bmp file using only Winapi and/or CRT functions so I don't have to add dependencies to the project?
sashoalm
  • 75,001
  • 122
  • 434
  • 781
12
votes
3 answers

Creating HBITMAP from memory buffer

I have an application which loads some blob data out of a database which can represent png formatted or raw binary data for various bitmaps and icons. This is being stored in a std::vector I'm using CImageList objects to display…
AJG85
  • 15,849
  • 13
  • 42
  • 50
12
votes
3 answers

Getting a HBITMAP from a QPixmap in QT5 (Windows)

Now that QPixmap::toWinHBITMAP() has been deprecated, I can't find a way to get an HBITMAP from a QPixmap (or QImage). Googling, I found there's a function called qt_pixmapToWinHBITMAP() which seems would do what I need, but I can't find what module…
Gato
  • 671
  • 5
  • 15
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
10
votes
2 answers

C++ Getting RGB from hBitmap

Working with bitmaps is very new to me so I've been really struggling with the online tutorials and strategies that I've read through. Basically my goal is to scan the screen for a particular RGB value. I believe the steps to do this is to capture…
Mike
  • 199
  • 1
  • 2
  • 9
8
votes
2 answers

Converting from HBITMAP to Jpeg or Png in C++

Does anyone know how I can use an HBITMAP variable to write a png or jpeg file? I first looked into doing this with GDI+ but it gives me errors telling me min/max haven't been defined (defining them just brings more problems), I then looked into…
Mikey
  • 2,942
  • 33
  • 37
8
votes
2 answers

Load HBITMAP from *.bmp file in Win32 project

Is it possible to load a *.bmp file into a HBITMAP in a Win32 project, using only WINAPI functions?
sashoalm
  • 75,001
  • 122
  • 434
  • 781
7
votes
3 answers

QImage from HBITMAP

In my windows-only program, I use a third-party library, which returns a HBITMAP. Is there a way to initialize a QImage from its contents, i.e. to convert it to a QImage?
sashoalm
  • 75,001
  • 122
  • 434
  • 781
6
votes
1 answer

Converting HBitmap into byte array in Delphi

I am trying to convert hBitmap to array of bytes but I don't want to use TBitmap from unit Graphics. My input image is 128x64x32bit. var TheBits: array of array of Cardinal; begin with info.bmiHeader do begin biWidth:=131; …
Tom
  • 2,962
  • 3
  • 39
  • 69
6
votes
5 answers

Get bytes from HBITMAP

How can I get image bytes from hbitmap if I am given an HBITMAP pointer, and my application is console application. I tryed using GetDIBits which require such parameter as HDC, which I can't get. EDIT: I load bitmap from file: HBITMAP bm = 0;…
maximus
  • 4,201
  • 15
  • 64
  • 117
6
votes
5 answers

Proper way close WinAPI HANDLEs (avoiding of repeated closing)

I have some handle and I need to close it. There is some places in code, where handle may be closed. So, is this a right way to close handle? HANDLE h; .... if ( h != INVALID_HANDLE_VALUE ) { ::CloseHandle(h); h = INVALID_HANDLE_VALUE; } There…
Loom
  • 9,768
  • 22
  • 60
  • 112
5
votes
1 answer

How do I have DeleteObject() invoked on hBitmap other than by using P/Invoke?

I'm dealing with code that goes something like this (from here) using (var bmp = new System.Drawing.Bitmap(1000, 1000)) { IntPtr hBitmap = bmp.GetHbitmap(); var source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( …
sharptooth
  • 167,383
  • 100
  • 513
  • 979
5
votes
3 answers

C++: Hbitmap/BITMAP into .bmp file

Ok, whole story is, I am trying to use Leptonica+Tesseract OCR in C++ to take a screenshot, save it to a *.bmp file, then load it back up to OCR with it. I won't need to do this frequently, but as I cannot seem to copy the screenshot data directly…
user3285714
  • 75
  • 1
  • 1
  • 5
3
votes
2 answers

Passing Bitmap from C# to C++ Unmanaged code

I am trying without success to write code in C# to pass a bitmap to an unmanaged c++ DLL and return a POINT structure. I have done a lot of research on the internet, but have not found the "Gotcha" article or piece of code to help me resolve my…
Walter Zydhek
  • 293
  • 4
  • 10
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
1
2 3 4 5 6 7