续。
如果有CvvImage类最好就用这个类
//IplImage* imgSrc;
//HDC hDC;
//CRect rect;
CvvImage imgShow;
imgShow.CopyOf(imgSrc,imgSrc->nChannels);
imgShow.DrawToHDC(hDC,rect);
在OpenCV高版本(最近好像有2.4Beta2版本了)如2.3.1没有CvvImage类,我们可以自己添加这个类到自己的工程中。
找到他们的头文件和实现文件。因为我已另外经安装了OpenCV1.0,找到
..\..\\otherlibs\highgui\image.cpp文件,这个就是实现文件了,头文件也很容易,自己写也可以
首先是头文件。
///
//CvvImage.h
//#pragma once
#ifndef CVVIMAGE_CLASS_DEF
#define CVVIMAGE_CLASS_DEF
#include "opencv.hpp"
class CvvImage
{
public:
CvvImage();
virtual ~CvvImage();
virtual bool Create( int width, int height, int bits_per_pixel, int image_origin = 0 );
virtual bool Load( const char* filename, int desired_color = 1 );
virtual bool LoadRect( const char* filename,
int desired_color, CvRect r );
#if defined WIN32 || defined _WIN32
virtual bool LoadRect( const char* filename,int desired_color, RECT r )
{
return LoadRect( filename, desired_color,
cvRect( r.left, r.top, r.right - r.left, r.bottom - r.top ));
}
#endif
virtual bool Save( const char* filename );
virtual void CopyOf( CvvImage& image, int desired_color = -1 );
virtual void CopyOf( IplImage* img, int desired_color = -1 );
IplImage* GetImage() { return m_img; };
virtual void Destroy(void);
int Width() { return !m_img ? 0 : !m_img->roi ? m_img->width : m_img->roi->width; };
int Height() { return !m_img ? 0 : !m_img->roi ? m_img->height : m_img->roi->height;};
int Bpp() { return m_img ? (m_img->depth & 255)*m_img->nChannels : 0; };
virtual void Fill( int color );
virtual void Show( const char* window );
#if defined WIN32 || defined _WIN32
virtual void Show( HDC dc, int x, int y, int width, int height,
int