// Nbis.h

#include <malloc.h>
#include <memory.h>

#include "Interop.h"

#pragma once

using namespace System;
using namespace System::Drawing;
using namespace System::Drawing::Imaging;
using namespace System::Runtime::InteropServices;


namespace Nbis {

	public enum class Finger {
		LeftOrRightSlap = 0,
		RightThumb = 1,
		RightIndex = 2,
		RightMiddle = 3,
		RightRing = 4,
		RightLittle = 5,
		LeftThumb = 6,
		LeftIndex = 7,
		LeftMiddle = 8,
		LeftRing = 9,
		LeftLittle = 10,	
		RightSlap = 13,
		LeftSlap = 14,
		BothThumbs = 23
	};

	public ref class SegmenterParameters {
		public:
			property bool IsInked;
			property bool PermitRotation;
			property Finger TargetFingers;
	};

	public ref class Segment {
		public:
			property int Width;
			property int Height;
			property int OriginX;
			property int OriginY;
			property float Rotation;
	};


	public ref class NbisException : ApplicationException
	{
	public:
		NbisException(int errorCode, String^ message);
		property int ErrorCode;
	};

	public ref class Nfiq {
	public:
		static int FromFile(String^ filename);
		static int FromBitmap(Bitmap^ image, int pixels_per_inch);
		static int FromWsq(array<Byte>^ wsqAsByteArray);
	};

	public ref class Wsq {
	public:
		static Bitmap^ FromWsqToBitmap(array<Byte>^ wsq_data);
		static array<Byte>^ FromBitmapToWsq(Bitmap^ image, float bitrate, int pixels_per_inch, String^ comment);
	};

	public ref class Segmentation {
	public:
		static array<Segment^>^ FromBitmap(Bitmap^ image, SegmenterParameters^ options);
	};


	public ref class Shared {
	public:
		static int DetermineImageDepth(Bitmap ^image);
		static void CheckReadAndDecodeGreyscaleImageOutcome(int return_value);
		static void* FromBitmapToRaw(int width, int height, int stride, IntPtr data);
		static Bitmap^ LoadFileIntoBitmap(String^ filename);
	};

	public ref class Minutia {
	public:
		property int X;
		property int Y;
		property int Direction;
	};

	public ref class DetectMinutiae {
	public:
		static array<Minutia^>^ FromBitmap(Bitmap ^image, int pixels_per_inch);
	};
	
	public ref class Matcher {
	public:
		static int Compare(array<Minutia^>^ probe, array<Minutia^>^ gallery);
	};	
};