STE-Industries: utilities testing
|
#include "Bitmap.h"
Classes | |
struct | CorrectionDescriptorType |
struct | CorrectionParameters |
struct | PixelInformationType |
struct | RepulsionType |
Public Types | |
enum | ChoiceType { ChoiceType::RANDOM, ChoiceType::MAXIMUM } |
typedef uint_fast32_t | IndexType |
Public Member Functions | |
Bitmap (Bitmap &&thisBitmap) noexcept | |
Bitmap (const Bitmap &thisBitmap) noexcept | |
Bitmap (void) noexcept | |
~Bitmap (void) noexcept | |
uint_fast32_t | ComputeLineSize (void) const noexcept |
Bitmap | Correct (register const CorrectionParameters &Parameters) noexcept(false) |
unsigned int | GetBitsPerPixel (void) const noexcept |
uint_fast32_t | GetHeight (void) const noexcept |
uint_fast32_t | GetHorizontalResolution (void) const noexcept |
uint_fast32_t | GetSize (void) const noexcept |
uint_fast32_t | GetVerticalResolution (void) const noexcept |
uint_fast32_t | GetWidth (void) const noexcept |
Bitmap & | operator= (Bitmap &&thisBitmap) noexcept |
Bitmap & | operator= (const Bitmap &thisBitmap) noexcept |
void | Randomize (uint_fast32_t Seed[RandomGenerator::NUMBER_OF_GENERATORS+1]) noexcept |
void | ReadFile (const char *Path) noexcept(false) |
void | WriteFile (const char *Path) noexcept(false) |
Static Public Member Functions | |
static void * | CorrectFunction (void *Argument) noexcept(false) |
Static Public Attributes | |
static constexpr unsigned int | DIB_HEADER_SIZE = 40 |
static constexpr unsigned int | HEADER_NAME_LENGTH = 2 |
static constexpr unsigned int | HEADER_SIZE = 14 |
static constexpr unsigned int | LONG_DATA_SIZE = 4 |
static constexpr unsigned int | MAXIMUM_BITMAP_SIZE |
static constexpr unsigned int | MAXIMUM_HEIGHT = 10000 |
static constexpr unsigned int | MAXIMUM_NUMBER_OF_STEPS = 1000 |
static constexpr unsigned int | MAXIMUM_NUMBER_OF_TERMITES |
static constexpr unsigned int | MAXIMUM_NUMBER_OF_THREADS = 100 |
static constexpr unsigned int | MAXIMUM_WIDTH = 10000 |
static constexpr unsigned int | NUMBER_OF_COLOR_PLANES |
static constexpr unsigned int | NUMBER_OF_COLORS = 3 |
static constexpr unsigned int | OFFSET_OF_BITMAP_OFFSET = 10 |
static constexpr unsigned int | OFFSET_OF_BITS_PER_PIXEL = 14 |
static constexpr unsigned int | OFFSET_OF_COLOR_PLANES |
static constexpr unsigned int | OFFSET_OF_COMPRESSION |
static constexpr unsigned int | OFFSET_OF_FILE_SIZE = 2 |
static constexpr unsigned int | OFFSET_OF_HEIGHT = 8 |
static constexpr unsigned int | OFFSET_OF_HORIZONTAL_RESOLUTION = 24 |
static constexpr unsigned int | OFFSET_OF_IMAGE_SIZE |
static constexpr unsigned int | OFFSET_OF_NUMBER_OF_COLORS = 32 |
static constexpr unsigned int | OFFSET_OF_NUMBER_OF_IMPORTANT_COLORS = 36 |
static constexpr unsigned int | OFFSET_OF_VERTICAL_RESOLUTION = 28 |
static constexpr unsigned int | OFFSET_OF_WIDTH = 4 |
static constexpr unsigned int | SHORT_DATA_SIZE = 2 |
static constexpr unsigned int | VALID_COMPRESSION = 0 |
Private Types | |
typedef IndexType(PixelInformationType::* | PathFunction) (RandomGenerator &CurrentGenerator, const RepulsionType *RepulsionPointer) const |
Private Member Functions | |
void | AllocateImage (void) noexcept |
unsigned int | ComputeTermite (register unsigned int MaximumValue, register IndexType PixelIndex, register const uint8_t *ColorPointer, register unsigned int Steps, register const PixelInformationType *PixelInformationPointer, register RepulsionType *RepulsionPointer, register RandomGenerator &CurrentGenerator, register PathFunction PathFinder) const noexcept |
void | CorrectColor (register uint8_t *CorrectedColorPointer, register const uint8_t *OriginalColorPointer, register unsigned int MaximumValue, register const CorrectionParameters &Parameters, register const PixelInformationType *PixelInformationPointer, register PathFunction PathFinder, const uint_least32_t DivisionTable[UINT8_MAX+1]) noexcept |
void | CorrectStrip (register uint8_t *CorrectedColorPointer, register const uint8_t *OriginalColorPointer, register unsigned int StartRow, register unsigned int EndRow, register unsigned int MaximumValue, register const CorrectionParameters &Parameters, register const PixelInformationType *PixelInformationPointer, register PathFunction PathFinder, register const uint_least32_t DivisionTable[UINT8_MAX+1]) const noexcept |
void | DestroyImage (void) noexcept |
const CorrectionDescriptorType * | GetStripDescriptor (void) noexcept |
bool | IsOrthogonal (IndexType FirstIndex, IndexType SecondIndex) const noexcept |
IndexType | MakeIndex (unsigned int Row, unsigned int Column) const noexcept |
bool | ValidIndex (unsigned int Row, unsigned int Column) const noexcept |
Static Private Member Functions | |
static uint_fast32_t | LoadInteger (const uint8_t Buffer[], unsigned int Size) noexcept |
static uint_fast32_t | RoundedDivide (uint_fast32_t Dividend, uint_fast32_t Divisor) noexcept |
static void | StoreInteger (uint8_t Buffer[], uint_fast32_t Value, unsigned int Size) noexcept |
Private Attributes | |
uint_fast32_t | BitmapSize |
uint16_t | BitsPerPixel |
CorrectionDescriptorType * | DescriptorPointer |
RandomGenerator | Generator |
uint_fast32_t | Height |
uint_fast32_t | HorizontalResolution |
RepulsionType * | InitialRepulsionPointer |
uint8_t * | PixelPointer [NUMBER_OF_COLORS] |
unsigned short | RepulsionTable [REPULSION_TABLE_SIZE] |
Mutex | StripMutex |
uint_fast32_t | Strips |
uint_fast32_t | VerticalResolution |
uint_fast32_t | Width |
Static Private Attributes | |
static constexpr unsigned int | ATTRACTION_SCALE |
static const char | HeaderName [HEADER_NAME_LENGTH] = { 'B', 'M' } |
static constexpr unsigned int | INITIAL_GENERATION |
static constexpr unsigned int | NUMBER_OF_NEIGHBOURS |
static const char *const | OpenReadBinary = "rb" |
static const char *const | OpenWriteBinary = "wb" |
static constexpr unsigned int | REPULSION_SCALE = 0x400 |
static constexpr size_t | REPULSION_TABLE_SIZE |
static constexpr unsigned int | STRIP_HEIGHT = 5 |
static constexpr const char * | STRIP_INDEX_FORMAT |
static constexpr unsigned int | TERMITES_SUM_SCALE |
|
private |
Pointer to the function which chooses the next pixel.
|
strong |
|
noexcept |
None. |
Definition at line 573 of file Bitmap.cpp.
|
noexcept |
thisBitmap | Bitmap to be copied. |
None. |
Definition at line 598 of file Bitmap.cpp.
|
noexcept |
thisBitmap | Bitmap to be moved. |
None. |
Definition at line 630 of file Bitmap.cpp.
|
noexcept |
None. |
Definition at line 661 of file Bitmap.cpp.
|
inlineprivatenoexcept |
None. |
Definition at line 143 of file Bitmap.inl.
References BitmapSize, NUMBER_OF_COLORS, and PixelPointer.
|
inlinenoexcept |
None. |
Definition at line 468 of file Bitmap.inl.
References BitsPerPixel, and Width.
|
privatenoexcept |
MaximumValue | Maximum value of the color in the whole image. |
PixelIndex | Index of the pixel. |
ColorPointer | Pointer to the array that contains the the original bitmap of the color. |
Steps | Number of steps of each termite. |
PixelInformationPointer | Pointer to the array of information about the pixels. |
RepulsionPointer | Array of the repulsion information for each pixel. |
CurrentGenerator | Reference to the random number generator. |
PathFinder | Member pointer to the function used to select the pixels to visit. |
None. |
Definition at line 298 of file Bitmap.cpp.
Referenced by CorrectStrip().
|
noexcept |
Parameters | Reference to the struct containing the correction parameters. |
IntegerExceptionType::INVALID_NUMBER_OF_TERMITES | If the number of termites is 0 or greater than MAXIMUM_NUMBER_OF_TERMITES. |
IntegerExceptionType::INVALID_NUMBER_OF_STEPS | If the number of steps is 0 or greater than MAXIMUM_NUMBER_OF_STEPS. |
FloatExceptionType::INVALID_REPULSION_STEP | If the repulsion step is less than 0 or greater than 1. |
FloatExceptionType::INVALID_ALPHA | If Alpha is less than 0 or greater than 1. |
FloatExceptionType::INVALID_BETA | If Beta is less than 0 or greater than 1. |
Definition at line 1076 of file Bitmap.cpp.
References GraphicSpace::INVALID_ALPHA, GraphicSpace::INVALID_BETA, GraphicSpace::INVALID_NUMBER_OF_STEPS, GraphicSpace::INVALID_NUMBER_OF_TERMITES, GraphicSpace::INVALID_REPULSION_STEP, NumberOfElements, PixelPointer, GraphicSpace::Bitmap::RepulsionType::Repulsion, and GraphicSpace::Bitmap::RepulsionType::Visitors.
Referenced by Application().
|
privatenoexcept |
|
staticnoexcept |
Argument | Pointer to a CorrectionDescriptorType, containing all the information needed about the strip. |
None. |
Definition at line 1190 of file Bitmap.cpp.
References GraphicSpace::Bitmap::CorrectionDescriptorType::CorrectedColorPointer, GraphicSpace::Bitmap::CorrectionDescriptorType::DivisionTablePointer, GraphicSpace::Bitmap::CorrectionDescriptorType::EndRow, GetStripDescriptor(), GraphicSpace::Bitmap::CorrectionDescriptorType::MaximumValue, GraphicSpace::Bitmap::CorrectionDescriptorType::OriginalColorPointer, GraphicSpace::Bitmap::CorrectionDescriptorType::ParametersPointer, GraphicSpace::Bitmap::CorrectionDescriptorType::PathFinder, GraphicSpace::Bitmap::CorrectionDescriptorType::PixelInformationPointer, and GraphicSpace::Bitmap::CorrectionDescriptorType::StartRow.
|
privatenoexcept |
CorrectedColorPointer | Pointer to the array that will contain the corrected bitmap of the color. |
OriginalColorPointer | Pointer to the array that contains the the original bitmap of the color. |
StartRow | Index of the first row of the strip. |
EndRow | Index of the first row after the strip. |
MaximumValue | Maximum value of the color in the whole image. |
Parameters | Reference to the struct containing the correction parameters. |
PixelInformationPointer | Pointer to the array of information about the pixels. |
PathFinder | Member pointer to the function used to select the pixels to visit. |
DivisionTable | Array of quotient: for n > 0 the entry with index n contains UINT8_MAX * TERMITES_SUM_SCALE / n, rounded to the closest integer; the entry with index 0 contains the same value of the entry with index 1. |
None. |
Definition at line 377 of file Bitmap.cpp.
References BitmapSize, ComputeTermite(), Generator, IgnoreValue, InitialRepulsionPointer, MakeIndex(), GraphicSpace::RandomGenerator::ModifySeed(), RoundedDivide(), GraphicSpace::Bitmap::CorrectionParameters::Steps, GraphicSpace::Bitmap::CorrectionParameters::Termites, TERMITES_SUM_SCALE, and Width.
|
inlineprivatenoexcept |
None. |
Definition at line 164 of file Bitmap.inl.
References NUMBER_OF_COLORS, and PixelPointer.
|
inlinenoexcept |
None. |
Definition at line 417 of file Bitmap.inl.
References BitsPerPixel.
|
inlinenoexcept |
None. |
Definition at line 381 of file Bitmap.inl.
References Height.
|
inlinenoexcept |
None. |
Definition at line 435 of file Bitmap.inl.
References HorizontalResolution.
|
inlinenoexcept |
None. |
Definition at line 399 of file Bitmap.inl.
References BitmapSize.
|
privatenoexcept |
None. |
Definition at line 543 of file Bitmap.cpp.
References IgnoreValue, GraphicSpace::Bitmap::CorrectionDescriptorType::ParametersPointer, and GraphicSpace::Bitmap::CorrectionParameters::Quiet.
Referenced by CorrectFunction().
|
inlinenoexcept |
None. |
Definition at line 453 of file Bitmap.inl.
References VerticalResolution.
|
inlinenoexcept |
None. |
Definition at line 363 of file Bitmap.inl.
References Width.
|
inlineprivatenoexcept |
FirstIndex | Index of first pixel. |
SecondIndex | Index of second pixel. |
None. |
Definition at line 235 of file Bitmap.inl.
References Width.
Referenced by GraphicSpace::Bitmap::PixelInformationType::SetAttraction().
|
inlinestaticprivatenoexcept |
Buffer | Array of bytes to convert. |
Size | The number of bytes to convert. |
None. |
Definition at line 292 of file Bitmap.inl.
References LONG_DATA_SIZE, and SHORT_DATA_SIZE.
|
inlineprivatenoexcept |
Row | Row index. |
Column | Column index. |
None. |
Definition at line 210 of file Bitmap.inl.
Referenced by CorrectStrip().
thisBitmap | Bitmap to assign. |
None. |
Definition at line 716 of file Bitmap.cpp.
References Width.
thisBitmap | Bitmap to assign. |
None. |
Definition at line 682 of file Bitmap.cpp.
References Width.
|
inlinenoexcept |
None. |
Definition at line 491 of file Bitmap.inl.
References GraphicSpace::RandomGenerator::Generate(), Generator, IgnoreValue, INITIAL_GENERATION, and GraphicSpace::RandomGenerator::SetSeed().
|
noexcept |
Path | Pathname of the file. |
FileExceptionType::FILE_OPEN_ERROR | If an error occurs while opening the file. |
FileExceptionType::FILE_SEEK_ERROR | If an error occurs while seeking the file. |
FileExceptionType::FILE_READ_ERROR | If an error occurs while reading the file. |
FileExceptionType::FILE_CLOSE_ERROR | If an error occurs while closing the file. |
IntegerExceptionType::INVALID_FILE_SIZE | If the file size in the header is not equal to the actual file size. |
IntegerExceptionType::INVALID_BITMAP_OFFSET | If the bitmap offset in the header is not equal to HEADER_SIZE + DIB_HEADER_SIZE. |
IntegerExceptionType::INVALID_DIB_HEADER_SIZE | If the DIB header size in the header is not equal to DIB_HEADER_SIZE. |
IntegerExceptionType::INVALID_IMAGE_WIDTH | If the image width is 0 or greater than MAXIMUM_WIDTH. |
IntegerExceptionType::INVALID_COLOR_PLANES | If the number of color planes is not NUMBER_OF_COLOR_PLANES. |
IntegerExceptionType::INVALID_BITS_PER_PIXEL | If the number of bits per pixel is not NUMBER_OF_COLORS * CHAR_BIT. |
IntegerExceptionType::INVALID_COMPRESSION | If the value of compression is not VALID_COMPRESSION. |
IntegerExceptionType::INVALID_IMAGE_SIZE | If the image size is not valid. |
IntegerExceptionType::INVALID_NUMBER_OF_COLORS | If the number of colors is not zero. |
IntegerExceptionType::INVALID_NUMBER_OF_IMPORTANT_COLORS | If the number of important colors is not zero. |
Definition at line 824 of file Bitmap.cpp.
References GraphicSpace::BITMAP_TOO_LARGE, GraphicSpace::FILE_CLOSE_ERROR, GraphicSpace::FILE_OPEN_ERROR, GraphicSpace::FILE_READ_ERROR, GraphicSpace::FILE_SEEK_ERROR, GraphicSpace::INVALID_BITMAP_OFFSET, GraphicSpace::INVALID_BITS_PER_PIXEL, GraphicSpace::INVALID_COLOR_PLANES, GraphicSpace::INVALID_COMPRESSION, GraphicSpace::INVALID_DIB_HEADER_SIZE, GraphicSpace::INVALID_FILE_SIZE, GraphicSpace::INVALID_IMAGE_HEIGHT, GraphicSpace::INVALID_IMAGE_SIZE, GraphicSpace::INVALID_IMAGE_WIDTH, GraphicSpace::INVALID_NUMBER_OF_COLORS, GraphicSpace::INVALID_NUMBER_OF_IMPORTANT_COLORS, and MAXIMUM_BITMAP_SIZE.
Referenced by Application().
|
inlinestaticprivatenoexcept |
Dividend | Dividend. |
Divisor | Divisor. |
None. |
Definition at line 265 of file Bitmap.inl.
Referenced by CorrectStrip().
|
inlinestaticprivatenoexcept |
Buffer | Array where bytes will be stored. |
Value | Value to be stored. |
Size | The number of bytes to convert. |
None. |
Definition at line 337 of file Bitmap.inl.
References LONG_DATA_SIZE, and SHORT_DATA_SIZE.
|
inlineprivatenoexcept |
|
noexcept |
Path | Pathname of the file. |
FileExceptionType::FILE_OPEN_ERROR | If an error occurs while opening the file. |
FileExceptionType::FILE_WRITE_ERROR | If an error occurs while writing the file. |
FileExceptionType::FILE_CLOSE_ERROR | If an error occurs while closing the file. |
Definition at line 973 of file Bitmap.cpp.
References GraphicSpace::FILE_CLOSE_ERROR, GraphicSpace::FILE_OPEN_ERROR, GraphicSpace::FILE_WRITE_ERROR, and IgnoreValue.
Referenced by Application().
|
staticconstexprprivate |
Scale factor for attraction.
|
private |
Size of the image in pixels.
Definition at line 470 of file Bitmap.h.
Referenced by AllocateImage(), CorrectStrip(), and GetSize().
|
private |
Bits per pixels.
Definition at line 474 of file Bitmap.h.
Referenced by ComputeLineSize(), and GetBitsPerPixel().
|
private |
|
staticconstexpr |
Size of the bitmap file DIB header in bytes.
Definition at line 63 of file Bitmap.h.
Referenced by WriteProperties().
|
mutableprivate |
Random numbers generator.
Definition at line 514 of file Bitmap.h.
Referenced by CorrectStrip(), and Randomize().
|
staticconstexpr |
Length of the name of the file type, in bytes
Definition at line 50 of file Bitmap.h.
Referenced by GraphicSpace::NameException::NameException(), and GraphicSpace::NameException::Write().
|
staticconstexpr |
Size of the bitmap file header in bytes.
Definition at line 46 of file Bitmap.h.
Referenced by WriteProperties().
|
staticprivate |
|
private |
Height of the image in pixels.
Definition at line 466 of file Bitmap.h.
Referenced by GetHeight(), MakeIndex(), and ValidIndex().
|
private |
Horizontal resolution in pixel per meter.
Definition at line 478 of file Bitmap.h.
Referenced by GetHorizontalResolution().
|
staticconstexprprivate |
Number of random numbers generated during the initialization of the generator.
Definition at line 240 of file Bitmap.h.
Referenced by Randomize().
|
mutableprivate |
property InitialRepulsionPointer Pointer to an array of initial repulsion values, corresponding to zero visitors.
Definition at line 506 of file Bitmap.h.
Referenced by CorrectStrip().
|
staticconstexpr |
Size of a 16 bit data field, in bytes.
Size of a 32 bit data field, in bytes.
Definition at line 42 of file Bitmap.h.
Referenced by LoadInteger(), and StoreInteger().
|
staticconstexpr |
Maximum number of pixel in an image.
Definition at line 126 of file Bitmap.h.
Referenced by ReadFile().
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
Number of color planes.
Definition at line 114 of file Bitmap.h.
Referenced by AllocateImage(), and DestroyImage().
|
staticconstexprprivate |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticprivate |
|
staticprivate |
|
private |
Array of pointers to bitmaps, one for each color.
Definition at line 486 of file Bitmap.h.
Referenced by AllocateImage(), Correct(), and DestroyImage().
|
staticconstexprprivate |
Scale factor for repulsion.
|
staticconstexprprivate |
Number of elements in the repulsion table.
|
mutableprivate |
property RepulsionTable Array of repulsion values; the index is the number of termites which already visited a pixel.
|
staticconstexpr |
Definition at line 38 of file Bitmap.h.
Referenced by LoadInteger(), and StoreInteger().
|
staticconstexprprivate |
|
staticconstexprprivate |
|
private |
|
staticconstexprprivate |
Scale factor for the sum of the contribution of the termites.
Definition at line 276 of file Bitmap.h.
Referenced by CorrectStrip().
|
staticconstexpr |
|
private |
Vertical resolution in pixel per meter.
Definition at line 482 of file Bitmap.h.
Referenced by GetVerticalResolution().
|
private |
Width of the image in pixels.
Definition at line 462 of file Bitmap.h.
Referenced by ComputeLineSize(), CorrectStrip(), GetWidth(), IsOrthogonal(), MakeIndex(), operator=(), and ValidIndex().