大顽石

凡事太紧,缘分必早尽

  IT博客 :: 首页 :: 联系 :: 聚合  :: 管理
  9 Posts :: 0 Stories :: 14 Comments :: 0 Trackbacks
CXimage真是个不错的咚咚。这里也发个贴子顶一下。
 

CXimage使用还是比较方便。从它的网站下载的cximage600_full.zip的版本直接有debug/release/unicode debug/unicode release四种模式的编译方式。在对cximage工程进行编译前,可以把dependance开关设置为和其它需要的lib工程相关,一起进行编译。

 

在使用CXimage的时候,基本依照它网页上的说明:

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 

                                   ../raw/Debug/libdcr.lib

                                   ../jpeg/Debug/jpeg.lib

                                   ../zlib/Debug/zlib.lib

                                   ../tiff/Debug/tiff.lib

                                   ../jasper/Debug/jasper.lib

                                   ../cximage/Debug/cximage.lib ...In your source code you must add #include "ximage.h"

Note: don't mix debug and release modules; each configuration must use its respective library modules.

 

具体可以参考它附带的demo工程的设置。这里补充两点注意:

1,好像工程的MFC只能够用动态链接的方式;

2,编译好的debug模式的cximage.lib应该有7M左右,并且用dumpbin /exports能够看到输出函数。我在这里出过些问题。我把demo工程设置为active project,然后进行编译,发现编译出来的cximage.lib只有1M多,并且dumpbin /exports也看不到东西的。后来改为把cximage设置为active project,才成功。

 

实际的使用经验:

1, CXimage目录整个拷贝到自己的工程下。

2, 在工程的setting中,依照上面要求配置好。

3, libDLL都拷贝到工程能够找到的地方;

4, 在自己的视类中,添加一个:     CxImage *m_pXImage;

5, 加载一个tiff格式的文件:

              m_pXImage=new CxImage();

              m_pXImage->Load(arg_mapfile,CXIMAGE_FORMAT_TIF);

5,绘图可以在OnPaint中用CXimagedraw()函数,当然也可以用windows函数。其中,特别注意红色的部分是怎样获得的:

              // draw the pic

                     ::StretchDIBits(dc.GetSafeHdc(),UpdateRect.left,UpdateRect.top,

                            UpdateRect.Width(),UpdateRect.Height(),

                            UpdateRect.left*t_ratio,(t_pdoc->m_vMapSize.cy/t_ratio-UpdateRect.top-UpdateRect.Height())*t_ratio,

                            UpdateRect.Width()*t_ratio,UpdateRect.Height()*t_ratio,

                            m_pXImage->GetBits(),(BITMAPINFO*)m_pXImage->GetDIB(),DIB_RGB_COLORS,SRCCOPY);

       }

 

Cimage合并图片就是这么简单:

       CxImage t_img1,t_img2,t_img3;

       int t_h1,t_w1,t_h2,t_w2,t_h3,t_w3,t_bpp;

       t_img1.Load("F:\\1.jpg");

       t_img2.Load("F:\\2.jpg");

       t_h1=t_img1.GetHeight();

       t_w1=t_img1.GetWidth();

       t_h2=t_img2.GetHeight();

       t_w2=t_img2.GetWidth();

       t_h3=t_h1;

       t_w3=t_w1+t_w2;

       t_bpp=t_img1.GetBpp();

       t_img3.Create(t_w3,t_h3,t_bpp);

       t_img3.MixFrom(t_img1,0,0);

       t_img3.MixFrom(t_img2,t_w1,0);

       t_img3.Save("f:\\3.jpg",CXIMAGE_FORMAT_JPG);

 

posted on 2009-02-15 11:20 大顽石 阅读(10992) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。