[VC]如何使用GDIPlus進行圖檔轉檔

有關於C/C++的語法, 程式等
回覆文章
頭像
tim
文章: 1380
註冊時間: 2008年 11月 26日, 00:49

[VC]如何使用GDIPlus進行圖檔轉檔

文章 tim »

本篇文章利用了 VC++ 6.0 配合 GDIPlus 及 DXSDK 進行圖檔的轉檔動作, 程式碼很短, 雖然大多 GDI+ 的 sample 都是 .net 環境下的, 本文利用 vs6.0 進行 GDI+ 的轉檔, 給各位參考.

代碼: 選擇全部

     
    int main(int argc, char* argv[]) 
    { 
       
      // Initialize GDI+. 
      GdiplusStartupInput gdiplusStartupInput; 
      ULONG_PTR gdiplusToken; 
      GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); 
     
      CLSID             encoderClsid; 
      // Get an image from the disk. 
      Image* image = new Image(L"c:\mem.gif");   
      //Image* img = Image::FromFile( L"c:\mem.gif"); is the sam 
     
      // Get the CLSID of the JPEG encoder. 
      GetEncoderClsid(L"image/jpeg", &encoderClsid); 
     
      /* 
      the encoder type must be 
      image/bmp  
      image/jpeg  
      image/gif  
      image/tiff  
      image/png  
      */ 
     
      image->Save(L"c:\mem.jpg", &encoderClsid, NULL); 
     
      printf("finished n"); 
     
      GdiplusShutdown(gdiplusToken); 
     
      return 0; 
        
    } 

附件為完整的 sample code.
另外的一些參考文章,
http://msdn.microsoft.com/library/defau ... nlevel.asp
http://msdn.microsoft.com/library/defau ... ingthe.asp
http://msdn.microsoft.com/library/defau ... ingthe.asp
附加檔案
5_70.zip
(121.67 KiB) 已下載 672 次
多多留言, 整理文章, 把經驗累積下來.....
回覆文章