locked
Load image from file

    Question

  • I've tried this code with VS2012 but I can't resolve the WIC references. What header files do I need?

    IWICImagingFactory *pFactory = NULL;
    IWICBitmapDecoder *pDecoder = NULL;

    HRESULT hr = CoCreateInstance
    (

      CLSID_WICImagingFactory,
      NULL,
      CLSCTX_INPROC_SERVER,
      IID_IWICImagingFactory,
      (LPVOID*)&pFactory

    );


    if (SUCCEEDED(hr))
    {
      hr = pFactory->CreateDecoderFromFilename

           (
              L"c:\\myfile.jpg",
              NULL,

              GENERIC_READ,

              WICDecodeMetadataCacheOnDemand,

              &pDecoder
           );
    }

    Tuesday, January 22, 2013 7:31 AM

Answers

All replies

  • You can find the required header files at the bottom of the interface documentation:

    http://msdn.microsoft.com/en-us/library/ee690281(v=VS.85).aspx

    Header: Wincodec.h
    --Rob
    Tuesday, January 22, 2013 7:19 PM
    Owner
  • Thanks. Now I just get the following after adding wincodec.h:

    error LNK2001: unresolved external symbol _IID_IWICImagingFactory


    Tuesday, January 22, 2013 10:54 PM
  • Are you linking to Windowscodecs.lib? The required library is mentioned two lines down from the header in the interface docs.

    --Rob

    Tuesday, January 22, 2013 11:01 PM
    Owner
  • BTW, Windowscodecs.lib is not available for ARM builds, as in it won't run on Tablets, kinda weird...
    Tuesday, January 22, 2013 11:18 PM
  • There's an ARM version of windowscodecs.lib in the Windows 8 SDK:

    C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um>dir /s windowscodecs.lib
     Volume in drive C is OSDisk
     Volume Serial Number is 1E4B-1DF1
    
     Directory of C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\arm
    
    07/25/2012  03:45 PM           392,206 windowscodecs.lib
                   1 File(s)        392,206 bytes
    
     Directory of C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64
    
    07/25/2012  04:07 PM           364,462 windowscodecs.lib
                   1 File(s)        364,462 bytes
    
     Directory of C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86
    
    07/25/2012  04:07 PM           366,648 windowscodecs.lib
                   1 File(s)        366,648 bytes
    
         Total Files Listed:
                   3 File(s)      1,123,316 bytes
                   0 Dir(s)  267,896,180,736 bytes free

    --Rob

    Tuesday, January 22, 2013 11:26 PM
    Owner
  • WIC is supported by Windows 8 and Windows RT. As such, windowscodecs.lib is present as noted by Rob in the Windows 8.0 SDK.

    NOTE: WIC is not supported by Windows phone 8.

    Wednesday, January 23, 2013 1:03 AM
  • Yes, I'm using WIC on ARM with C# but i need c++ Sinkwriter. It seems to be supported with SharpDX but I can't find any same code. I need WIC to inject photos from disk into video.
    Wednesday, January 23, 2013 1:47 AM