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.

55 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: jpeg functions
  4. //
  5. //=============================================================================
  6. #ifndef JPEGLOADER_H
  7. #define JPEGLOADER_H
  8. #include "tier0/platform.h"
  9. #include "tier1/utlbuffer.h"
  10. #include "Color.h"
  11. // Get dimensions out of jpeg header
  12. bool GetJpegDimensions( const byte *pubData, int cubData, uint32 &width, uint32 &height );
  13. // 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.
  14. // pcubUsed is an optional output param for how many bytes of data were used in the image
  15. bool ConvertJpegToRGBA( const byte *pubJpegData, int cubJpegData, CUtlBuffer &bufOutput, int &width, int &height, int *pcubUsed = NULL );
  16. // 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.
  17. // pcubUsed is an optional output param for how many bytes of data were used in the image
  18. bool ConvertJpegToRGB( const byte *pubJpegData, int cubJpegData, CUtlBuffer &bufOutput, int &width, int &height, int *pcubUsed = NULL );
  19. // Write a Jpeg to disk, quality is 0-100
  20. bool ConvertRGBToJpeg( const char *pchFileOut, int quality, int width, int height, CUtlBuffer &bufRGB );
  21. // Write a Jpeg to a buffer, quality is 0-100
  22. bool ConvertRGBToJpeg( CUtlBuffer &bufOutput, int quality, int width, int height, CUtlBuffer &bufRGB );
  23. // Resize an RGB image using linear interpolation
  24. bool BResizeImageRGB( CUtlBuffer &bufRGB, int nWidth, int nHeight, int &nNewWidth, int &nNewHeight );
  25. // Resize an RGBA image using linear interpolation
  26. bool BResizeImageRGBA( CUtlBuffer &bufRGBA, int nWidth, int nHeight, int &nNewWidth, int &nNewHeight );
  27. // Convert an RGB image to RGBA with 100% opacity
  28. bool BConvertRGBToRGBA( CUtlBuffer &bufRGB, int nWidth, int nHeight );
  29. // Convert an RGBA image to RGB using opacity against a given solid background
  30. bool BConvertRGBAToRGB( CUtlBuffer &bufRGB, int nWidth, int nHeight, Color colorBG = Color(255,255,255) );
  31. #ifdef _PS3
  32. // PS3 PSN Avatars are PNG, so we have to support some similar functions on them. Should move
  33. // this to it's own pngloader.h someday when we really support PNG on all platforms.
  34. // Get dimensions out of PNG header
  35. bool GetPNGDimensions( const byte *pubData, int cubData, uint32 &width, uint32 &height );
  36. // 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.
  37. bool ConvertPNGToRGBA( const byte *pubJpegData, int cubJpegData, CUtlBuffer &bufOutput, int &width, int &height );
  38. #endif // _PS3
  39. #endif // JPEGLOADER_H