用VC++6.0怎么编程实现JPG转换成BMP,求代码,论坛有过类似代码,不过#include   <Gdiplus.h>   
  #include   <GdiPlusEnums.h> 两个头文件打不开,不知道是在什么编译器下运行的,我要的是VC++6.谢谢

解决方案 »

  1.   

    我也正在找多格式图像转换的方法,GDI+的头文件和库文件应该要添加的,原来的库不包含这些
    我也不知道对不对,硕士说自己的看法吧
    希望各路高手能指点下小弟,
    有什么好的方法么,要求也是要用vc来完成多格式图像转换
    先谢谢各位了
      

  2.   

    //jpeglib.h
    BOOL Jpeg2Bmp(LPCWSTR pJpgFileName, LPCWSTR pBmpFileName);
    BOOL Bmp2Jpeg(LPCWSTR pBmpFileName, LPCWSTR pJpgFileName);//jpeglib.cpp
    #include "StdAfx.h"
    #include "JpegLib.h"#ifndef ULONG_PTR
    #define ULONG_PTR unsigned long*
    #endif
     
    #include <Gdiplus.h>   
    #include <GdiPlusEnums.h>   
    using namespace   Gdiplus; 
      
    #pragma comment(lib, "gdiplus.lib")int   GetCodecClsid(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));   
    pImageCodecInfo   =   (ImageCodecInfo*)(new BYTE[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;   
    return   j;     //   Success   
    }           
    }   //   for   
        
    return   -1;     //   Failure   
        
    }   //   GetCodecClsidTopBOOL Jpeg2Bmp(LPCWSTR pJpgFileName, LPCWSTR pBmpFileName)
    {
     CLSID                             codecClsid;   
     EncoderParameters     encoderParameters;   
     long                               quality;   
     Status                           stat;   
     
     //   Get   an   image   from   the   disk.   
     Image image(pJpgFileName);   
     
     //   Get   the   CLSID   of   the   JPEG   codec.   
     GetCodecClsid(L"image/bmp",   &codecClsid);   
     
     //   Before   we   call   Image::Save,   we   must   initialize   an   
     //   EncoderParameters   object.   The   EncoderParameters   object   
     //   has   an   array   of   EncoderParameter   objects.   In   this   
     //   case,   there   is   only   one   EncoderParameter   object   in   the   array.   
     //   The   one   EncoderParameter   object   has   an   array   of   values.   
     //   In   this   case,   there   is   only   one   value   (of   type   LONG)   
     //   in   the   array.   We   will   set   this   value   to   0,   50,   and   100.   
     
     encoderParameters.Count   =   1;   
     encoderParameters.Parameter[0].Guid   =   EncoderQuality;   
     encoderParameters.Parameter[0].Type   =   EncoderParameterValueTypeLong;   
     encoderParameters.Parameter[0].NumberOfValues   =   1;   
     
     //   Save   the   image   as   a   JPEG   with   quality   level   0.   
     quality   =   0;   
     encoderParameters.Parameter[0].Value   =   &quality;   
     stat   =   image.Save(pBmpFileName,   &codecClsid,   &encoderParameters);  return stat   ==   Ok;
    }BOOL Bmp2Jpeg(LPCWSTR pBmpFileName, LPCWSTR pJpgFileName)
    {
     CLSID                             codecClsid;   
     EncoderParameters     encoderParameters;   
     long                               quality;   
     Status                           stat;   
     
     //   Get   an   image   from   the   disk.   
     Image   image(pBmpFileName);   
     
     //   Get   the   CLSID   of   the   JPEG   codec.   
     GetCodecClsid(L"image/jpeg",   &codecClsid);   
     
     //   Before   we   call   Image::Save,   we   must   initialize   an   
     //   EncoderParameters   object.   The   EncoderParameters   object   
     //   has   an   array   of   EncoderParameter   objects.   In   this   
     //   case,   there   is   only   one   EncoderParameter   object   in   the   array.   
     //   The   one   EncoderParameter   object   has   an   array   of   values.   
     //   In   this   case,   there   is   only   one   value   (of   type   LONG)   
     //   in   the   array.   We   will   set   this   value   to   0,   50,   and   100.   
     
     encoderParameters.Count   =   1;   
     encoderParameters.Parameter[0].Guid   =   EncoderQuality;   
     encoderParameters.Parameter[0].Type   =   EncoderParameterValueTypeLong;   
     encoderParameters.Parameter[0].NumberOfValues   =   1;   
     
     //   Save   the   image   as   a   JPEG   with   quality   level   0.   
     quality   =   0;   
     encoderParameters.Parameter[0].Value   =   &quality;   
     stat   =   image.Save(pJpgFileName,   &codecClsid,   &encoderParameters);    return stat   ==   Ok;
    }///////////////
    it's okay
      

  3.   

    这个程序运行的时候也有一个问题。
    jpg_bmp.cpp
    (2) : error C2146: syntax error : missing ';' before identifier 'Jpeg2Bmp'
    (2) : error C2501: 'BOOL' : missing storage-class or type specifiers
    (2) : fatal error C1004: unexpected end of file found