using namespace cv;
Mat src, src_gray;
CvRect Rect;

// 開啟檔案對話框                

if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK){
// 讀取影像                    

src = imread( msclr::interop::marshal_as< std::string >(openFileDialog1->FileName), CV_LOAD_IMAGE_COLOR);

                     System::Drawing::Graphics^ graphics = pictureBox1->CreateGraphics();
                     System::IntPtr ptr(src.ptr());   // 傳入指標
                     System::Drawing::Bitmap^ b  = gcnew System::Drawing::Bitmap(src.cols,src.rows,src.step,System::Drawing::Imaging::PixelFormat::Format24bppRgb,ptr);
                     //pictureBox1->Width = src.cols;
                     //pictureBox1->Height = src.rows;
                     System::Drawing::RectangleF rect(0,0,pictureBox1->Width,pictureBox1->Height);
                     graphics->DrawImage(b,rect);

 

範例程式: ShowOpenCVImage245

全站熱搜
創作者介紹
創作者 me1237guy 的頭像
me1237guy

天天向上

me1237guy 發表在 痞客邦 留言(0) 人氣()