int Rescale(const UBitmap* src, UBitmap* dst, UINT w, UINT h)
// 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();