summaryrefslogtreecommitdiff
path: root/utils/pfmcomp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/pfmcomp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/pfmcomp')
-rw-r--r--utils/pfmcomp/pfmcomp.cpp53
-rw-r--r--utils/pfmcomp/pfmcomp.vpc46
2 files changed, 99 insertions, 0 deletions
diff --git a/utils/pfmcomp/pfmcomp.cpp b/utils/pfmcomp/pfmcomp.cpp
new file mode 100644
index 0000000..d75f31a
--- /dev/null
+++ b/utils/pfmcomp/pfmcomp.cpp
@@ -0,0 +1,53 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+#include <tier0/platform.h>
+#include "bitmap/float_bm.h"
+#include "mathlib/mathlib.h"
+#include <tier2/tier2.h>
+
+
+
+
+
+void main(int argc,char **argv)
+{
+ InitCommandLineProgram( argc, argv );
+ if ((argc<2) || (argc>3))
+ {
+ printf("format is %s imagefile.pfm [scalefactor]\n",argv[0]);
+ }
+ else
+ {
+ FloatBitMap_t cmap;
+ cmap.LoadFromPFM(argv[1]);
+ if (argc==3) // scale factor specified
+ {
+ float scale_factor=atof(argv[2]);
+ for(int y=0;y<cmap.Height;y++)
+ for(int x=0;x<cmap.Width;x++)
+ for(int c=0;c<3;c++)
+ cmap.Pixel(x,y,c) *= scale_factor;
+ }
+ FloatBitMap_t save_orig(&cmap);
+ cmap.CompressTo8Bits(8.0);
+ char fname[1024];
+ strcpy(fname,argv[1]);
+ char *dot=strstr(fname,".pfm");
+ if (! dot)
+ dot=fname+strlen(fname);
+ strcpy(dot,"_compressed.tga");
+ cmap.WriteTGAFile(fname);
+
+#ifdef WRITE_OUT_COMPARISON_IMAGES
+ // now, write out comparison images
+ cmap.Uncompress(8.0);
+ cmap.RaiseToPower(1.0/2.2);
+ strcpy(dot,"_ref_comp.tga");
+ cmap.WriteTGAFile(fname);
+ save_orig.RaiseToPower(1.0/2.2);
+ strcpy(dot,"_ref_orig.tga");
+ save_orig.WriteTGAFile(fname);
+#endif
+
+ }
+}
+
diff --git a/utils/pfmcomp/pfmcomp.vpc b/utils/pfmcomp/pfmcomp.vpc
new file mode 100644
index 0000000..d4c137a
--- /dev/null
+++ b/utils/pfmcomp/pfmcomp.vpc
@@ -0,0 +1,46 @@
+//-----------------------------------------------------------------------------
+// PFMCOMP.VPC
+//
+// Project Script
+//-----------------------------------------------------------------------------
+
+$Macro SRCDIR "..\.."
+$Macro OUTBINDIR "$SRCDIR\..\game\bin"
+
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $AdditionalIncludeDirectories "$BASE,..\common"
+ }
+}
+
+$Project "Pfmcomp"
+{
+ $Folder "Source Files"
+ {
+ $File "$SRCDIR\public\chunkfile.cpp"
+ $File "..\common\scriplib.cpp"
+ $File "$SRCDIR\public\collisionutils.cpp"
+ $File "$SRCDIR\public\filesystem_helpers.cpp"
+ $File "$SRCDIR\public\filesystem_init.cpp"
+ $File "$SRCDIR\public\ScratchPadUtils.cpp"
+ $File "..\common\cmdlib.cpp"
+ $File "..\common\filesystem_tools.cpp"
+ $File "pfmcomp.cpp"
+ }
+
+ $Folder "Header Files"
+ {
+ $File "$SRCDIR\public\tier1\utlsymbol.h"
+ }
+
+ $Folder "Link Libraries"
+ {
+ $Lib bitmap
+ $Lib mathlib
+ $Lib tier2
+ }
+}