public void Test() { Console.WriteLine("--- BinaryPayload ---"); var sw = new System.Diagnostics.Stopwatch(); // 画像の平均輝度を取得(C#) sw.Restart(); double csy = ImagePath.GetAverageY(); Console.WriteLine($"C# AverageY={csy:f2} {sw.Elapsed} sec"); // 画像の平均輝度を取得(PInvoke) sw.Restart(); double cppy; using (var bitmap = new Bitmap(ImagePath)) { var rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height); var bitmapData = bitmap.LockBits(rect, ImageLockMode.ReadOnly, bitmap.PixelFormat); try { var payload = new ImagePayload(bitmap, bitmapData); cppy = GetImageAllY(payload); } finally { bitmap.UnlockBits(bitmapData); } } Console.WriteLine($"C++ AverageY={cppy:f2} {sw.Elapsed} sec"); }
private extern static double GetImageAllY(ImagePayload imagePayload);