////////////////////////////////////////////////////////////////////// // PUT THE FOLLOWING DECLARATIONS IN THE HEADER FILE ////////////////////////////////////////////////////////////////////// HINSTANCE FFLibDllHandle; int ( __stdcall *pfnFFBmpServices )( int, HANDLE, void* ); void ( __stdcall *pfnFFAsciiWrite)( void*, int, int, void*, int, int, int ); int ( __stdcall *pfnFFView )( HWND, void*, int, int, void*, void* ); ////////////////////////////////////////////////////////////////////// // SECTION ONE --- PRELIMINARY OPERATIONS ////////////////////////////////////////////////////////////////////// // load the DLL FFLibDllHandle = 0; FFLibDllHandle = LoadLibrary ( "FFLIB.DLL" ); if ( FFLibDllHandle == 0 ) { MessageBox ( NULL, "LoadLibrary:\nFFLIB.DLL not found.", "Error FS 001", MB_SYSTEMMODAL ); PostQuitMessage ( 0 ); } // load the address of FFBmpServices pfnFFBmpServices = ( int ( __stdcall *)( int, HANDLE, void* ) ) GetProcAddress ( FFLibDllHandle, "FFBmpServices" ); if ( pfnFFBmpServices == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFBmpServices not found.", "Errore FS 003", MB_SYSTEMMODAL ); PostQuitMessage ( 0 ); } // load the address of FFAsciiWrite pfnFFAsciiWrite = ( void ( __stdcall *)( void*, int, int, void*, int, int, int ) ) GetProcAddress ( FFLibDllHandle, "FFAsciiWrite" ); if ( pfnFFAsciiWrite == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFAsciiWrite not found.", "Error FS 003", MB_SYSTEMMODAL ); PostQuitMessage ( 0 ); } // load the address of FFView pfnFFView = ( int ( __stdcall *)( HWND, void*, int, int, void*, void* ) ) GetProcAddress ( FFLibDllHandle, "FFView" ); if ( pfnFFView == NULL ) { MessageBox ( NULL, "GetProcAddress:\nFFView not found.", "Errore FS 003", MB_SYSTEMMODAL ); PostQuitMessage ( 0 ); } ////////////////////////////////////////////////////////////////////// // SECTION TWO --- OPEN AND LOAD THE BMP FILE ////////////////////////////////////////////////////////////////////// // set the name of the image to be decompressed and viewed char filePathAndName [ 256 ]; strcpy ( filePathAndName, "C:\\Lavori\\Sito2\\ROMA.BMP" ); HANDLE handle = CreateFileA ( filePathAndName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if ( handle == INVALID_HANDLE_VALUE ) { MessageBox ( NULL, filePathAndName, "BMP file doesn't open, or doesn't exist:", MB_SYSTEMMODAL ); PostQuitMessage ( 0 ); } // check whether it is a true BMP file (rc==2) int rslt = pfnFFBmpServices ( 1, handle, NULL ); if ( rslt != 2 ) { MessageBox ( NULL, "Hey:\nit's not a bitmap!", "Error FS 003", MB_SYSTEMMODAL ); PostQuitMessage ( 0 ); } // get the width and the height of the image int width = pfnFFBmpServices ( 2, handle, NULL ); int height = pfnFFBmpServices ( 3, handle, NULL ); // allocate a buffer for the image according to its size int frameSize = width * height; HGLOBAL pFrame = GlobalAlloc ( GMEM_FIXED, frameSize ); // carica la palette in memoria void* pPalette; ( int ) pPalette = pfnFFBmpServices ( 4, handle, NULL ); // carica la bitmap in memoria int rc = pfnFFBmpServices ( 5, handle, pFrame ); // close the file CloseHandle ( handle ); ////////////////////////////////////////////////////////////////////// // SECTION FOUR --- WRITE SOMETHING AND VIEW THE IMAGE ////////////////////////////////////////////////////////////////////// // prepare the string to write and print it on the image char myComments [ 1024 ]; strcpy ( myComments, "COLOSSEO" ); pfnFFAsciiWrite ( pFrame, width, height, myComments, 0, 400, 200 ); strcpy ( myComments, "CIRCO MASSIMO" ); pfnFFAsciiWrite ( pFrame, width, height, myComments, 0, 300, 250 ); strcpy ( myComments, "FORO ROMANO" ); pfnFFAsciiWrite ( pFrame, width, height, myComments, 0, 500, 300 ); strcpy ( myComments, "COLONNA TRAIANA" ); pfnFFAsciiWrite ( pFrame, width, height, myComments, 0, 220, 290 ); // call the image display routine Form1 -> WindowState = wsMinimized; pfnFFView ( Application -> Handle, pFrame, width/8, height, pPalette, 0 ); Form1 -> WindowState = wsNormal; ////////////////////////////////////////////////////////////////////// // SECTION FIVE --- FINAL OPERATIONS ////////////////////////////////////////////////////////////////////// // free the memory GlobalFree ( pFrame ); // free the DLL if ( FFLibDllHandle != 0 ) FreeLibrary ( FFLibDllHandle );