raze-gles/source/common/utility/palutil.h

76 lines
2.6 KiB
C
Raw Normal View History

2020-04-11 21:50:43 +00:00
#pragma once
#include <stdint.h>
#include "zstring.h"
2020-04-11 21:50:43 +00:00
#include "palentry.h"
2020-04-11 22:04:02 +00:00
struct FScriptPosition;
class FScanner;
int BestColor(const uint32_t* pal, int r, int g, int b, int first = 1, int num = 255, const uint8_t* indexmap = nullptr);
2020-04-11 21:50:43 +00:00
int PTM_BestColor(const uint32_t* pal_in, int r, int g, int b, bool reverselookup, float powtable, int first = 1, int num = 255);
void DoBlending(const PalEntry* from, PalEntry* to, int count, int r, int g, int b, int a);
2020-04-11 22:04:02 +00:00
// Given an array of colors, fills in remap with values to remap the
// passed array of colors to BaseColors. Used for loading palette downconversions of PNGs.
void MakeRemap(uint32_t* BaseColors, const uint32_t* colors, uint8_t* remap, const uint8_t* useful, int numcolors);
void MakeGoodRemap(uint32_t* BaseColors, uint8_t* Remap);
2020-04-11 21:50:43 +00:00
// Colorspace conversion RGB <-> HSV
void RGBtoHSV (float r, float g, float b, float *h, float *s, float *v);
void HSVtoRGB (float *r, float *g, float *b, float h, float s, float v);
2020-04-11 22:04:02 +00:00
// Returns the closest color to the one desired. String
// should be of the form "rr gg bb".
int V_GetColorFromString(const char* colorstring, FScriptPosition* sc = nullptr);
2020-04-11 22:04:02 +00:00
// Scans through the X11R6RGB lump for a matching color
// and returns a color string suitable for V_GetColorFromString.
FString V_GetColorStringByName(const char* name, FScriptPosition* sc = nullptr);
// Tries to get color by name, then by string
int V_GetColor(const char* str, FScriptPosition* sc = nullptr);
int V_GetColor(FScanner& sc);
2020-04-19 19:46:37 +00:00
PalEntry averageColor(const uint32_t* data, int size, int maxout);
enum
{
NOFIXEDCOLORMAP = -1,
INVERSECOLORMAP, // the inverse map is used explicitly in a few places.
GOLDCOLORMAP,
REDCOLORMAP,
GREENCOLORMAP,
BLUECOLORMAP,
REALINVERSECOLORMAP,
};
struct FSpecialColormapParameters
{
float Start[3], End[3];
};
struct FSpecialColormap
{
float ColorizeStart[3];
float ColorizeEnd[3];
uint8_t Colormap[256];
PalEntry GrayscaleToColor[256];
};
2021-03-07 12:21:15 +00:00
extern TArray<FSpecialColormap> SpecialColormaps;
extern uint8_t DesaturateColormap[31][256];
int AddSpecialColormap(PalEntry *pe, float r1, float g1, float b1, float r2, float g2, float b2);
void InitSpecialColormaps(PalEntry* pe);
void UpdateSpecialColormap(PalEntry* BaseColors, unsigned int index, float r1, float g1, float b1, float r2, float g2, float b2);
int ReadPalette(int lumpnum, uint8_t* buffer);
2021-03-06 22:06:26 +00:00
enum EColorManipulation
{
CM_PLAIN2D = -2, // regular 2D drawing.
CM_INVALID = -1,
CM_DEFAULT = 0, // untranslated
CM_FIRSTSPECIALCOLORMAP, // first special fixed colormap
};
#define CM_MAXCOLORMAP int(CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size())