XCOLOR.C 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: h:/miner/source/xcolor/RCS/xcolor.c $
  15. * $Revision: 1.1 $
  16. * $Author: john $
  17. * $Date: 1994/01/24 11:09:24 $
  18. *
  19. * .
  20. *
  21. * $Log: xcolor.c $
  22. * Revision 1.1 1994/01/24 11:09:24 john
  23. * Initial revision
  24. *
  25. *
  26. */
  27. #pragma off (unreferenced)
  28. static char rcsid[] = "$Id: xcolor.c 1.1 1994/01/24 11:09:24 john Exp $";
  29. #pragma on (unreferenced)
  30. #include <dos.h>
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include "types.h"
  34. #include "gr.h"
  35. #include "iff.h"
  36. #include "mem.h"
  37. ubyte palette[768];
  38. void dofile( char * filename )
  39. {
  40. ubyte tc1, tc2;
  41. int i;
  42. grs_bitmap * bitmap;
  43. //MALLOC( bitmap, grs_bitmap, 1 );//Hack by KRB
  44. bitmap = (grs_bitmap *)malloc(1*sizeof(grs_bitmap));
  45. printf( "Reading %s...", filename );
  46. iff_read_bitmap( filename, bitmap, BM_LINEAR, palette );
  47. printf( "\n" );
  48. if ( iff_has_transparency ) {
  49. tc1 = bitmap->bm_data[0];
  50. tc2 = iff_transparent_color;
  51. printf( "Mapping all color %d's to transparent color %d...", tc1, tc2 );
  52. for (i=0; i < bitmap->bm_h * bitmap->bm_w; i++ ) {
  53. if ( bitmap->bm_data[i]==tc1 )
  54. bitmap->bm_data[i] = tc2;
  55. }
  56. } else {
  57. tc1 = bitmap->bm_data[0];
  58. iff_has_transparency = 1;
  59. iff_transparent_color = tc1;
  60. tc2 = iff_transparent_color;
  61. printf( "Making color %d the new transparency color...", tc1 );
  62. }
  63. printf( "\n" );
  64. printf( "Writing %s...", filename );
  65. iff_write_bitmap(filename,bitmap, palette );
  66. printf( "\n" );
  67. gr_free_bitmap(bitmap);
  68. }
  69. void main(int argc, char * argv[]) {
  70. int numfiles = 0;
  71. struct find_t find;
  72. char * cp;
  73. char * cp1;
  74. argv++; argc--;
  75. for (;argc--;argv++)
  76. {
  77. if( !_dos_findfirst( *argv, 0xffff, &find ) )
  78. {
  79. dofile( find.name );
  80. numfiles++;
  81. while( !_dos_findnext( &find ) ) {
  82. numfiles++;
  83. dofile( find.name );
  84. }
  85. }
  86. }
  87. if ( numfiles < 1 ) {
  88. printf( "xcolor- this program corrects a .bbm file's transparency\n");
  89. printf( "by making all pixels that are the same as the upper-left\n");
  90. printf( "pixel be transparent. The command line is the file specs\n" );
  91. printf( "to convert. ie.. xcolor john*.bbm adam*.bbm\n\n" );
  92. exit(1);
  93. }
  94. }
  95.