home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 7 Games / 07-Games.zip / PMCHESSR.ZIP / CONVERT.C < prev    next >
C/C++ Source or Header  |  1990-11-29  |  3KB  |  95 lines

  1. //
  2. //  Copyright (C)  Kent D. Cedola  All Rights Reserved.
  3. //
  4. //  Project:    Port Windows GNU Chess to OS/2 PM (PmChess).
  5. //
  6. //  Program:    Convert Windows 3.0 B/W Bitmaps to OS/2 B/W Bitmaps.
  7. //
  8. //   Author:    Kent David Cedola
  9. //
  10. //   System:    OS2 1.2 using Microsoft C 6.0
  11. //
  12. //  Remarks:    This is a quick and dirty tool that I used to convert the B/W
  13. //              bitmaps in the Windows 3.0 version of GNU Chess to something
  14. //              that OS/2 can understand.  After which I will used the OS/2
  15. //              IconEditor to modify the bitmaps (if required).
  16. //
  17. //              Actually I just peeked at the Windows bitmaps and a PM bitmaps
  18. //              and just moved the last 128 bytes from the Windows bitmap to
  19. //              a PM bitmap that I create.  Dumb, but it works...
  20. //
  21. //              Since I plan to use this application only once, it's not fancy
  22. //              and your mileage could vary.
  23. //
  24.  
  25. #include <stdio.h>
  26. #include <memory.h>
  27.  
  28.  
  29. //
  30. //  This is the prefix of a B/W 32x32 PM 1.1 bitmap that I dumped.
  31. //
  32. unsigned char BmpHdr[] =
  33.   {
  34.   0x42, 0x4D, 0x1A, 0x00, 0x00, 0x00, 0x10, 0x00,
  35.   0x10, 0x00, 0x20, 0x00, 0x00, 0x00, 0x0C, 0x00,
  36.   0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x01, 0x00,
  37.   0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF
  38.   };
  39.  
  40.  
  41. //
  42. //  Define prototypes of routines.
  43. //
  44. void main(short argc, char **argv);
  45.  
  46.  
  47. //***************************************************************************
  48. //
  49. //  Routine: main(In, In)
  50. //
  51. //  Remarks: This is where it all begins.
  52. //
  53. //  Returns: None.
  54. //
  55. void main(short argc, char **argv)
  56.   {
  57.   FILE *pFile;
  58.   unsigned char WnBmp[256];
  59.   unsigned char PmBmp[256];
  60.   register i;
  61.  
  62.  
  63.   //
  64.   //  Load the header of a PM 32x32 B/W bitmap to our output buffer.
  65.   //
  66.   memcpy(PmBmp, BmpHdr, sizeof(BmpHdr));
  67.  
  68.   //
  69.   //  Loop through all the icky Windows bitmaps and make neat-o Pm bitmaps.
  70.   //
  71.   for (i = 1; i < argc; i++)
  72.     {
  73.     //
  74.     //  Read in the Windows bitmap into memory so we can play with it.
  75.     //
  76.     pFile = fopen(argv[1], "rb");
  77.     fread(WnBmp, sizeof(WnBmp), 1, pFile);
  78.     fclose(pFile);
  79.  
  80.     //
  81.     //  Retrieve just the raw bitmap data from the Windows bitmap and merge
  82.     //  with the header of the new PM bitmap.
  83.     //
  84.     memcpy(&PmBmp[sizeof(BmpHdr)], &WnBmp[62], 128);
  85.  
  86.     //
  87.     //  Write over the Windows bitmap to form a new PM bitmap (not very nice,
  88.     //  but this is only a one time tool...
  89.     //
  90.     pFile = fopen(argv[1], "wb");
  91.     fwrite(PmBmp, sizeof(BmpHdr) + 128, 1, pFile);
  92.     fclose(pFile);
  93.     }
  94.   }
  95.