How to draw bitmaps without access to HDC or HWND
-
I need to draw on bitmaps buried deep in a DLL and have no access to HDC or HWND any attempt to GetDC(NULL) returns a valid pointer but all attempts to draw the bitmap fails. I'm not using MFC, straight SDK. Has anyone done this before or know how to implement this? any help would be appreciated.
-
I need to draw on bitmaps buried deep in a DLL and have no access to HDC or HWND any attempt to GetDC(NULL) returns a valid pointer but all attempts to draw the bitmap fails. I'm not using MFC, straight SDK. Has anyone done this before or know how to implement this? any help would be appreciated.
What is a bitmap "buried deep in a DLL"? You only need an HWND if you're doing something window related. GetDC() is for obtaining a device context for a window (or the screen). If you're not drawing there, then that's useless as well. What are you trying to do? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
What is a bitmap "buried deep in a DLL"? You only need an HWND if you're doing something window related. GetDC() is for obtaining a device context for a window (or the screen). If you're not drawing there, then that's useless as well. What are you trying to do? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
I'm trying to do on screen display inside a DirectShow filter. To show buffering messages. I figured it would be easy to just create a bitmap the size of the output image, then just draw buffering messages and send it off to the render.
Assuming you want to use GDI to draw on the video frames... If you have access to the uncompressed frames before they are rendered, I would use a DIBSection (see CreateDIBSection). Create a memory DC (CreateCompatibleDC()), select the DIBSection into it. For each frame, copy the frame pixel bits into the DIBSection's pixel bits. Then use GDI to draw to the memory DC. Copy the pixel bits from the DIBSection back to the frame buffer. Depending on the renderer you are using, there may be features already there for overlays. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Assuming you want to use GDI to draw on the video frames... If you have access to the uncompressed frames before they are rendered, I would use a DIBSection (see CreateDIBSection). Create a memory DC (CreateCompatibleDC()), select the DIBSection into it. For each frame, copy the frame pixel bits into the DIBSection's pixel bits. Then use GDI to draw to the memory DC. Copy the pixel bits from the DIBSection back to the frame buffer. Depending on the renderer you are using, there may be features already there for overlays. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
I'll try that... only difrence is i'll have to create the buffer first, take the previous frame and color convert it to rgb24 then pass it into the CreateDIBSection draw the message I want, then color convert it to YUY2 or what ever output format is beeing used. HBITMAP CreateDIBSection( HDC hdc, // handle to DC CONST BITMAPINFO *pbmi, // bitmap data UINT iUsage, // data type indicator VOID **ppvBits, // bit values HANDLE hSection, // handle to file mapping object DWORD dwOffset // offset to bitmap bit values ); it needs a HDC, I dont' have one... How do i get one, or do i need a valid value? (pass in NULL?) edit: just looked into CreateCompatibleDC. If this handle is NULL, the function creates a memory DC compatible with the application's current screen. would that be dependent if someone is running their display in 16,24, or 32bit? -- modified at 12:35 Thursday 4th October, 2007
-
I'll try that... only difrence is i'll have to create the buffer first, take the previous frame and color convert it to rgb24 then pass it into the CreateDIBSection draw the message I want, then color convert it to YUY2 or what ever output format is beeing used. HBITMAP CreateDIBSection( HDC hdc, // handle to DC CONST BITMAPINFO *pbmi, // bitmap data UINT iUsage, // data type indicator VOID **ppvBits, // bit values HANDLE hSection, // handle to file mapping object DWORD dwOffset // offset to bitmap bit values ); it needs a HDC, I dont' have one... How do i get one, or do i need a valid value? (pass in NULL?) edit: just looked into CreateCompatibleDC. If this handle is NULL, the function creates a memory DC compatible with the application's current screen. would that be dependent if someone is running their display in 16,24, or 32bit? -- modified at 12:35 Thursday 4th October, 2007
hvanzyll wrote:
t needs a HDC, I dont' have one...
You can pass NULL for the DC when calling CreateDIBSection. The DC is only used for DIBs requiring a color table, not RGB DIBs.
hvanzyll wrote:
If this handle is NULL, the function creates a memory DC compatible with the application's current screen. would that be dependent if someone is running their display in 16,24, or 32bit?
The DIBSection will determine the bitmap format so a screen compatible DC will be fine. Note this is NOT the case with regular DDBs (HBITMAP), which cannot be selected into an incompatible DC.
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
hvanzyll wrote:
t needs a HDC, I dont' have one...
You can pass NULL for the DC when calling CreateDIBSection. The DC is only used for DIBs requiring a color table, not RGB DIBs.
hvanzyll wrote:
If this handle is NULL, the function creates a memory DC compatible with the application's current screen. would that be dependent if someone is running their display in 16,24, or 32bit?
The DIBSection will determine the bitmap format so a screen compatible DC will be fine. Note this is NOT the case with regular DDBs (HBITMAP), which cannot be selected into an incompatible DC.
Mark Salsbery Microsoft MVP - Visual C++ :java: