隨筆-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 飛鳥 閱讀(2365) 評論(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區裡吧,誤會一場哈。  回復  更多評論
            
          主站蜘蛛池模板: 厦门市| 商南县| 无极县| 睢宁县| 鞍山市| 杂多县| 喜德县| 仪征市| 拉萨市| 平罗县| 唐海县| 托克逊县| 广德县| 沭阳县| 临安市| 古交市| 屯留县| 库尔勒市| 衡水市| 海兴县| 金沙县| 湘潭市| 年辖:市辖区| 平潭县| 东乌| 沙坪坝区| 根河市| 天峨县| 汤原县| 沽源县| 渭南市| 中阳县| 商河县| 建始县| 大埔区| 伊金霍洛旗| 合川市| 荥经县| 天全县| 桑植县| 江达县|