This isn't really a major problem but I'm trying to learn something here...
My application uses the FLTK toolkit. All the toolkits I've used let you "link" your own image data to the toolkit's internal format. (This way you can draw to the same image using either your own code or the toolkit methods.)
In FLTK, X11, and even Swing, you simply pass a pointer to the image data which you've already allocated (in your own bitmap object, or whatever). But Win32 seems to do this backwards.
I am using CreateDIBSection, which does the memory allocation for the image itself. Seems wierd. I had to make a special constructor in my Bitmap class to accomodate this.
So am I barking up the right tree or is there a better way to handle the Win32 drawing? Is there something newer/better than CreateDIBSection I should be using instead?
I've had a quick look at your code, but there is quite a bit of it. So what problem are you using CreateDIBSection to solve? The variable name "backbuf" make me wonder if you're using it for double-buffered drawing?
Also, when you talk about a bitmap object, what do you mean? I assume you're not talking about a Windows GDI bitmap object.
I'll try to explain in more detail. This has to do with drawing the main image to the screen. "Backbuf" is indeed used for double-buffering.
The "backbuf" object uses my own Bitmap class, and contains RGBA image data. FLTK supports same the format, but I think it does software alpha-blending on this format, which I don't need. And it's too slow.
The lower-level X11/Win32 functions support ignoring the alpha channel and drawing the image very quickly. Which all works great, but I'm just wondering if CreateDIBSection is the correct approach?
I've only ever come across double buffering being done with a Device Dependent Bitmap (including FLTK's Fl_Double_Window class.) What I was wondering about was how often you have to access the bitmap data directly, as it might be more efficient overall to work with the DDB most of the time and only access the data when required.
But given the nature of your program I would assume you need to access the data frequently, so it probably is the DIB approach that would work best.
This is probably a question for a more specialized forum, esp. as no one else has responded here.
Andy
PS Microsoft would prob. say CreateDIBSection is not the correct approach anymore, and that you should be using the Direct2D equivalent. Though I haven't yet worked on codebases which have switched to Direct2D myself.