隨筆-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區裡吧,誤會一場哈。  回復  更多評論
            
          主站蜘蛛池模板: 钟山县| 鄂托克旗| 集安市| 茶陵县| 临邑县| 清水河县| 措美县| 汾阳市| 巫山县| 曲沃县| 山东省| 平原县| 饶平县| 华坪县| 罗江县| 开阳县| 上林县| 丹江口市| 鄢陵县| 赤峰市| 犍为县| 封丘县| 衢州市| 南开区| 城口县| 突泉县| 犍为县| 宁安市| 南雄市| 乌鲁木齐县| 宝坻区| 云和县| 鹤壁市| 仲巴县| 池州市| 汉川市| 资兴市| 玉门市| 富川| 新营市| 应用必备|