//---------------------------------------------------------------------------

#ifndef wsq_demo_main_formH
#define wsq_demo_main_formH
//---------------------------------------------------------------------------



#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Buttons.hpp>


#include <Graphics.hpp>


// File access routines
#include <stdio.h>
#include <fcntl.h>
#include <io.h>




//WSQ image library declaration of functions

typedef int (*RegisterWSQ)();
typedef HBITMAP (*CreateBMPFromFile)( const char *filename);
typedef int (*SaveBMPToFile)(HBITMAP hBitmap, const char *filename, int filetype);
typedef HBITMAP (*CreateBMPFromWSQByteArray)(unsigned char *input_wsq_byte_array, int size_of_input_wsq_byte_array);
typedef int (*SaveWSQByteArrayToImageFile)(unsigned char *input_wsq_byte_array, int size_of_input_wsq_byte_array, const char *filename, int filetype);
typedef int (*SetShowFilePropertiesDialog)(int file_properties_dialog);
typedef int (*ShowFileConverter)();
typedef int (*WSQ_decode_stream)(unsigned char *input_data_stream, const int input_stream_length, unsigned char **output_data_stream, int *width, int *height, int *ppi, char **comment_text);
typedef int (*WSQ_encode_stream)(unsigned char *input_data_stream, const int width, const int height, const double bitrate, const int ppi, char *comment_text, unsigned char **output_data_stream, int *output_stream_length);
typedef HBITMAP (*ConvertHBITMAPtoGrayScale256)(HBITMAP hBitmap);
typedef int (*SaveHBITMAPtoFileAsGrayScale256BMP)(HBITMAP hBitmap, const char *filename);



RegisterWSQ pRegisterWSQ;
CreateBMPFromFile  pCreateBMPFromFile;
SaveBMPToFile  pSaveBMPToFile;
CreateBMPFromWSQByteArray pCreateBMPFromWSQByteArray;
SaveWSQByteArrayToImageFile pSaveWSQByteArrayToImageFile;
SetShowFilePropertiesDialog pSetShowFilePropertiesDialog;
ShowFileConverter pShowFileConverter;
WSQ_decode_stream pWSQ_decode_stream;
WSQ_encode_stream pWSQ_encode_stream;
ConvertHBITMAPtoGrayScale256 pConvertHBITMAPtoGrayScale256;
SaveHBITMAPtoFileAsGrayScale256BMP pSaveHBITMAPtoFileAsGrayScale256BMP;




HINSTANCE hWSQ_library;



   unsigned char *input_data_stream, *output_data_stream;
   unsigned char *input_data_stream2, *output_data_stream2;
   int width, height, ppi;
   double bitrate;
   char* comment_text;
   char* comment_text2;
   int ret, n, input_stream_length;
   FILE *infp, *outfp;
   int handle;
   int output_stream2_length;
   char* save_filename_with_extension;



//---------------------------------------------------------------------------
class TMainForm : public TForm
{
__published:	// IDE-managed Components
        TImage *OutputImage;
        TButton *OpenButton;
        TButton *SaveButton;
        TButton *RegisterButton;
	TButton *WSQtoStreamButton;
	TButton *StreamToWSQButton;
        void __fastcall OpenButtonClick(TObject *Sender);
        void __fastcall SaveButtonClick(TObject *Sender);
        void __fastcall RegisterButtonClick(TObject *Sender);
	void __fastcall FormShow(TObject *Sender);
	void __fastcall WSQtoStreamButtonClick(TObject *Sender);
	void __fastcall StreamToWSQButtonClick(TObject *Sender);
private:	// User declarations
public:		// User declarations
        __fastcall TMainForm(TComponent* Owner);
        __fastcall ~TMainForm();


            HBITMAP hBitmap;// = NULL;


};
//---------------------------------------------------------------------------
extern PACKAGE TMainForm *MainForm;
//---------------------------------------------------------------------------
#endif
