zoukankan      html  css  js  c++  java
  • ilpimage to bitmap

    Iplimage To Bitmap (銀展提供)



    if (ipl->depth == 8)

    {

    if (ipl->nChannels == 3)

    {

    return gcnew System::Drawing::Bitmap(ipl->width , ipl->height , ipl->widthStep , System::Drawing::Imaging::PixelFormat::Format24bppRgb ,

    (System::IntPtr)ipl->imageData); 

    }

    else

    {

    return gcnew System::Drawing::Bitmap(ipl->width , ipl->height , ipl->widthStep , System::Drawing::Imaging::PixelFormat::Format8bppIndexed ,

    (System::IntPtr)ipl->imageData);

    }

    }



    Bitmap To Iplimage 



    IplImage* tmp;

    System::Drawing::Imaging::BitmapData^ bmData = bitmap->LockBits(System::Drawing::Rectangle(0, 0, bitmap->Width, bitmap->Height) ,

    System::Drawing::Imaging::ImageLockMode::ReadWrite, bitmap->PixelFormat);

    if(bitmap->PixelFormat == System::Drawing::Imaging::PixelFormat::Format8bppIndexed)

    {

    tmp = cvCreateImage(cvSize(bitmap->Width , bitmap->Height) , IPL_DEPTH_8U , 1);

    tmp->imageData = (char*)bmData->Scan0.ToPointer();

    }

    else if (bitmap->PixelFormat == System::Drawing::Imaging::PixelFormat::Format24bppRgb)

    {

    tmp = cvCreateImage(cvSize(bitmap->Width , bitmap->Height) , IPL_DEPTH_8U , 3);

    tmp->imageData = (char*)bmData->Scan0.ToPointer();

    }

  • 相关阅读:
    2014/4/9-最近所想
    DNS坑爹呢?!
    c#委托使用
    sqlserver 获取一个月有多少天
    定时提醒模型
    sqlserver导入dbf文件
    json对象中根据主键判断是否有重复数据
    差异备份与恢复
    html编码和解码
    opendatasource问题
  • 原文地址:https://www.cnblogs.com/mfryf/p/2349443.html
Copyright © 2011-2022 走看看