There is a form of GDI bitmap called a "packed DIB."
These are like any other GDI bitmaps, DIBs, MetaFiles, etc. except that the pixel bits immediately follow the header structures in memory and a few rules are simplified which guarantee a few specific things about some header field values.
Supposedly they get used a lot in Windows because they're the only safe way to pass images between processes: they can be persisted as a BLOB in memory and aren't a GDI object. For example this is how bitmaps and such get passed via the Clipboard.
VB6 can handle these with the Clipboard because it has specific Clipboard methods for dealing with them.
But now I have a case where a Windows object returns to me a packed DIB in a Long array. I don't want to play games with the Clipboard because I don't want to mess with the Clipboard contents, which might well have other stuff there the user is copying/pasting.
So since Windows loves these so much, I'd think there should be some easy support to either get them into a GDI HBITMAP, or preferably even directly into an OLE IPicture/StdPicture object.
I have some working code but I feel like I'm doing too much work. Does anyone have a better idea for converting these using less code?
See the first post in DirectShow WebCam Minimal Code to look at what i have (it is in Module1.bas of the ZIP archive).
The code I have works, but (a.) as I said it feels like too much work for this, and (b.) the resulting StdPicture doesn't have a "real" Device Context. This limits what can be done with it without more work to tie it to a screen DC or something.
This second point is minor since I can always adapt my code to have the calling Form, UserControl, etc. pass in its own hDC - and you can PaintPicture, etc. with it as it is.
These are like any other GDI bitmaps, DIBs, MetaFiles, etc. except that the pixel bits immediately follow the header structures in memory and a few rules are simplified which guarantee a few specific things about some header field values.
Supposedly they get used a lot in Windows because they're the only safe way to pass images between processes: they can be persisted as a BLOB in memory and aren't a GDI object. For example this is how bitmaps and such get passed via the Clipboard.
VB6 can handle these with the Clipboard because it has specific Clipboard methods for dealing with them.
But now I have a case where a Windows object returns to me a packed DIB in a Long array. I don't want to play games with the Clipboard because I don't want to mess with the Clipboard contents, which might well have other stuff there the user is copying/pasting.
So since Windows loves these so much, I'd think there should be some easy support to either get them into a GDI HBITMAP, or preferably even directly into an OLE IPicture/StdPicture object.
I have some working code but I feel like I'm doing too much work. Does anyone have a better idea for converting these using less code?
See the first post in DirectShow WebCam Minimal Code to look at what i have (it is in Module1.bas of the ZIP archive).
The code I have works, but (a.) as I said it feels like too much work for this, and (b.) the resulting StdPicture doesn't have a "real" Device Context. This limits what can be done with it without more work to tie it to a screen DC or something.
This second point is minor since I can always adapt my code to have the calling Form, UserControl, etc. pass in its own hDC - and you can PaintPicture, etc. with it as it is.