Ejemplo n.º 1
0
void CvvImage::CopyOf( IplImage* img, int desired_color )
{
	try
	{
		if (HG_IS_IMAGE(img))
		{
			int color = desired_color;
			CvSize size = cvGetSize(img);

			if (color < 0)
				color = img->nChannels > 1;

			if (Create(size.width, size.height,
				(!color ? 1 : img->nChannels > 1 ? img->nChannels : 3) * 8,
				img->origin))
			{
				cvConvertImage(img, m_img, 0);
			}
		}
	}
	catch (cv::Exception &exc)
	{
		char szLog[300] = { 0 };
		sprintf_s(szLog, "CvvImage::CopyOf error. detail: %s\n\n", exc.msg);
		TRACE(szLog);
	}
	catch (...)
	{
		char szLog[300] = { 0 };
		sprintf_s(szLog, "CvvImage::CopyOf error2. Unknown error.\n\n");
		TRACE(szLog);
	}
}
Ejemplo n.º 2
0
void  CvvImage::CopyOf( IplImage* img, int desired_color )
{
   if( HG_IS_IMAGE(img) )
   {
      int color = desired_color;
      CvSize size = cvGetSize( img ); 
      if( color < 0 )
         color = img->nChannels > 1;
      if( Create( size.width, size.height,
         (!color ? 1 : img->nChannels > 1 ? img->nChannels : 3)*8,
         img->origin ))
      {
         cvConvertImage( img, m_img, 0 );
      }
   }
}
Ejemplo n.º 3
0
void  CvvImage::CopyOf( IplImage* img, int desired_color )
{
	if( HG_IS_IMAGE(img) )
	{
		int color = desired_color;
		CvSize size = cvGetSize( img ); 
		if( color < 0 )
			color = img->nChannels > 1;
		//此处create函数开辟了内存
		if( Create( size.width, size.height,
			(!color ? 1 : img->nChannels > 1 ? img->nChannels : 3)*8,
			img->origin ))
		{
			//没有单独申请空间
			cvConvertImage( img, m_img, 0 ); //也需要一开始就申请好内存
			//cvCopy(img,m_img,0);//需要重新开辟内存,即img和m_img必须都指向申请的内存
		}
	}
}