summaryrefslogtreecommitdiff
path: root/common/jpegloader.h
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 /common/jpegloader.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'common/jpegloader.h')
-rw-r--r--common/jpegloader.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/common/jpegloader.h b/common/jpegloader.h
new file mode 100644
index 0000000..ccb8a9b
--- /dev/null
+++ b/common/jpegloader.h
@@ -0,0 +1,56 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: jpeg functions
+//
+//=============================================================================
+
+#ifndef JPEGLOADER_H
+#define JPEGLOADER_H
+
+#include "tier0/platform.h"
+#include "tier1/utlbuffer.h"
+#include "Color.h"
+
+
+// Get dimensions out of jpeg header
+bool GetJpegDimensions( const byte *pubData, int cubData, uint32 &width, uint32 &height );
+
+// Convert Jpeg data to raw RGBA, pubData is the jpeg data, cubData is it's size, buf is for output, and width/height are output as well.
+// pcubUsed is an optional output param for how many bytes of data were used in the image
+bool ConvertJpegToRGBA( const byte *pubJpegData, int cubJpegData, CUtlBuffer &bufOutput, int &width, int &height, int *pcubUsed = NULL );
+
+// Convert Jpeg data to raw RGB, pubData is the jpeg data, cubData is it's size, buf is for output, and width/height are output as well.
+// pcubUsed is an optional output param for how many bytes of data were used in the image
+bool ConvertJpegToRGB( const byte *pubJpegData, int cubJpegData, CUtlBuffer &bufOutput, int &width, int &height, int *pcubUsed = NULL );
+
+// Write a Jpeg to disk, quality is 0-100
+bool ConvertRGBToJpeg( const char *pchFileOut, int quality, int width, int height, CUtlBuffer &bufRGB );
+
+// Write a Jpeg to a buffer, quality is 0-100
+bool ConvertRGBToJpeg( CUtlBuffer &bufOutput, int quality, int width, int height, CUtlBuffer &bufRGB );
+
+// Resize an RGB image using linear interpolation
+bool BResizeImageRGB( CUtlBuffer &bufRGB, int nWidth, int nHeight, int &nNewWidth, int &nNewHeight );
+
+// Resize an RGBA image using linear interpolation
+bool BResizeImageRGBA( CUtlBuffer &bufRGBA, int nWidth, int nHeight, int &nNewWidth, int &nNewHeight );
+
+// Convert an RGB image to RGBA with 100% opacity
+bool BConvertRGBToRGBA( CUtlBuffer &bufRGB, int nWidth, int nHeight );
+
+// Convert an RGBA image to RGB using opacity against a given solid background
+bool BConvertRGBAToRGB( CUtlBuffer &bufRGB, int nWidth, int nHeight, Color colorBG = Color(255,255,255) );
+
+#ifdef _PS3
+// PS3 PSN Avatars are PNG, so we have to support some similar functions on them. Should move
+// this to it's own pngloader.h someday when we really support PNG on all platforms.
+
+// Get dimensions out of PNG header
+bool GetPNGDimensions( const byte *pubData, int cubData, uint32 &width, uint32 &height );
+
+// Convert PNG data to raw RGBA, pubData is the PNG data, cubData is it's size, buf is for output, and width/height are output as well.
+bool ConvertPNGToRGBA( const byte *pubJpegData, int cubJpegData, CUtlBuffer &bufOutput, int &width, int &height );
+
+#endif // _PS3
+
+#endif // JPEGLOADER_H \ No newline at end of file