winForm 으로 이미지 로딩하기
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Formusing OpenCvSharp;
using OpenCvSharp.Extensions;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
showImageUsingPictureBox();
showImageUsingPictureBoxIpl();
}
private void showImageUsingPictureBoxIpl()
{
using (var iplImage = new Mat(@"c:\lena512.jpg", ImreadModes.AnyDepth | ImreadModes.AnyColor))
{
Cv2.Dilate(iplImage, iplImage, new Mat());
var pictureBoxIpl = new OpenCvSharp.UserInterface.PictureBoxIpl
{
ImageIpl = iplImage,
AutoSize = true
};
flowLayoutPanel1.Controls.Add(pictureBoxIpl);
//How to redraw:
//pictureBoxIpl.RefreshIplImage(iplImage);
}
}
private void showImageUsingPictureBox()
{
Bitmap bitmap;
using (var iplImage = new Mat(@"c:\lena512.jpg", ImreadModes.AnyDepth | ImreadModes.AnyColor))
{
bitmap = iplImage.ToBitmap(); // BitmapConverter.ToBitmap()
}
var pictureBox = new PictureBox
{
Image = bitmap,
ClientSize = bitmap.Size
};
//How to redraw:
//iplImage.ToBitmap(dst: (Bitmap)pictureBox.Image);
flowLayoutPanel1.Controls.Add(pictureBox);
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Formusing OpenCvSharp;
using OpenCvSharp.Extensions;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
showImageUsingPictureBox();
showImageUsingPictureBoxIpl();
}
private void showImageUsingPictureBoxIpl()
{
using (var iplImage = new Mat(@"c:\lena512.jpg", ImreadModes.AnyDepth | ImreadModes.AnyColor))
{
Cv2.Dilate(iplImage, iplImage, new Mat());
var pictureBoxIpl = new OpenCvSharp.UserInterface.PictureBoxIpl
{
ImageIpl = iplImage,
AutoSize = true
};
flowLayoutPanel1.Controls.Add(pictureBoxIpl);
//How to redraw:
//pictureBoxIpl.RefreshIplImage(iplImage);
}
}
private void showImageUsingPictureBox()
{
Bitmap bitmap;
using (var iplImage = new Mat(@"c:\lena512.jpg", ImreadModes.AnyDepth | ImreadModes.AnyColor))
{
bitmap = iplImage.ToBitmap(); // BitmapConverter.ToBitmap()
}
var pictureBox = new PictureBox
{
Image = bitmap,
ClientSize = bitmap.Size
};
//How to redraw:
//iplImage.ToBitmap(dst: (Bitmap)pictureBox.Image);
flowLayoutPanel1.Controls.Add(pictureBox);
}
}
}
폼에 flowLayoutPanel 을 하나 언저주어야.
답글삭제