00001
00002 #ifndef _DC_TOOLS_H_
00003 #define _DC_TOOLS_H_
00004
00006 enum RgbLutCs
00007 {
00008 RgbLutSRGB,
00009 RgbLutLinear
00010 };
00011
00013
00014 template <typename T, int Len = 256>
00015 class RgbLut
00016 {
00017 public:
00018 T Lut[Len];
00019
00021 RgbLut(RgbLutCs To, RgbLutCs From)
00022 {
00023 T Mul;
00024 memset(&Mul, 0xff, sizeof(Mul));
00025 double Div = Len - 1;
00026
00027 double in, out;
00028 if (From == RgbLutLinear && To == RgbLutSRGB)
00029 {
00030 for (int i=0; i<Len; i++)
00031 {
00032 in = (double)i / Div;
00033 if (in <= 0.0031308)
00034 out = in * 12.92;
00035 else
00036 out = pow(in, 1.0 / 2.4) * 1.055 - 0.055;
00037
00038 Lut[i] = out * Mul + 0.0000001;
00039 }
00040 }
00041 else if (From == RgbLutSRGB && To == RgbLutLinear)
00042 {
00043 for (int i=0; i<Len; i++)
00044 {
00045 in = (double)i / Div;
00046 if (in <= 0.04045)
00047 out = in / 12.92;
00048 else
00049 out = pow((in + 0.055) / 1.055, 2.4);
00050
00051 Lut[i] = out * Mul;
00052 }
00053 }
00054 }
00055 };
00056
00057
00058 extern bool RemapDC(GSurface *pDC, GPalette *DestPal);
00059
00060
00061 #define FLIP_X 1
00062 #define FLIP_Y 2
00063
00064 extern bool FlipDC(GSurface *pDC, int Dir);
00065
00066
00067 extern bool IsGreyScale(GSurface *pDC);
00068
00069
00070 extern bool GreyScaleDC(GSurface *pDest, GSurface *pSrc);
00071
00072
00073 extern bool InvertDC(GSurface *pDC);
00074
00075
00076 extern bool RotateDC(GSurface *pDC, double Angle);
00077
00078
00079 extern bool FlipXDC(GSurface *pDC);
00080 extern bool FlipYDC(GSurface *pDC);
00081
00082
00083 extern bool ResampleDC(GSurface *pTo, GSurface *pFrom, GRect *FromRgn = 0, Progress *Prog = 0);
00084
00085 #endif