从网上下了一个cximage的库,但是很郁闷的是不知道应该如何配置,才能完成多种图像格式得读取。它里面也有个demo,但是我看了看很复杂。一般的库编译了以后,有个.lib还有.dll但是,这个库却没有。请教,有没有人会用这个库,或者会配置。谢谢

解决方案 »

  1.   

    主要是project->Setting 里需要设置
      

  2.   

    你应该好好 它的帮助文章啊 写的很详细的 里面告诉了你怎么在你自己的工程中使用的
    先编译,设置vc的头、源文件路径
    然后在使用的地方加上 #include "ximage.h"
      

  3.   

    Using CxImage in your projects
    The CxImgLib.dsw workspace shows the libraries required to build an application (demo.exe) including almost all the features and the formats available in CxImage. You must compile all the libraries before you can link the final application.
    In the same workspace you'll find the projects to build different libraries and applications:CxImage : cximage.lib - static library 
    CxImageCrtDll : cximagecrt.dll - DLL not using mfc 
    CxImageMfcDll : cximage.dll - DLL using mfc 
    Demo : demo.exe - program linked with cximage.lib and the C libraries 
    DemoDll : demodll.exe - program linked with cximagecrt.dll 
    j2k,jasper,jbig,jpeg,png,tiff,zlib : static C libraries 
    Building the projects will need some minutes to complete (the intermediate files occupy 60MB!). When everything is done, select the demo project and launch the application.
     CxImgLib.dsw
     To use CxImage in your project, you must edit these settings: Project Settings
     |- C/C++
     |   |- Code Generation
     |   |   |- Use run-time library : Multithreaded DLL (must be the same for 
     |   |   |  all the linked libraries)
     |   |   |- Struct member alignment : must be the same for all the linked 
     |   |   |  libraries
     |   |- Precompiled headers : not using precompiled headers
     |   |- Preprocessor
     |       |- Additional Include Directories:  ..\cximage
     |- Link
        |- General
            |- Object/library modules: ../png/Debug/png.lib 
                                       ../jpeg/Debug/jpeg.lib 
                                       ../zlib/Debug/zlib.lib 
                                       ../tiff/Debug/tiff.lib 
                                       ../jasper/Debug/jasper.lib 
                                        ../cximage/Debug/cximage.lib  ...
      

  4.   

    我按照这样做了,可是依旧没有像demo那样,把那些类加进自己的工程。而且在编译的时候,出现了,defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library,这样的waring.帮人帮到底,帮我说清楚一点吧,我第一次接触用到这种库。谢谢了:)同时,还让我觉得迷惑的还有CxImgLib,这个里面怎么有那么多的工程。我第一次看到,能给我解释解释吗?
      

  5.   

    Cximage 使用了别人的图像编码的库 比如jpeg2000 jpeg  这些都是使用现成的库
      

  6.   

    刚才又改了一下,我对我的工程作了这样的修改。除了设置以外,Doc类里面添加了成员变量CxImage* m_image,并且添加了OnOpenDocument函数,用来打开。
    // TODO: Add your specialized creation code here
    CString filename(lpszPathName);
        CString ext(FindExtension(filename));
    ext.MakeLower();
    if (ext == "") return FALSE;
    if (ext == "bmp") type = CXIMAGE_FORMAT_BMP;
    #if CXIMAGE_SUPPORT_JPG
    else if (ext=="jpg"||ext=="jpeg") type = CXIMAGE_FORMAT_JPG;
    #endif
    #if CXIMAGE_SUPPORT_GIF
    else if (ext == "gif") type = CXIMAGE_FORMAT_GIF;
    #endif
    #if CXIMAGE_SUPPORT_PNG
    else if (ext == "png") type = CXIMAGE_FORMAT_PNG;
    #endif
    #if CXIMAGE_SUPPORT_MNG
    else if (ext=="mng"||ext=="jng") type = CXIMAGE_FORMAT_MNG;
    #endif
    #if CXIMAGE_SUPPORT_ICO
    else if (ext == "ico") type = CXIMAGE_FORMAT_ICO;
    #endif
    #if CXIMAGE_SUPPORT_TIF
    else if (ext=="tiff"||ext=="tif") type = CXIMAGE_FORMAT_TIF;
    #endif
    #if CXIMAGE_SUPPORT_TGA
    else if (ext=="tga") type = CXIMAGE_FORMAT_TGA;
    #endif
    #if CXIMAGE_SUPPORT_PCX
    else if (ext=="pcx") type = CXIMAGE_FORMAT_PCX;
    #endif
    #if CXIMAGE_SUPPORT_WBMP
    else if (ext=="wbmp") type = CXIMAGE_FORMAT_WBMP;
    #endif
    #if CXIMAGE_SUPPORT_WMF
    else if (ext=="wmf"||ext=="emf") type = CXIMAGE_FORMAT_WMF;
    #endif
    #if CXIMAGE_SUPPORT_J2K
    else if (ext=="j2k"||ext=="jp2") type = CXIMAGE_FORMAT_J2K;
    #endif
    #if CXIMAGE_SUPPORT_JBG
    else if (ext=="jbg") type = CXIMAGE_FORMAT_JBG;
    #endif
    else return FALSE; m_image = new CxImage(filename, type); if (!m_image->IsValid()){
    AfxMessageBox(m_image->GetLastError());
    delete m_image;
    m_image = NULL;
    return FALSE;
    }  
    return TRUE;

    最后,还有一个函数用来返回m_image,用作显示。在View的OnDraw里面添加了
          CxImage* ima = pDoc->GetImage(); 
    if (ima) {
    ima->Draw(pDC->GetSafeHdc(),
    CRect(0,0,(int)(ima->GetWidth()),(int)(ima->GetHeight())));
    }然而,这样,最后编译可以通过,并且warning也没有了。可是执行起来,却出现错误。
      

  7.   

    这是调用 别人的 dll  的常规的步骤啊
      

  8.   

    看到了你在图形图象那版提出的和此相同的问题。实际上,你只要按照配置详细配置一下就可以了。大概你的代码也没有什么错误。多编译下下,然后,注意你定义的指针,在构造函数里面要附值null,在析构函数里,判断是否为空后在删掉,这样就应该不会有任何问题了。如果,还有问题,可以发到我的邮箱里,我帮你改改:)别着急。