Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. #include <tier0/platform.h>
  3. #include "bitmap/float_bm.h"
  4. #include "mathlib/mathlib.h"
  5. #include <tier2/tier2.h>
  6. void main(int argc,char **argv)
  7. {
  8. InitCommandLineProgram( argc, argv );
  9. if ((argc<2) || (argc>3))
  10. {
  11. printf("format is %s imagefile.pfm [scalefactor]\n",argv[0]);
  12. }
  13. else
  14. {
  15. FloatBitMap_t cmap;
  16. cmap.LoadFromPFM(argv[1]);
  17. if (argc==3) // scale factor specified
  18. {
  19. float scale_factor=atof(argv[2]);
  20. for(int y=0;y<cmap.Height;y++)
  21. for(int x=0;x<cmap.Width;x++)
  22. for(int c=0;c<3;c++)
  23. cmap.Pixel(x,y,c) *= scale_factor;
  24. }
  25. FloatBitMap_t save_orig(&cmap);
  26. cmap.CompressTo8Bits(8.0);
  27. char fname[1024];
  28. strcpy(fname,argv[1]);
  29. char *dot=strstr(fname,".pfm");
  30. if (! dot)
  31. dot=fname+strlen(fname);
  32. strcpy(dot,"_compressed.tga");
  33. cmap.WriteTGAFile(fname);
  34. #ifdef WRITE_OUT_COMPARISON_IMAGES
  35. // now, write out comparison images
  36. cmap.Uncompress(8.0);
  37. cmap.RaiseToPower(1.0/2.2);
  38. strcpy(dot,"_ref_comp.tga");
  39. cmap.WriteTGAFile(fname);
  40. save_orig.RaiseToPower(1.0/2.2);
  41. strcpy(dot,"_ref_orig.tga");
  42. save_orig.WriteTGAFile(fname);
  43. #endif
  44. }
  45. }