views:

228

answers:

1

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.

A: 

To obtain IImage* object simply use IImagingFactory::CreateImageFromFile. See http://msdn.microsoft.com/en-us/library/aa918650.aspx

tommyk