这是我在这里的第一篇文章。我有个问题。我需要拍摄桌面截图,将其转换为 jpeg,将其存储在缓冲区中,然后对其进行操作并通过 Internet 发送。
我已经编写了使用 GetDC....和 GDI+ 将 HBITMAP 转换为 jpeg 的代码。我现在遇到的问题是我不知道已保存到 IStream 中的 jpeg 的大小。这是将HBITMAP hBackBitmap引用的位图转换为jpeg并将其保存到pStream中的部分代码。我需要知道已将多少字节写入 pStream 以及如何使用 pStream(获取 PVOID 句柄):
Gdiplus::Bitmap bitmap(hBackBitmap, NULL);///loading the HBITMAP
CLSID clsid;
GetEncoderClsid(L"image/jpeg", &clsid);
HGLOBAL hGlobal = GlobalAlloc(GMEM_FIXED, nBlockSize) ;//allocating memory, the size of the current bitmap size. i'm over allocating but i don't think there is any way to get the exact ammount I need to allocate, is there?
if(!hGlobal)
return;
IStream* pStream = NULL ;
if(CreateStreamOnHGlobal(hGlobal, TRUE, &pStream) != S_OK )
return;
bitmap.Save(pStream, &clsid);
我需要的是: 1.找出jpeg的大小,流中写入了多少字节 2.如何使用流。例如,我可以为流中的数据获取 PVOID 吗?
谢谢你。