Index: trunk/savebmp.cpp
===================================================================
--- trunk/savebmp.cpp	(revision 11)
+++ trunk/savebmp.cpp	(revision 27)
@@ -24,11 +24,7 @@
 #include "model.h"
 
-#define  __PMPRINTF__
-#include "PMPRINTF.H"
-
 /* ------------------------------ */
 static int StrideOf(const MOD *mod)
 {
-    DebugHereIAm();
 	return ( ( mod->gbm.w * mod->gbm.bpp + 31 ) / 32 ) * 4;
 	}
@@ -41,5 +37,4 @@
 	if ( (mod->pbData = (UCHAR*) gbmmem_malloc(stride * mod->gbm.h)) == NULL )
             return FALSE;
-        DebugHereIAm();
         return TRUE;
 	}
@@ -59,5 +54,4 @@
 	if ( !AllocateData(modNew) )
             return MOD_ERR_MEM;
-        DebugHereIAm();
 	return MOD_ERR_OK;
 	}
@@ -85,6 +79,6 @@
 
 	if ( (mrc = ModCreate(w, h, bpp, NULL, modNew)) != MOD_ERR_OK )
-		return mrc;
-        DebugHereIAm();
+            return mrc;
+
 	memset(&(bm.bmp2), 0, sizeof(bm.bmp2));
 	bm.bmp2.cbFix     = sizeof(BITMAPINFOHEADER2);
@@ -105,5 +99,4 @@
 			}
                 }
-        DebugHereIAm();
 	return MOD_ERR_OK;
 	}
@@ -127,9 +120,6 @@
             return grc;
         }
-        PmpfF(( "file type %i", ft ));
-        DebugHereIAm();
         gbm_query_filetype(ft, &gbmft);
-        PmpfF(( "file type %i name %s flags %i bpp %i", ft, gbmft.short_name,
-               gbmft.flags, mod->gbm.bpp));
+        
 	switch ( mod->gbm.bpp )
 		{
@@ -143,9 +133,10 @@
 	if ( (gbmft.flags & flag) == 0 )
             return MOD_ERR_SUPPORT;
-        DebugHereIAm();
+        
 	if ( (fd = gbm_io_create(szFn, GBM_O_WRONLY)) == -1 )
 		return MOD_ERR_CREATE;
-        DebugHereIAm();
-	if ( (grc = gbm_write(szFn, fd, ft, &(mod->gbm), mod->gbmrgb, mod->pbData, szOpt)) != GBM_ERR_OK )
+        
+        if ( (grc = gbm_write(szFn, fd, ft, &(mod->gbm), mod->gbmrgb,
+                              mod->pbData, szOpt)) != GBM_ERR_OK )
 		{
 		gbm_io_close(fd);
@@ -153,7 +144,6 @@
 		return MOD_ERR_GBM(grc);
 		}
-        DebugHereIAm();
+        
 	gbm_io_close(fd);
-        DebugHereIAm();
 	return MOD_ERR_OK;
 	}
@@ -161,5 +151,6 @@
 // ** SaveBitmap ********************************************************** /*FOLD00*/
 
-VOID SaveBitmap (HBITMAP hbm, HPS hps, int width, int height, int bitCount)
+VOID SaveBitmap (HBITMAP hbm, HPS hps, int width, int height,
+                 int bitCount, char *title)
 {
 #ifdef _DOLOGMEM_
@@ -172,58 +163,41 @@
         PSZ psz = pset->QueryForceSaveFile();
         psz = AddExtensionToFilename( psz );
-        //
-        /*if( ( pset->QueryFileFormat() == BMF_12 ) ||
-           ( pset->QueryFileFormat() == BMF_16 ) ||
-           ( pset->QueryFileFormat() == BMF_20 ) ) {
-            SaveBitmapToFile( hbm, psz, hps );
-            DebugHereIAm();
-        }
-        else { */
+        ModCreateFromHPS( hps, width, height,
+                         (bitCount > 8 ) ? 24 : bitCount,
+                         &newmod );
+        ModWriteToFile(&newmod, psz, "" );
+        
+#ifdef _DOLOGMEM_
+        LogMem( "SaveBitmap-1", FALSE );
+#endif
+        return;
+    }
+
+    if (pset->DoSound ())
+    {
+        DosBeep ( 500, 100);
+        DosBeep (1000, 100);
+        DosBeep (1500, 100);
+    }
+
+    switch (pset->QuerySaveStyle ())
+    {
+    case SAVESTYLE_CLIPBOARD:
+        SaveBitmapToClipboard (hbm);
+        break;
+
+    default:
+#ifdef _DOLOGDEBUG_
+        LogDebug( "SaveBitmap()" );
+#endif
+        if (SelectSaveFile (title)) {
+#ifdef _DOLOGDEBUG_
+            LogDebug( "Before call to SaveBitmapToFile()" );
+#endif
             ModCreateFromHPS( hps, width, height,
                              (bitCount > 8 ) ? 24 : bitCount,
                              &newmod );
-            ModWriteToFile(&newmod, psz, "" );
-        //}
-#ifdef _DOLOGMEM_
-        LogMem( "SaveBitmap-1", FALSE );
-#endif
-        return;
-    }
-
-    if (pset->DoSound ())
-    {
-        DosBeep ( 500, 100);
-        DosBeep (1000, 100);
-        DosBeep (1500, 100);
-    }
-
-    switch (pset->QuerySaveStyle ())
-    {
-    case SAVESTYLE_CLIPBOARD:
-        SaveBitmapToClipboard (hbm);
-        break;
-
-    default:
-#ifdef _DOLOGDEBUG_
-        LogDebug( "SaveBitmap()" );
-#endif
-        if (SelectSaveFile ()) {
-#ifdef _DOLOGDEBUG_
-            LogDebug( "Before call to SaveBitmapToFile()" );
-#endif
-            //DebugHereIAm();
-            /*if( ( pset->QueryFileFormat() == BMF_12 ) ||
-               ( pset->QueryFileFormat() == BMF_16 ) ||
-               ( pset->QueryFileFormat() == BMF_20 ) ) {
-                DebugHereIAm();
-                SaveBitmapToFile( hbm, pset->QuerySaveFile (), hps );
-                DebugHereIAm();
-            }
-            else {*/
-                ModCreateFromHPS( hps, width, height,
-                                 (bitCount > 8 ) ? 24 : bitCount,
-                                 &newmod );
-                ModWriteToFile(&newmod, pset->QuerySaveFile (), "" );
-            //}
+            ModWriteToFile(&newmod, pset->QuerySaveFile (), "" );
+
 #ifdef _DOLOGDEBUG_
             LogDebug( "After call to SaveBitmapToFile()" );
@@ -256,10 +230,10 @@
 
 // ** SaveBitmapToFile **************************************************** /*FOLD00*/
-
+#if 0
 #define CB_12HEADER       sizeof (BITMAPINFOHEADER) // == 12
 #define CB_16HEADER       (sizeof (BITMAPINFOHEADER2)-24)
 #define CB_20HEADER       sizeof (BITMAPINFOHEADER2) // == 64
 
-#if 0
+
 VOID SaveBitmapToFile (HBITMAP hbm, PSZ psz, HPS hps)
 {
@@ -442,115 +416,4 @@
     }
 
-    /*else {
-#ifdef _DOLOGDEBUG_
-        LogDebug( "SaveBitmapToFile(): Starting 'else' path." );
-#endif
-        PFN xmmioClose = pset->GetMMIO()->pfmmioClose;
-//        PFN xmmioOpen = pset->GetMMIO()->pfmmioOpen;
-        PFN xmmioWrite = pset->GetMMIO()->pfmmioWrite;
-        PFN xmmioQueryHeaderLength = pset->GetMMIO()->pfmmioQueryHeaderLength;
-        PFN xmmioSetHeader = pset->GetMMIO()->pfmmioSetHeader;
-
-#ifdef _DOLOGDEBUG_
-    LogDebug( "SaveBitmapToFile(): Before GetFOURCC." );
-#endif
-        // ********* WRITE TARGET
-        FOURCC fccTargetIOProc = pset->GetFOURCC();
-
-        // Initialize our info MMIOINFO structure.
-        MMIOINFO mmioinfoTarget;
-#ifdef _DOLOGDEBUG_
-    LogDebug( "SaveBitmapToFile(): Before memset." );
-#endif
-        memset( &mmioinfoTarget, 0L, sizeof( MMIOINFO ) );
-        mmioinfoTarget.fccIOProc   = fccTargetIOProc;
-        mmioinfoTarget.ulTranslate = MMIO_TRANSLATEHEADER | MMIO_TRANSLATEDATA;
-
-#ifdef _DOLOGDEBUG_
-        LogDebug( "SaveBitmapToFile(): Trying to open file." );
-#endif
-        // Open target file.
-        HMMIO hmmioTarget;
-        if( ! ( hmmioTarget = mmioOpen( psz,
-                                        &mmioinfoTarget,
-                                        MMIO_CREATE | MMIO_WRITE |
-                                        MMIO_DENYWRITE | MMIO_NOIDENTIFY ))) {
-            DisplayError ("mmioOpen()-Error",
-                          "mmioOpen()-Error %ld", mmioinfoTarget.ulErrorRet );
-            return;
-        }
-#ifdef _DOLOGDEBUG_
-        LogDebug( "SaveBitmapToFile(): Open file ok." );
-#endif
-
-        // Set the target header.
-        ULONG ulImageHeaderLength;
-
-        mmioQueryHeaderLength( hmmioTarget, (PLONG)&ulImageHeaderLength, 0L, 0L );
-        if( ulImageHeaderLength != sizeof( MMIMAGEHEADER ) )
-        {
-            // We have a problem.....possibly incompatible versions.
-            mmioClose( hmmioTarget, 0L );
-            DisplayError ("mmioQueryHeaderLength()-Error",
-                          "mmioQueryHeaderLength()-Error",
-                          WinGetLastError (hab));
-            return;
-        }
-#ifdef _DOLOGDEBUG_
-        LogDebug( "SaveBitmapToFile(): xmmioQueryHeaderLength ok." );
-#endif
-
-        MMIMAGEHEADER mmImgHdr;
-        mmImgHdr.ulHeaderLength = ulImageHeaderLength;
-        mmImgHdr.ulContentType  = MMIO_IMAGE_UNKNOWN;
-        mmImgHdr.ulMediaType    = MMIO_MEDIATYPE_IMAGE;
-
-#ifdef _DOLOGDEBUG_
-    LogDebug( "SaveBitmapToFile(): Before memcpy (colors)." );
-#endif
-        memcpy( mmImgHdr.bmiColors,
-                PBYTE( &( pbfh2->bmp2 ) ) + sizeof( BITMAPINFOHEADER2 ),
-                cbColtab );
-
-        mmImgHdr.mmXDIBHeader.XDIBHeaderPrefix.ulMemSize = cbBits; // FIXME;
-        mmImgHdr.mmXDIBHeader.XDIBHeaderPrefix.ulPelFormat = 0; // FIXME;
-        mmImgHdr.mmXDIBHeader.XDIBHeaderPrefix.usTransType = 0; // FIXME
-        mmImgHdr.mmXDIBHeader.XDIBHeaderPrefix.ulTransVal = 0;  // FIXME
-        memcpy( &(mmImgHdr.mmXDIBHeader.BMPInfoHeader2), &bih2, sizeof (BITMAPINFOHEADER2));
-
-#ifdef _DOLOGDEBUG_
-    LogDebug( "SaveBitmapToFile(): Before xmmioSetHeader." );
-#endif
-        ULONG ulBytesRead;
-        if( ( rc = (LONG)mmioSetHeader( hmmioTarget, (MMIMAGEHEADER*)&mmImgHdr,
-                                         (LONG)sizeof( MMIMAGEHEADER ), (PLONG)&ulBytesRead,
-                                         0L, 0L ) ) != MMIO_SUCCESS )
-        {
-            // Header unavailable.
-            mmioClose( hmmioTarget, 0L );
-            DisplayError ("mmioSetHeader()-Error",
-                          "mmioSetHeader()-Error %ld", rc );
-            return;
-        }
-#ifdef _DOLOGDEBUG_
-        LogDebug( "SaveBitmapToFile(): xmmioSetHeader ok." );
-#endif
-
-        // write the actual bitmap data bits
-        if( ( rc = mmioWrite( hmmioTarget, (CHAR *) pb, cbBits ) ) == MMIO_ERROR )
-            DisplayError ("mmioWrite()-Error",
-                          "mmioWrite()-Error %ld", rc );
-#ifdef _DOLOGDEBUG_
-        LogDebug( "SaveBitmapToFile(): xmmioWrite ok." );
-#endif
-
-        if( ( rc = mmioClose( hmmioTarget, 0 ) ) != MMIO_SUCCESS )
-            DisplayError ("mmioClose()-Error",
-                          "mmioClose()-Error %ld", rc );
-#ifdef _DOLOGDEBUG_
-        LogDebug( "SaveBitmapToFile(): xmmioClose ok." );
-#endif
-    } */
-
 #ifdef _DOLOGDEBUG_
     LogDebug( "SaveBitmapToFile(): Everything done, closed file" );
@@ -569,5 +432,5 @@
 #endif
 // ** SetEAs ************************************************************** /*FOLD00*/
-
+#if 0
 BOOL SetEAs (PSZ psz)
 {
@@ -621,8 +484,8 @@
     return TRUE;
 }
-
+#endif
 // ** SelectSaveFile ****************************************************** /*FOLD00*/
 
-BOOL SelectSaveFile (VOID)
+BOOL SelectSaveFile (char *title)
 {
 #ifdef _DOLOGMEM_
@@ -632,9 +495,10 @@
     if (pset->QueryFileSaveStyle () == FSS_NUMFILES)
     {
+        PmpfF(( " title %s", title));
         CHAR   ach[_MAX_PATH];
-        for (USHORT i = 0; i < 10000; i++)
+        for (USHORT i = 0; i < 100; i++)
         {
-            sprintf( ach, "%s\\got%05d.%s", pset->QueryNumSaveDir(), i,
-                     pset->GetFileExtension() );
+            sprintf( ach, "%s\\%s%02d.%s", pset->QueryNumSaveDir(),
+                    title, i, pset->GetFileExtension() );
             if (access (ach, 0) != 0)
             {
