67 #ifndef _graphicsproceduralconvolutionmodifier_cpp
68 #define _graphicsproceduralconvolutionmodifier_cpp
70 #include "Graphics/Procedural/Texture/convolutionmodifier.h"
85 CalculateEdgeDivisor(true),
86 IncludeAlphaChannel(false)
97 this->
KernelData[ this->KernelSize * Mid + Mid ] = 1.0;
117 for(
Whole Y = 0 ; Y < TargetHeight ; ++Y )
119 for(
Whole X = 0 ; X < TargetWidth ; ++X )
126 Integer ProcessedKernelSize = 0;
135 if( YPos >= static_cast<Integer>( TargetHeight ) )
145 if( XPos < static_cast<Integer>( TargetWidth ) ) {
148 Div +=
static_cast<Integer>( KernelVal );
155 ProcessedKernelSize++;
160 if( ProcessedKernelSize == ( this->KernelSize * this->KernelSize ) ) {
185 static_cast<UInt8>( (Red > 255) ? 255 : ( (Red < 0) ? 0 : Red ) ),
186 static_cast<UInt8>( (Green > 255) ? 255 : ( (Green < 0) ? 0 : Green ) ),
187 static_cast<UInt8>( (Blue > 255) ? 255 : ( (Blue < 0) ? 0 : Blue ) ),
188 static_cast<UInt8>( (Alpha > 255) ? 255 : ( (Alpha < 0) ? 0 : Alpha ) ) );
196 {
return "ConvolutionModifier"; }
203 if( Size < 3 || Size % 2 == 0 ) {
213 this->
KernelData[ Y * this->KernelSize + X ] = Data[ Y * this->KernelSize + X ];
222 if( Size < 3 || Size % 2 == 0 ) {
232 this->
KernelData[ Y * this->KernelSize + X ] =
static_cast<Real>( Data[ Y * this->KernelSize + X ] );
248 this->
KernelData[ Y * this->KernelSize + X ] = Data[Y][X];
256 { this->
Divisor = Div;
return *
this; }
259 { this->
Threshold = Thresh;
return *
this; }
ColourChannelType & GetPixel(const Whole X, const Whole Y, const UInt16 Component)
Gets access to the pixel at the specified position in this buffer. the X or Y location go beyond the ...
This is a 3x3 Matrix class used for representing rotations and scaling in an object.
bool Boole
Generally acts a single bit, true or false.
void SetPixelByte(const Whole X, const Whole Y, const ColourChannelType Red, const ColourChannelType Green, const ColourChannelType Blue, const ColourChannelType Alpha=255)
Set colour of a specified pixel using a 0-255 range. the X or Y location go beyond the set size of th...
Whole GetWidth() const
Get the pixel width of this texture.
int Integer
A datatype used to represent any integer close to.
ConvolutionModifier & SetThreshold(const UInt8 Thresh)
Sets a threshold that will force the colours of each pixel further to white or black.
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.
ConvolutionModifier & SetCalculateEdgeDivisor(const Boole CalculateEdge)
Sets if a custom divisor should be use or one automatically generated during pixel processing...
Boole IncludeAlphaChannel
Whether or not the Alpha channel is to be processed with the rest of the pixel.
Real GreenChannel
Value from 0.0 to 1.0 representing the amount of green present in the colour. 1.0 if very green...
Real Divisor
The custom value to divide the pixel result by.
virtual ~ConvolutionModifier()
Class destructor.
Real AlphaChannel
Value from 0.0 to 1.0 representing the transparency of the colours. 1.0 is opaque and 0...
virtual void Modify(TextureBuffer &Buffer)
Alters the generated pixels in a TextureBuffer.
Boole CalculateEdgeDivisor
Whether or not a dynamic divisor from pixel processing is to be used or the explicitly set divisor...
ConvolutionModifier & SetIncludeAlphaChannel(const Boole IncludeAlpha)
Sets if the alpha channel of each pixel should be processed.
ConvolutionModifier & SetDivisor(const Real Div)
Sets a custom divisor that will be applied to the result of the pixel to help keep the value within a...
Real * KernelData
The matricy to use for per-pixel processing.
A convenience buffer that stores pixel colour values of a texture to be generated.
ConvolutionModifier & CalculateDivisor()
Automatically generates a sane divisor for pixel processing.
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.
A modifier that will calculate each pixel in an image to be a weighed sum of itself and it's neighbor...
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...
virtual String GetName() const
Gets the name of this modifier.
UInt8 KernelSize
The size of the set kernel.
Real RedChannel
Value from 0.0 to 1.0 representing the amount of red present in the colour. 1.0 if very red...
ConvolutionModifier & SetKernel(const UInt8 Size, Real *Data)
Sets the matrix that determines how each pixel neighbor is to be weighed when processing each pixel...
UInt8 Threshold
A value over 128 will force a colour closer to White, lower will force a colour closer to black...
std::string String
A datatype used to a series of characters.
void SetData(const TextureBuffer &Other)
Copies image data from another buffer into this buffer.
ConvolutionModifier()
Blank constructor.