112 lines
3.3 KiB
C
112 lines
3.3 KiB
C
|
|
// Gradient.h : header file
|
|||
|
|
#ifndef Gradient_H
|
|||
|
|
#define Gradient_H
|
|||
|
|
|
|||
|
|
#include <QGraphicsWidget>
|
|||
|
|
#include "CStringType.h"
|
|||
|
|
|
|||
|
|
//typedef struct myRGBTRIPLE {
|
|||
|
|
// BYTE rgbtBlue;
|
|||
|
|
// BYTE rgbtGreen;
|
|||
|
|
// BYTE rgbtRed;
|
|||
|
|
//} RGBTRIPLE;
|
|||
|
|
|
|||
|
|
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);
|
|||
|
|
void 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
|