I think the subject says it all. But in some detail, I am loading, manipulating, then displaying a bitmap, and was doing it in GDI. Now I want to add some speed, because it happens repeatedly.
Many years ago, I used DirectX for other things, but everything I've seen says to get off of DirectX, go Direct2D. So time to throw away all that knowledge, and start over again. Truly the MS way ;-)
Well, in order to manipulate the bitmap, before it goes in for rendering, I see I can get it with the 'Lock()'. And a function on the interface will also tell me the size. But I also need to know the BBP, and stride.
Before anyone says "Why don't you use ::GetBBP()... DUH", I haven't been able to find anything remotely like that, after hours of searching the MSDN and other sources. And there are a lot of very confusing COM interfaces out there.
The only thing I can find is GetPixelFormat(), which returns a GUID, and then I get to write about 150 "if (...)" statements to compare it. Just so I can test it for three values and a reject if it's none of them (1,8,32) Hardly an efficient way to deal with this.
And GetPixelFormat() doesn't tell me the stride either.
Is there a way to do this?
(The bitmaps are also uncompressed, so I don't even need to run them through the IWICBitmapDecoder, but I have yet to unravel how to simply tell IWICBitmap "here's a blob, go use it as a bitmap of size x-y")
Thanks for any assistance.
-Scott
Use
IWICPixelFormatInfo.You can get this interface from the
IWICImagingFactory.CreateComponentInfo()method.WICPixelFormatGUIDvalue you get fromIWICBitmap.GetPixelFormat().QueryInterface( __uuidof(IWICPixelFormatInfo))on theIWICComponentInfointerface pointer returned by the factory method above to get theIWICPixelFormatInfointerface pointer.IWICPixelFormatInfopointer toGetBitsPerPixel()Convert that to the number of bytes per pixel, and you are done.
A bit more convoluted than getting the read lock, but an alternative nonetheless.
Pseudocode