Witam potrzebuje pomocy.Tworze aplikacje w C# ,która po wybraniu zdjęć z dysku oraz po wykonaniu pętli wybiera interesujące zdjęcie i chciałbym z C# wysłać to zdjęcie do C++ dll. i w nim wykonać jakieś operacje ,np.zdjęcie w odcieniu szarości oraz zwrócenie z powrotem tego do c#.Proszę o nie mówienie ,że są lepsze sposoby bo taki mam temat pracy magisterskiej.
C# code :
for (int i = 0; i <= 30; i++)
{
if (images[n-1]== images[i])//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
{
Bitmap bmp = new Bitmap(images[i]);
int width = bmp.Width;//320
int height = bmp.Height;//239
var rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
var bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
int results = NativeMethods.Gray(bmpData.Width, bmpData.Height, bmpData.Scan0, bmpData.Stride);
bmp.UnlockBits(bmpData);
image2.Image = bmp;
}
}
}
public static class NativeMethods
{
[DllImport("number.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "_Z9AddNumberii")]
public static extern int Gray(int width, int height, IntPtr scan0, int stride);
}
C++ dll code :
int Gray(int width, int height, unsigned char *scan0, int stride)
{
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
}
}
}
Macie może jakieś pomysły jak wypełnić kod C++ dll oraz powiedzieć czy taki sposób w ogóle jest dobry?