ImageUtils.h 694 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef IMAGEUTILS_H
  2. #define IMAGEUTILS_H
  3. #include <QPixmap>
  4. class GaussianBlur
  5. {
  6. public:
  7. GaussianBlur(int blurRadius, float sigma);
  8. QImage BlurImage(const QImage &in);
  9. float GaussFunc(float x);
  10. int getBlurRadius() const;
  11. void setBlurRadius(int value);
  12. float getSigma() const;
  13. void setSigma(float value);
  14. ~GaussianBlur();
  15. private:
  16. QVector<float> m_convolutionMatrix;
  17. int ReflectIndex(int x, int length);
  18. void CreateConvolutionMatrix();
  19. int m_blurRadius;
  20. float m_sigma;
  21. };
  22. class DominantColor
  23. {
  24. public:
  25. /// 获取主色
  26. static QColor getDominantColor(const QString &imagePath, int step = 20);
  27. };
  28. #endif // IMAGEUTILS_H