資料來源: display cv::Mat (opencv 2.4.3) in pictureBox (Visual C++ 2010)
Mat img;
openFileDialog1->Filter = "JPEG files (*.jpg)|*.jpg|Bitmap files (*.bmp)|*.bmp";
if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
img = imread(openFileDialog1->FileName, CV_LOAD_IMAGE_COLOR);
System::Drawing::Graphics^ graphics = pictureBox1->CreateGraphics();
System::IntPtr ptr(img.ptr());
System::Drawing::Bitmap^ b = gcnew System::Drawing::Bitmap(img.cols,img.rows,img.step,System::Drawing::Imaging::PixelFormat::Format24bppRgb,ptr);
System::Drawing::RectangleF rect(0,0,pictureBox1->Width,pictureBox1->Height);
graphics->DrawImage(b,rect);
}
資料來源: C++/CLI Converting from System::String^ to std::string
#include <msclr/marshal_cppstd.h>
System::String^ xyz="Hi boys";
std::string converted_xyz = msclr::interop::marshal_as< std::string >( xyz );
留言列表