logplus/qtpropertybrowser/Gradient.h
DESKTOP-450PEFP\mainc 5ece38108e 左侧数据树 色板属性添加颜色,可以配置不同的色板列表
图像道属性实现,最大值,最小值,色板等属性
波列道实现逻辑,x 与 y 轴不对调
2026-05-10 22:21:26 +08:00

115 lines
3.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Gradient.h : header file
#ifndef Gradient_H
#define Gradient_H
#include <QGraphicsWidget>
//typedef struct myRGBTRIPLE {
// BYTE rgbtBlue;
// BYTE rgbtGreen;
// BYTE rgbtRed;
//} RGBTRIPLE;
typedef unsigned long DWORD;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef DWORD COLORREF;
typedef DWORD *LPCOLORREF;
#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
//#define LOBYTE(w) ((BYTE)(((DWORD_PTR)(w)) & 0xff))
//#define GetRValue(rgb) (LOBYTE(rgb))
//#define GetGValue(rgb) (LOBYTE(((WORD)(rgb)) >> 8))
//#define GetBValue(rgb) (LOBYTE((rgb)>>16))
typedef COLORREF (__cdecl* InterpolateFn)(COLORREF first, COLORREF second, float position, float start, float end);
typedef struct CPeg {
COLORREF colour;
float position;
} ;
enum DataType{LINEAR, LOG};
enum InterpolationMethod
{
Linear,
FlatStart,
FlatMid,
FlatEnd,
Cosine,
HSLRedBlue,
HSLBlueRed,
HSLShortest,
HSLLongest,
Reverse
};
//不滤波;3×3平均;3×3十字;N×N平均;Sobel边缘增强;Robert边缘增强;中值滤波;Laplacian边缘增强;USM;自适应滤波;保守滤波;
enum FilterMethod
{
NONEMETHOD, //不滤波
MEANDEFAULT, //3×3平均
CROSS,
MEANCUSTOM,
SOBEL,
ROBERT,
Median,
Laplacian,
USM,
Adaptive,
Conservative
};
#define BACKGROUND -4
#define STARTPEG -3
#define ENDPEG -2
#define NONE -1
class CGradient
{
// Construction
public:
CGradient();
~CGradient();
// Attributes
public:
QVector <CPeg> pegs;
bool m_UseBackground;
CPeg m_StartPeg, m_EndPeg, m_Background;//ace
int m_Quantization;
InterpolationMethod m_InterpolationMethod;
QString m_FileFlag;
public:
//void MakeEntries(RGBTRIPLE *lpPal, int iEntryCount);
int GetColorArray(COLORREF colorArr[]);
InterpolateFn GetInterpolationProc();
int IndexFromPos2(float pos);
int IndexFromPos(float pos);
void Serialize(QString strCfg);//CArchive &ar);
COLORREF GetBackgroundColour() const {return m_Background.colour;};
//----- Interpolation routines -----//
static COLORREF InterpolateLinear(COLORREF first, COLORREF second,
float position, float start, float end);
static COLORREF InterpolateFlatStart(COLORREF first, COLORREF second,
float position, float start, float end);
static COLORREF InterpolateFlatMid(COLORREF first, COLORREF second,
float position, float start, float end);
static COLORREF InterpolateFlatEnd(COLORREF first, COLORREF second,
float position, float start, float end);
static COLORREF InterpolateCosine(COLORREF first, COLORREF second,
float position, float start, float end);
static COLORREF InterpolateHSLClockwise(COLORREF first, COLORREF second,
float position, float start, float end);
static COLORREF InterpolateHSLAntiClockwise(COLORREF first, COLORREF second,
float position, float start, float end);
static COLORREF InterpolateHSLLongest(COLORREF first, COLORREF second,
float position, float start, float end);
static COLORREF InterpolateHSLShortest(COLORREF first, COLORREF second,
float position, float start, float end);
static COLORREF InterpolateReverse(COLORREF first, COLORREF second,
float position, float start, float end);
};
#endif