代码之家  ›  专栏  ›  技术社区  ›  Hernán

IImage*来自IBitmap图像*

  •  1
  • Hernán  · 技术社区  · 17 年前

    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();
    

    1 回复  |  直到 17 年前
        1
  •  0
  •   tommyk    16 年前

    要获取IImage*对象,只需使用IImagingFactory::CreateImageFromFile。 http://msdn.microsoft.com/en-us/library/aa918650.aspx

    推荐文章