隨筆-17  評論-64  文章-79  trackbacks-1
          #define? ULONG_PTR? void*
          #include<gdiplus.h>??
          #include<GdiPlusEnums.h>
          #pragma comment(lib,"GdiPlus.lib")
          using namespace Gdiplus;
          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
          ?? GdiplusStartupInput gdiplusStartupInput;
          ?? ULONG_PTR?????????? gdiplusToken;
          ?? GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
          ?? 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);
          ?? GdiplusShutdown(gdiplusToken);
          ?? return -1;? // Failure?
          }?
          ?
          void BMP2JPG(CString strBMPFile,CString strJPGFile)
          {
          ??? CLSID? encoderClsid;
          ??? WCHAR? strGuid[39];
          ??? if(GetEncoderClsid(L"image/jpeg", &encoderClsid) >= 0)
          ??? StringFromGUID2(encoderClsid, strGuid, 39);
          ??? Image image(strBMPFile.AllocSysString());
          ??? image.Save(strJPGFile.AllocSysString(),&encoderClsid,NULL);
          }
          posted on 2007-02-27 19:26 飛鳥 閱讀(2356) 評論(7)  編輯  收藏 所屬分類: VC

          評論:
          # re: bmp轉JPG 2008-03-26 13:43 | 就不告訴你
          垃圾,說是java,寫的卻是c的代碼  回復  更多評論
            
          # re: bmp轉JPG 2008-03-26 14:13 | 飛鳥
          你是不是傻啊,沒看到是分在VC類里面,我看你還是不要學編程了  回復  更多評論
            
          # re: bmp轉JPG 2008-03-27 00:21 | 21
          gyuk  回復  更多評論
            
          # re: bmp轉JPG 2008-04-26 22:10 | HE YOU BING
          NI HAO   回復  更多評論
            
          # re: bmp轉JPG 2008-11-23 03:57 | changzihao
          155+  回復  更多評論
            
          # re: bmp轉JPG[未登錄] 2009-08-20 15:35 | 無名
          @就不告訴你
          腦殘  回復  更多評論
            
          # re: bmp轉JPG 2010-02-24 00:04 | lya.79
          他應該是看到 "飛鳥JAVA" 這東西,所以誤以為怎會放在java區裡吧,誤會一場哈。  回復  更多評論
            
          主站蜘蛛池模板: 宜兰市| 瑞丽市| 章丘市| 江西省| 察哈| 卫辉市| 油尖旺区| 德保县| 泗水县| 上虞市| 星座| 兴义市| 龙州县| 九江县| 池州市| 保亭| 新宁县| 阿尔山市| 新营市| 三明市| 建昌县| 天门市| 定日县| 栾川县| 水城县| 锡林浩特市| 宁强县| 伊金霍洛旗| 崇州市| 波密县| 新营市| 吉林市| 运城市| 天台县| 绍兴市| 达拉特旗| 新巴尔虎左旗| 桂平市| 林州市| 宝清县| 锦州市|