From dda263edb261906d329de2f53aced0eb3b3e3f78 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Wed, 22 Jul 2015 09:43:53 +0200 Subject: [PATCH 1/2] Bugfix: Bitmap ctor throws an exception if we attempt to create an empty bitmap (0, 0). --- src/bindings/csharp/openalpr-net/helper-net.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bindings/csharp/openalpr-net/helper-net.h b/src/bindings/csharp/openalpr-net/helper-net.h index ce93a1b..806ace0 100644 --- a/src/bindings/csharp/openalpr-net/helper-net.h +++ b/src/bindings/csharp/openalpr-net/helper-net.h @@ -50,6 +50,11 @@ namespace openalprnet static Bitmap^ MatToBitmap(cv::Mat mat) { + if (mat.empty()) + { + return nullptr; + } + const int width = mat.size().width; const int height = mat.size().height; const int channels = mat.channels(); From f7f1337757fd0a1ffad0bb5ced6454e290189306 Mon Sep 17 00:00:00 2001 From: Peter Rekdal Sunde Date: Wed, 22 Jul 2015 09:44:41 +0200 Subject: [PATCH 2/2] Throw a more descriptive exception when pixelformat is unsupported. --- src/bindings/csharp/openalpr-net/bitmapmat-net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bindings/csharp/openalpr-net/bitmapmat-net.h b/src/bindings/csharp/openalpr-net/bitmapmat-net.h index a65acf3..cedbf94 100644 --- a/src/bindings/csharp/openalpr-net/bitmapmat-net.h +++ b/src/bindings/csharp/openalpr-net/bitmapmat-net.h @@ -65,7 +65,7 @@ namespace openalprnet { channels = 4; break; default: - throw gcnew NotImplementedException(); + throw gcnew NotSupportedException(bitmap->PixelFormat.ToString()); } BitmapData^ bitmapData = bitmap->LockBits(