67 #ifndef _graphicsproceduralcoloursmodifier_cpp
68 #define _graphicsproceduralcoloursmodifier_cpp
70 #include "Graphics/Procedural/Texture/coloursmodifier.h"
72 #include "MathTools/mathtools.h"
81 ColourBase(0.0,0.0,0.0,1.0),
82 ColourPercent(1.0,1.0,1.0,1.0),
83 ColourBrightness(127),
85 ColourSaturation(127),
102 fConstrast = fConstrast * fConstrast * fConstrast;
103 Contrast =
static_cast<Integer>( fConstrast * 256.0 );
106 Real AlphaMult =
static_cast<Real>( MaxAlpha - MinAlpha ) / 255.0;
108 for(
Whole Y = 0 ; Y < Height ; ++Y )
110 for(
Whole X = 0 ; X < Width ; ++X )
116 Integer Colour =
static_cast<Integer>( ( ( Red - 127 ) * Contrast ) >> 8 ) + 127;
117 Red = (Colour < 0x00) ? 0x00 : (Colour > 0xff) ? 0xff : Colour;
119 Colour =
static_cast<Integer>( ( ( Green - 127 ) * Contrast ) >> 8 ) + 127;
120 Green = (Colour < 0x00) ? 0x00 : (Colour > 0xff) ? 0xff : Colour;
122 Colour =
static_cast<Integer>( ( ( Blue - 127 ) * Contrast ) >> 8 ) + 127;
123 Blue = (Colour < 0x00) ? 0x00 : (Colour > 0xff) ? 0xff : Colour;
126 Integer Intensity = Red + Green + Blue;
129 Red = ( U + Intensity ) / 3;
130 Green = ( Intensity - ( U + V ) ) / 3;
131 Blue = ( V + Intensity ) / 3;
137 Buffer.
SetAlphaByte(X,Y,static_cast<UInt8>( MathTools::Clamp( ( static_cast<Real>( Buffer.
GetAlphaByte(X,Y) ) * AlphaMult ) +
static_cast<Real>( MinAlpha ),
Real(0),
Real(255)) ));
143 {
return "ColoursModifier"; }
ColourValue ColourBase
The base colour to add to the result of the original colour from the image being modified determined ...
ColoursModifier()
Blank constructor.
void SetRedByte(const Whole X, const Whole Y, const ColourChannelType Red)
Sets the red colour value of a specified pixel. the X or Y location go beyond the set size of this te...
Whole GetWidth() const
Get the pixel width of this texture.
UInt8 ColourContrast
The modifier that will adjust the intensity of pixels closer or further to neutral.
ColourChannelType GetBlueByte(const Whole X, const Whole Y) const
Gets the blue colour value of a specified pixel. the X or Y location go beyond the set size of this t...
ColoursModifier & SetColourPercent(const ColourValue &Colour)
Sets the amount of colour from each channel to use in the result texture.
int Integer
A datatype used to represent any integer close to.
virtual String GetName() const
Gets the name of this modifier.
ColoursModifier & SetSaturation(const UInt8 Saturation)
Sets the saturation modifier.
uint8_t UInt8
An 8-bit unsigned integer.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
ColourChannelType GetAlphaByte(const Whole X, const Whole Y) const
Gets the alpha colour value of a specified pixel. the X or Y location go beyond the set size of this ...
float Real
A Datatype used to represent a real floating point number.
void SetGreenByte(const Whole X, const Whole Y, const ColourChannelType Green)
Sets the green colour value of a specified pixel. the X or Y location go beyond the set size of this ...
Real GreenChannel
Value from 0.0 to 1.0 representing the amount of green present in the colour. 1.0 if very green...
ColoursModifier & SetBrightness(const UInt8 Brightness)
Sets the brightness modifier.
ColoursModifier & SetAlpha(const UInt8 Alpha)
Sets the alpha modifier.
ColoursModifier & SetColourBase(const ColourValue &Colour)
Sets the base colour to add to the result texture.
void SetValues(const Real Red, const Real Green, const Real Blue, const Real Alpha)
Sets each of the colour channels.
ColourValue ColourPercent
The amount of colour from each channel in the texture to be modified to keep for the result...
A modifier that will alter the basic colour properties of the texture.
A convenience buffer that stores pixel colour values of a texture to be generated.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Whole GetHeight() const
Get the pixel height of this texture.
Real BlueChannel
Value from 0.0 to 1.0 representing the amount of blue present in the colour. 1.0 if very blue...
UInt8 ColourAlpha
The modifier that will adjust the alpha channel for each pixel.
UInt8 ColourSaturation
The modifier that will adjust the strongest colour channel of a pixel to be more or less extreme in e...
Real RedChannel
Value from 0.0 to 1.0 representing the amount of red present in the colour. 1.0 if very red...
ColourChannelType GetGreenByte(const Whole X, const Whole Y) const
Gets the green colour value of a specified pixel. the X or Y location go beyond the set size of this ...
virtual ~ColoursModifier()
Class destructor.
UInt8 ColourBrightness
The modifier that will adjust the intensity for each pixel.
virtual void Modify(TextureBuffer &Buffer)
Alters the generated pixels in a TextureBuffer.
void SetAlphaByte(const Whole X, const Whole Y, const ColourChannelType Alpha)
Sets the alpha colour value of a specified pixel. the X or Y location go beyond the set size of this ...
void SetBlueByte(const Whole X, const Whole Y, const ColourChannelType Blue)
Sets the blue colour value of a specified pixel. the X or Y location go beyond the set size of this t...
std::string String
A datatype used to a series of characters.
ColoursModifier & SetContrast(const UInt8 Contrast)
Sets the contrast modifier.
ColourChannelType GetRedByte(const Whole X, const Whole Y) const
Gets the red colour value of a specified pixel. the X or Y location go beyond the set size of this te...