IImage* 来自 IBitmapImage*
我使用 Imaging API 基本上使用 Imaging 内置的调整大小函数编写了一个重新缩放函数。
我需要提供一个自定义 UBitmap 类,它是使用 Image* 指针和调整大小函数构建的,因此这里是 Rescale 函数原型:
int Rescale(const UBitmap* src, UBitmap* dst, UINT w, UINT h)
我的函数为 dst 指针分配堆(调用者只需要释放它)。
到目前为止我所做的:
// Get the IImage ptr from the source
HRESULT hr;
CoInitializeEx(NULL, COINIT_MULTITHREADED);
IImage* img_in = src->GetIImage();
if (img_in)
{
IImagingFactory* pImgf = NULL;
hr = CoCreateInstance(CLSID_ImagingFactory, 0, CLSCTX_ALL,
IID_IImagingFactory, void**)&pImgf);
assert(SUCCEEDED(hr));
IBitmapImage* pIResBmp = NULL;
hr = pImgf->CreateBitmapFromImage(img_in,w,h, PixelFormatDontCare,
InterpolationHintBilinear, &pIResBmp);
assert(SUCCEEDED(hr));
IImage* pImgOut = NULL; // How to obtain IImage pointer from pIResBmp?
bmpOut = new UBitmap(dst);
pImgf->Release();
}
CoUninitialize();
所以我已经使用 pImg->CreateBitmapFromImage 调用成功地重新缩放了图像,但我不知道如何获取 IImage* 来提供 UBitmap 构造函数。
提前致谢。
I'm using the Imaging API to basically write a rescaling function using the Imaging built-in Resize function.
I need to feed a custom UBitmap class that it's constructed with an Image* pointer with the resized function, so here's the Rescale function proto:
int Rescale(const UBitmap* src, UBitmap* dst, UINT w, UINT h)
My function allocates heap for the dst pointer (caller does need to free it only).
What I've done so far:
// Get the IImage ptr from the source
HRESULT hr;
CoInitializeEx(NULL, COINIT_MULTITHREADED);
IImage* img_in = src->GetIImage();
if (img_in)
{
IImagingFactory* pImgf = NULL;
hr = CoCreateInstance(CLSID_ImagingFactory, 0, CLSCTX_ALL,
IID_IImagingFactory, void**)&pImgf);
assert(SUCCEEDED(hr));
IBitmapImage* pIResBmp = NULL;
hr = pImgf->CreateBitmapFromImage(img_in,w,h, PixelFormatDontCare,
InterpolationHintBilinear, &pIResBmp);
assert(SUCCEEDED(hr));
IImage* pImgOut = NULL; // How to obtain IImage pointer from pIResBmp?
bmpOut = new UBitmap(dst);
pImgf->Release();
}
CoUninitialize();
So I've successfully rescaled the image with the pImg->CreateBitmapFromImage call, but I don't know how to obtain IImage* to feed the UBitmap constructor.
THanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要获取 IImage* 对象,只需使用 IImagingFactory::CreateImageFromFile。
请参阅 http://msdn.microsoft.com/en-us/library/aa918650 .aspx
To obtain IImage* object simply use IImagingFactory::CreateImageFromFile.
See http://msdn.microsoft.com/en-us/library/aa918650.aspx