• gdiplus图片格式转换


    还没来得及kan ,先转了再说


    vc6.0必须装gdiplus库文件和头文件

    Given an input stream of some type of image, the followingfunction converts that image into another type of image given thedestination format. The destination format should be a propermime-type such as "image/jpeg", "image/png".

    Gdiplus::Status imageToImage(
      IStream *pStreamIn, IStream *pStreamOut, BSTRwszOutputMimeType)
    {
        namespace G= Gdiplus;
        G::Statusstatus = G::Ok;
        G::ImageimageSrc(pStreamIn);
        status =imageSrc.GetLastStatus();
        if (G::Ok !=status) {
         return status;
        }
        UINTnumEncoders = 0;
        UINTsizeEncodersInBytes = 0;
        status =G::GetImageEncodersSize(&numEncoders,&sizeEncodersInBytes);
        if (status!= G::Ok) {
         return status;
        }
       G::ImageCodecInfo *pImageCodecInfo =
            (G::ImageCodecInfo *) malloc(sizeEncodersInBytes);
        status =G::GetImageEncoders(
             numEncoders, sizeEncodersInBytes, pImageCodecInfo);
        if (status!= G::Ok) {
         return status;
        }
        CLSIDclsidOut;
        status =G::UnknownImageFormat;
        for (UINT j= 0; j < numEncoders; j ++) {
         if (0 == wcscmp(pImageCodecInfo[j].MimeType, wszOutputMimeType)){
           clsidOut = pImageCodecInfo[j].Clsid;
           status = G::Ok;
           break;
           
        }
       free(pImageCodecInfo);
        if (status!= G::Ok) {
         return status;
        }
        returnimageSrc.Save(pStreamOut, &clsidOut);
      }

    It can be used like so:

    extern IStream *pSomeImg; // source image format is notimportant
    extern IStream *pMyJpeg;
    if (Gdiplus::Ok == imageToImage(pSomeImg, pMyJpeg, L"image/jpeg")){
    // pMyJpeg holds the converted jpeg.
    }

    If there is a need to put/retrieve data into/from IStream inbyte-array format (such as char*), it can by done by usingCreateStreamOnHGlobal, GlobalAlloc, GlobalLock Win32 API functions.See this tip for more details
    Note: List of supported formats: BMP, ICON, GIF, JPEG, Exif, PNG,TIFF, WMF, and EMF.



    摘自:http://blog.sina.com.cn/s/blog_ad0672d601017qpn.html

  • 相关阅读:
    淘宝如何做智能化UI测试?
    摸爬滚打16年的软件测试经验,建议收藏!
    QA如何高效参与技术设计评审
    官宣!新冠疫苗全民免费接种,全部费用政府出!
    2021年第一次,送Python好书
    【Python】自动化抢购茅台,真香。
    3年以上测试工程师,你的出路在哪里?
    性能测试的目的与类型
    Burpsuite的简单应用-y-Proxy
    用Burpsuite破解网站密码
  • 原文地址:https://www.cnblogs.com/xieyuan/p/3787427.html
Copyright © 2020-2023  润新知