EncodeDecodeHelper.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include "Common.h"
  3. enum ImreadModes
  4. {
  5. Unchanged = -1,
  6. Grayscale = 0,
  7. Color = 1,
  8. AnyDepth = 2,
  9. AnyColor = 4,
  10. LoadGdal = 8,
  11. };
  12. enum ImwriteFlags
  13. {
  14. JpegQuality,
  15. JpegProgressive,
  16. JpegOptimize,
  17. JpegRstInterval,
  18. JpegLumaQuality,
  19. JpegChromaQuality,
  20. PngCompression,
  21. PngStrategy,
  22. PngBilevel,
  23. };
  24. typedef struct
  25. {
  26. ImwriteFlags flagName;
  27. int flagValue;
  28. }ImwriteParam;
  29. enum ImwriteExtension
  30. {
  31. Png,
  32. Jpg,
  33. Bmp,
  34. };
  35. class EncodeDecodeHelper
  36. {
  37. public:
  38. EncodeDecodeHelper();
  39. ~EncodeDecodeHelper();
  40. bool Encode(ImageInfo srcImgInfo,ImwriteExtension extension,
  41. ImwriteParam* imwriteParams, int paramCount,uint8_t* dstImgData, int& dstDataSize);
  42. bool Decode(const uint8_t* srcImgData, const int srcDataSize,
  43. uint8_t* dstImgData, const int dstDataSize, ImreadModes readMode);
  44. bool SaveImage(ImageInfo srcImgInfo, ImwriteExtension extension,
  45. ImwriteParam* imwriteParams, int paramCount, const char* savePath);
  46. private:
  47. cv::Mat _imgDecode;
  48. cv::Mat _imgEncode;
  49. std::vector<uchar> _dataEncode;
  50. std::vector<uchar> _dataDecode;
  51. };