[DllImport("Project1.dll")]
unsafe static extern void CallFu(string OpenFile, string SaveFile);
This is dll on C++
The Function get image file string do smth and save new image to SaveFile string.
extern "C" void __export __stdcall CallFu(char* filepath,char* savefilepath)
Then i try to put saved image to ImageControl
string save = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\segmentedKletka.bmp";
private void B_AutoSegm_Click(object sender, System.Windows.RoutedEventArgs e)
{
string open = MainWindow.OsnovnoyClassPict.Pict_Source;
CallFu(open, save);
BitmapImage s_bmp = new BitmapImage(new Uri(save));
Slider_Kletka.Maximum = Slider_Yadro.Maximum = s_bmp.Width;
Slider_Kletka.Value = Slider_Yadro.Value = s_bmp.Width / 2;
Slider_Kletka.IsEnabled = Slider_Yadro.IsEnabled = true;
Img_Kletka.Source = Img_Yadro.Source = s_bmp;
}
and here i get the error
An unhandled exception of type ‘System.ArithmeticException’ occurred in mscorlib.dll
Additional information: Переполнение или потеря точности в арифметической операции. (Overflow or underflow in the arithmetic operation.)
How use c++ dll in WPF correctly?
[DllImport("Project1.dll")]
unsafe static extern void CallFu(string OpenFile, string SaveFile);
public Form1()
{
InitializeComponent();
string open = "D:\\SPPR_Gem\\SPPRGem\\bin\\Release\\kletki\\1a2a917d-45379cc5-451b3e95-a20e772c.bmp";
string save = "D:\\Projects\\SPPRGem\\SPPRGem\\bin\\Release\\segmentedKletka.bmp";
CallFu(open, save);
pictureBox1.Image = new Bitmap(save);
}
This is in c# only. And i have no errors.
P.S. sorry for my bad english =)
Solution
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/a31f9c7a-0e15-4a09-a544-bec07f0f152c