如何使用GDI或者GDI+的函数对IplImage进行图像处理
1个回答
展开全部
(1 )IplImage -> Bitmap and Bitmap -> IplImage
IplImage *img ;
Bitmap bitmap( 20 ,20 ,PixelFormat24bppRGB ) ;
Graphics pGra( bitmap) ;
HDC hdc = pGra ->GetHDC() ;
CvImage cvimg ;
cvimg.CopyOf( img , -1) ;
RECT rect = { 0 , 0 , img ->width , img ->height } ;
cvimg.DrawToHDC( hdc , rect ) ;
pGra ->ReleaseHDC( hdc ) ;
IplImage *tempimg = cvCreateImage(cvSize(bitmpa ->GetWidth() , bitmap->Getheight(), 8 , 3) ;
BitmapData mydata;
Rect rect(0, 0, bitmpa ->GetWidth() , bitmap ->Getheight()) ;
bitmap.LockBits( rect , ImageLockModeRead , PixelFormat24bppRGB ,mydata) ;
memcpy(tempimg ->imagedata, mydata.scan0 , tempimg->width * tempimg->height* 3) ;
bitmap.UnlockBits( objdata ) ;
(2) CBitmap ->Bitmap adn Bitmap -> CBitamp
CDC *pdc = this ->GetDC() ;
CBitmap m_Cbit;
m_Cbit.CreateCompatibleBitmap(pdc , 100 ,100 ) ;
Bitmap m_bit((HBITMAP) m_Cbit , NULL) ;
HBITMAP bitmap ;
m_bit.GetHBITMAP( Color( 0 , 0 , 0) , bitmap ) ;
CBitmap *m_pbit = CBitmap ::FromHandle( bitmap) ;
do something ;
m_pbit->DeleteObject() ;
(3) IplImage ->CBitmap , Cbitmap ->IplImage
CDC *pdc = this ->GetDC() ;
IplImage *img = cvCreateImage( cvSize( 100,100 ) , 8 , 3 );
CBitmap m_bitmap ;
m_bitmap.CreateCompatibleBitmap( pdc , 100 ,100 ) ;
CDC memdc ;
memdc.CreateCompatibleDC( pdc ) ;
CBitmap *pold = memdc .SelectObject( m_bitmap) ;
CvvImage cvimg ;
Rect rect(0 , 0 , 100,100 ) ;
cvimg.CopyOf( img , -1 ) ;
cvimg.DrawToHDC( memdc.m_hDC , rect ) ;
ReleaseDC( pdc) ;
IplImage *tempimg = cvCloneImage( img ) ;
m_bitmap.GetBitmapBits( img ->widthStep * img ->height , img ->imageData) ;
CDC *pdc = this ->GetDC() ;
IplImage *img = cvCreateImage( cvSize( 100,100 ) , 8 , 3 );
CBitmap m_bitmap ;
m_bitmap.CreateCompatibleBitmap( pdc , 100 ,100 ) ;
CDC memdc ;
memdc.CreateCompatibleDC( pdc ) ;
CBitmap *pold = memdc .SelectObject( m_bitmap) ;
CvvImage cvimg ;
Rect rect(0 , 0 , 100,100 ) ;
cvimg.CopyOf( img , -1 ) ;
cvimg.DrawToHDC( memdc.m_hDC , rect ) ;
ReleaseDC( pdc) ;
IplImage *tempimg = cvCloneImage( img ) ;
m_bitmap.GetBitmapBits( img ->widthStep * img ->height , img ->imageData) ;
转载,仅供参考。
IplImage *img ;
Bitmap bitmap( 20 ,20 ,PixelFormat24bppRGB ) ;
Graphics pGra( bitmap) ;
HDC hdc = pGra ->GetHDC() ;
CvImage cvimg ;
cvimg.CopyOf( img , -1) ;
RECT rect = { 0 , 0 , img ->width , img ->height } ;
cvimg.DrawToHDC( hdc , rect ) ;
pGra ->ReleaseHDC( hdc ) ;
IplImage *tempimg = cvCreateImage(cvSize(bitmpa ->GetWidth() , bitmap->Getheight(), 8 , 3) ;
BitmapData mydata;
Rect rect(0, 0, bitmpa ->GetWidth() , bitmap ->Getheight()) ;
bitmap.LockBits( rect , ImageLockModeRead , PixelFormat24bppRGB ,mydata) ;
memcpy(tempimg ->imagedata, mydata.scan0 , tempimg->width * tempimg->height* 3) ;
bitmap.UnlockBits( objdata ) ;
(2) CBitmap ->Bitmap adn Bitmap -> CBitamp
CDC *pdc = this ->GetDC() ;
CBitmap m_Cbit;
m_Cbit.CreateCompatibleBitmap(pdc , 100 ,100 ) ;
Bitmap m_bit((HBITMAP) m_Cbit , NULL) ;
HBITMAP bitmap ;
m_bit.GetHBITMAP( Color( 0 , 0 , 0) , bitmap ) ;
CBitmap *m_pbit = CBitmap ::FromHandle( bitmap) ;
do something ;
m_pbit->DeleteObject() ;
(3) IplImage ->CBitmap , Cbitmap ->IplImage
CDC *pdc = this ->GetDC() ;
IplImage *img = cvCreateImage( cvSize( 100,100 ) , 8 , 3 );
CBitmap m_bitmap ;
m_bitmap.CreateCompatibleBitmap( pdc , 100 ,100 ) ;
CDC memdc ;
memdc.CreateCompatibleDC( pdc ) ;
CBitmap *pold = memdc .SelectObject( m_bitmap) ;
CvvImage cvimg ;
Rect rect(0 , 0 , 100,100 ) ;
cvimg.CopyOf( img , -1 ) ;
cvimg.DrawToHDC( memdc.m_hDC , rect ) ;
ReleaseDC( pdc) ;
IplImage *tempimg = cvCloneImage( img ) ;
m_bitmap.GetBitmapBits( img ->widthStep * img ->height , img ->imageData) ;
CDC *pdc = this ->GetDC() ;
IplImage *img = cvCreateImage( cvSize( 100,100 ) , 8 , 3 );
CBitmap m_bitmap ;
m_bitmap.CreateCompatibleBitmap( pdc , 100 ,100 ) ;
CDC memdc ;
memdc.CreateCompatibleDC( pdc ) ;
CBitmap *pold = memdc .SelectObject( m_bitmap) ;
CvvImage cvimg ;
Rect rect(0 , 0 , 100,100 ) ;
cvimg.CopyOf( img , -1 ) ;
cvimg.DrawToHDC( memdc.m_hDC , rect ) ;
ReleaseDC( pdc) ;
IplImage *tempimg = cvCloneImage( img ) ;
m_bitmap.GetBitmapBits( img ->widthStep * img ->height , img ->imageData) ;
转载,仅供参考。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询