Status stat;
CLSID  clsid;
Image img(L"c:\\000.jpg");
Image* pThumbnail = img.GetThumbnailImage( 100, 100, NULL, NULL );
GetEncoderClsid ( L"image/jpeg", &clsid );
stat = img.Save( L"c:\\000_.jpg", &clsid, NULL );
if ( stat != Ok ) {
return false;
}
-------------------------------------------------------------------
报错误:
error C2065: 'GetEncoderClsid' : undeclared identifier

解决方案 »

  1.   

    你的程序可以传给我看看吗[email protected]我也在用GDI+
      

  2.   

    总共就下面这些
    我想做一个 ATL 组件,用来生成一个图片的缩略图
    -------------------------------------------------------------------------------
    //  初始化 GDI+
    ULONG_PTR gdiplusToken; //GDI+

    GdiplusStartupInput gdiplusStartupInput;
    GdiplusStartup( &gdiplusToken, &gdiplusStartupInput, NULL );
    ////////////////////////////////////////////////////////////////////////// Status stat;
    CLSID  clsid;
    Image img(L"c:\\000.jpg");
    Image* pThumbnail = img.GetThumbnailImage( 100, 100, NULL, NULL );
    GetEncoderClsid ( L"image/jpeg", &clsid );
    stat = img.Save( L"c:\\000_.jpg", &clsid, NULL );
    if ( stat != Ok ) {
    *pVal = false;
    return S_FALSE;
    } //////////////////////////////////////////////////////////////////////////
    GdiplusShutdown(gdiplusToken); // 销毁 GDI+ 资源
    *pVal = true;
    return S_OK;
      

  3.   

    给你一个GetEncoderClsid 地实现:
    int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
    {
       UINT  num = 0;          // number of image encoders
       UINT  size = 0;         // size of the image encoder array in bytes   ImageCodecInfo* pImageCodecInfo = NULL;   GetImageEncodersSize(&num, &size);
       if(size == 0)
          return -1;  // Failure   pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
       if(pImageCodecInfo == NULL)
          return -1;  // Failure   GetImageEncoders(num, size, pImageCodecInfo);   for(UINT j = 0; j < num; ++j)
       {
          if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
          {
             *pClsid = pImageCodecInfo[j].Clsid;
             free(pImageCodecInfo);
             return j;  // Success
          }    
       }   free(pImageCodecInfo);
       return -1;  // Failure
    }
      

  4.   

    GetEncoderClsid本来就不是一个现有的函数,不过
    MSDN上面倒是写出了这样的一个函数的具体代码,
    你把下面的代码加载你的程序里就可以了。
    int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
    {
       UINT  num = 0;          // number of image encoders
       UINT  size = 0;         // size of the image encoder array in bytes   ImageCodecInfo* pImageCodecInfo = NULL;   GetImageEncodersSize(&num, &size);
       if(size == 0)
          return -1;  // Failure   pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
       if(pImageCodecInfo == NULL)
          return -1;  // Failure   GetImageEncoders(num, size, pImageCodecInfo);   for(UINT j = 0; j < num; ++j)
       {
          if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
          {
             *pClsid = pImageCodecInfo[j].Clsid;
             free(pImageCodecInfo);
             return j;  // Success
          }    
       }   free(pImageCodecInfo);
       return -1;  // Failure
    }