STE-Industries: utilities testing
GraphicSpace::Bitmap Class Reference

#include "Bitmap.h"

Collaboration diagram for GraphicSpace::Bitmap:
Collaboration graph

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
 
Bitmapoperator= (Bitmap &&thisBitmap) noexcept
 
Bitmapoperator= (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 CorrectionDescriptorTypeGetStripDescriptor (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
 
CorrectionDescriptorTypeDescriptorPointer
 
RandomGenerator Generator
 
uint_fast32_t Height
 
uint_fast32_t HorizontalResolution
 
RepulsionTypeInitialRepulsionPointer
 
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
 

Detailed Description

The Bitmap class represents an image in bitmap format.

Definition at line 32 of file Bitmap.h.

Member Typedef Documentation

◆ IndexType

The type used as pixel index.

Definition at line 155 of file Bitmap.h.

◆ PathFunction

GraphicSpace::Bitmap::PathFunction
private

Pointer to the function which chooses the next pixel.

Note
The function captures the random number generator and the pointer to the array of RepulsionType.

Definition at line 401 of file Bitmap.h.

Member Enumeration Documentation

◆ ChoiceType

The ChoiceType enumerated type specify how the choiche of the step is done.

Enumerator
RANDOM 

The step is randomly chosen with a probability distribution

MAXIMUM 

The step with maximum probability is chosen.

Definition at line 164 of file Bitmap.h.

Constructor & Destructor Documentation

◆ Bitmap() [1/3]

GraphicSpace::Bitmap::Bitmap ( void  )
noexcept
Description:
Constructor.
Exceptions
None.
Returns
Not applicable
See also
NUMBER_OF_COLORS

Definition at line 573 of file Bitmap.cpp.

◆ Bitmap() [2/3]

GraphicSpace::Bitmap::Bitmap ( const Bitmap thisBitmap)
noexcept
Description:
Copy constructor.
Parameters
thisBitmapBitmap to be copied.
Exceptions
None.
Returns
Not applicable
See also
NUMBER_OF_COLORS

Definition at line 598 of file Bitmap.cpp.

◆ Bitmap() [3/3]

GraphicSpace::Bitmap::Bitmap ( Bitmap &&  thisBitmap)
noexcept
Description:
Move constructor.
Parameters
thisBitmapBitmap to be moved.
Exceptions
None.
Returns
Not applicable
See also
NUMBER_OF_COLORS

Definition at line 630 of file Bitmap.cpp.

◆ ~Bitmap()

GraphicSpace::Bitmap::~Bitmap ( void  )
noexcept
Description:
Destructor.
Exceptions
None.
Returns
Not applicable
See also
NUMBER_OF_COLORS

Definition at line 661 of file Bitmap.cpp.

Member Function Documentation

◆ AllocateImage()

void GraphicSpace::Bitmap::AllocateImage ( void  )
inlineprivatenoexcept
Description:
Allocate the bitmap for the image.
Exceptions
None.
Returns
none.
See also
NUMBER_OF_COLORS

Definition at line 143 of file Bitmap.inl.

References BitmapSize, NUMBER_OF_COLORS, and PixelPointer.

◆ ComputeLineSize()

uint_fast32_t GraphicSpace::Bitmap::ComputeLineSize ( void  ) const
inlinenoexcept
Description:
Compute the size of a line in bytes in a bitmap file in bytes.
Exceptions
None.
Returns
uint_fast32_t The size of a line in a bitmap file.

Definition at line 468 of file Bitmap.inl.

References BitsPerPixel, and Width.

◆ ComputeTermite()

unsigned int GraphicSpace::Bitmap::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
privatenoexcept
Description:
Compute the contribution of a termite to the correction of a pixel of a color.
Parameters
MaximumValueMaximum value of the color in the whole image.
PixelIndexIndex of the pixel.
ColorPointerPointer to the array that contains the the original bitmap of the color.
StepsNumber of steps of each termite.
PixelInformationPointerPointer to the array of information about the pixels.
RepulsionPointerArray of the repulsion information for each pixel.
CurrentGeneratorReference to the random number generator.
PathFinderMember pointer to the function used to select the pixels to visit.
Exceptions
None.
Returns
None.
Note
If ColorPointer is not a pointer to an array of at least BitmapSize elements, the behavior is undefined.
If Visitors is not a pointer to an array of at least BitmapSize elements, the behavior is undefined.
If Repulsion is not a pointer to an array of at least BitmapSize elements, the behavior is undefined.
See also
REPULSION_TABLE_SIZE

Definition at line 298 of file Bitmap.cpp.

Referenced by CorrectStrip().

Here is the caller graph for this function:

◆ Correct()

Bitmap GraphicSpace::Bitmap::Correct ( register const CorrectionParameters Parameters)
noexcept
Description:
Correct the bitmap.
Parameters
ParametersReference to the struct containing the correction parameters.
Exceptions
IntegerExceptionType::INVALID_NUMBER_OF_TERMITESIf the number of termites is 0 or greater than MAXIMUM_NUMBER_OF_TERMITES.
IntegerExceptionType::INVALID_NUMBER_OF_STEPSIf the number of steps is 0 or greater than MAXIMUM_NUMBER_OF_STEPS.
FloatExceptionType::INVALID_REPULSION_STEPIf the repulsion step is less than 0 or greater than 1.
FloatExceptionType::INVALID_ALPHAIf Alpha is less than 0 or greater than 1.
FloatExceptionType::INVALID_BETAIf Beta is less than 0 or greater than 1.
Returns
Bitmap The corrected bitmap.
See also
NUMBER_OF_COLORS
MAXIMUM_NUMBER_OF_TERMITES
MAXIMUM_NUMBER_OF_STEPS
ATTRACTION_SCALE
REPULSION_SCALE
REPULSION_TABLE_SIZE
UINT8_MAX
TERMITES_SUM_SCALE

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().

Here is the caller graph for this function:

◆ CorrectColor()

void GraphicSpace::Bitmap::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] 
)
privatenoexcept

◆ CorrectFunction()

void * GraphicSpace::Bitmap::CorrectFunction ( void *  Argument)
staticnoexcept
Description:
Correct one color of the bitmap, on an horizontal strip of the bitmap.
Parameters
ArgumentPointer to a CorrectionDescriptorType, containing all the information needed about the strip.
Exceptions
None.
Returns
void* Always nullptr.
Note
The correction algorithm is applied to all pixel whose row is in the range StartRow .. EndRow - 1, where StartRow and EndRow are the fields of the CorrectionDescriptorType struct.
The interface if constrained, as this must be the starting function of a thread; the returned value is ignored.
If Argument is not a pointer to a valid CorrectionDescriptorType struct, the behavior is undefined.

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.

Here is the call graph for this function:

◆ CorrectStrip()

void GraphicSpace::Bitmap::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
privatenoexcept
Description:
Correct one color of the bitmap, on an horizontal strip of the bitmap.
Parameters
CorrectedColorPointerPointer to the array that will contain the corrected bitmap of the color.
OriginalColorPointerPointer to the array that contains the the original bitmap of the color.
StartRowIndex of the first row of the strip.
EndRowIndex of the first row after the strip.
MaximumValueMaximum value of the color in the whole image.
ParametersReference to the struct containing the correction parameters.
PixelInformationPointerPointer to the array of information about the pixels.
PathFinderMember pointer to the function used to select the pixels to visit.
DivisionTableArray 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.
Exceptions
None.
Returns
None.
Note
If CorrectedColorPointer is not a pointer to an array of at least BitmapSize elements, the behavior is undefined.
If OriginalColorPointer is not a pointer to an array of at least BitmapSize elements, the behavior is undefined.
The correction algorithm is applied to all pixel whose row is in the range [StartRow .. EndRow - 1].
See also
UINT8_MAX
TERMITES_SUM_SCALE

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.

Here is the call graph for this function:

◆ DestroyImage()

void GraphicSpace::Bitmap::DestroyImage ( void  )
inlineprivatenoexcept
Description:
Free the bitmap of the image.
Exceptions
None.
Returns
none.
See also
NUMBER_OF_COLORS

Definition at line 164 of file Bitmap.inl.

References NUMBER_OF_COLORS, and PixelPointer.

◆ GetBitsPerPixel()

unsigned int GraphicSpace::Bitmap::GetBitsPerPixel ( void  ) const
inlinenoexcept
Description:
Return the number of bits per pixel.
Exceptions
None.
Returns
unsigned int The number of bits per pixel.
Note
If no image has been read, the returned value is undefined.

Definition at line 417 of file Bitmap.inl.

References BitsPerPixel.

◆ GetHeight()

uint_fast32_t GraphicSpace::Bitmap::GetHeight ( void  ) const
inlinenoexcept
Description:
Return the height of the image.
Exceptions
None.
Returns
uint_fast32_t The height of the image.
Note
If no image has been read, the returned value is undefined.

Definition at line 381 of file Bitmap.inl.

References Height.

◆ GetHorizontalResolution()

uint_fast32_t GraphicSpace::Bitmap::GetHorizontalResolution ( void  ) const
inlinenoexcept
Description:
Return the horizontal resolution.
Exceptions
None.
Returns
uint_fast32_t The horizontal resolution.
Note
If no image has been read, the returned value is undefined.

Definition at line 435 of file Bitmap.inl.

References HorizontalResolution.

◆ GetSize()

uint_fast32_t GraphicSpace::Bitmap::GetSize ( void  ) const
inlinenoexcept
Description:
Return the size of the image, in pixels,
Exceptions
None.
Returns
uint_fast32_t The size of the image.
Note
If no image has been read, the returned value is undefined.

Definition at line 399 of file Bitmap.inl.

References BitmapSize.

◆ GetStripDescriptor()

const Bitmap::CorrectionDescriptorType * GraphicSpace::Bitmap::GetStripDescriptor ( void  )
privatenoexcept
Description:
Return the pointer to next strip to correct, or nullptr, if all strips have been processed.
Exceptions
None.
Returns
const CorrectionDescriptorType* The pointer to next strip to correct.
See also
STRIP_INDEX_FORMAT

Definition at line 543 of file Bitmap.cpp.

References IgnoreValue, GraphicSpace::Bitmap::CorrectionDescriptorType::ParametersPointer, and GraphicSpace::Bitmap::CorrectionParameters::Quiet.

Referenced by CorrectFunction().

Here is the caller graph for this function:

◆ GetVerticalResolution()

uint_fast32_t GraphicSpace::Bitmap::GetVerticalResolution ( void  ) const
inlinenoexcept
Description:
Return the vertical resolution.
Exceptions
None.
Returns
uint_fast32_t The vertical resolution.
Note
If no image has been read, the returned value is undefined.

Definition at line 453 of file Bitmap.inl.

References VerticalResolution.

◆ GetWidth()

uint_fast32_t GraphicSpace::Bitmap::GetWidth ( void  ) const
inlinenoexcept
Description:
Return the width of the image.
Exceptions
None.
Returns
uint_fast32_t The height of the image.
Note
If no image has been read, the returned value is undefined.

Definition at line 363 of file Bitmap.inl.

References Width.

◆ IsOrthogonal()

bool GraphicSpace::Bitmap::IsOrthogonal ( IndexType  FirstIndex,
IndexType  SecondIndex 
) const
inlineprivatenoexcept
Description:
Check whether two pixels are orthogonal at distance one to each other.
Parameters
FirstIndexIndex of first pixel.
SecondIndexIndex of second pixel.
Exceptions
None.
Returns
bool true, if the two pixels are orthogonal at distance one to each other.
Note
If no image has been read, the returned value is undefined.

Definition at line 235 of file Bitmap.inl.

References Width.

Referenced by GraphicSpace::Bitmap::PixelInformationType::SetAttraction().

Here is the caller graph for this function:

◆ LoadInteger()

uint_fast32_t GraphicSpace::Bitmap::LoadInteger ( const uint8_t  Buffer[],
unsigned int  Size 
)
inlinestaticprivatenoexcept
Description:
Convert consecutive bytes in little endian order to an uint_fast32_t.
Parameters
BufferArray of bytes to convert.
SizeThe number of bytes to convert.
Exceptions
None.
Returns
uint_fast32_t The converted value.
Note
If Size is different from SHORT_DATA_SIZE or LONG_DATA_SIZE, the function returns zero.
If Buffer is not a pointer to an area of Size bytes, the behavior is undefined.

Definition at line 292 of file Bitmap.inl.

References LONG_DATA_SIZE, and SHORT_DATA_SIZE.

◆ MakeIndex()

Bitmap::IndexType GraphicSpace::Bitmap::MakeIndex ( unsigned int  Row,
unsigned int  Column 
) const
inlineprivatenoexcept
Description:
Compute the index of a pixel in the bitmap, given the row and column indices.
Parameters
RowRow index.
ColumnColumn index.
Exceptions
None.
Returns
IndexType The index.
Note
If Row is not less that Height or Column is not less than Width, the returned value is not a valid index.

Definition at line 210 of file Bitmap.inl.

References Height, and Width.

Referenced by CorrectStrip().

Here is the caller graph for this function:

◆ operator=() [1/2]

Bitmap & GraphicSpace::Bitmap::operator= ( Bitmap &&  thisBitmap)
noexcept
Description:
Move assignment.
Parameters
thisBitmapBitmap to assign.
Exceptions
None.
Returns
Bitmap& reference to the assigned Bitmap.
See also
NUMBER_OF_COLORS

Definition at line 716 of file Bitmap.cpp.

References Width.

◆ operator=() [2/2]

Bitmap & GraphicSpace::Bitmap::operator= ( const Bitmap thisBitmap)
noexcept
Description:
Copy assignment.
Parameters
thisBitmapBitmap to assign.
Exceptions
None.
Returns
Bitmap& reference to the assigned Bitmap.
See also
NUMBER_OF_COLORS

Definition at line 682 of file Bitmap.cpp.

References Width.

◆ Randomize()

void GraphicSpace::Bitmap::Randomize ( uint_fast32_t  Seed[RandomGenerator::NUMBER_OF_GENERATORS+1])
inlinenoexcept
Description:
Initialize the random numbers generator with a set of values.
Exceptions
None.
Returns
None.
See also
NUMBER_OF_GENERATORS
INITIAL_GENERATION
Note
The function causes the generation of a small number of random numbers, to better initialize the generator.

Definition at line 491 of file Bitmap.inl.

References GraphicSpace::RandomGenerator::Generate(), Generator, IgnoreValue, INITIAL_GENERATION, and GraphicSpace::RandomGenerator::SetSeed().

Here is the call graph for this function:

◆ ReadFile()

void GraphicSpace::Bitmap::ReadFile ( const char *  Path)
noexcept
Description:
Read a bitmap image from a file.
Parameters
PathPathname of the file.
Exceptions
FileExceptionType::FILE_OPEN_ERRORIf an error occurs while opening the file.
FileExceptionType::FILE_SEEK_ERRORIf an error occurs while seeking the file.
FileExceptionType::FILE_READ_ERRORIf an error occurs while reading the file.
FileExceptionType::FILE_CLOSE_ERRORIf an error occurs while closing the file.
IntegerExceptionType::INVALID_FILE_SIZEIf the file size in the header is not equal to the actual file size.
IntegerExceptionType::INVALID_BITMAP_OFFSETIf the bitmap offset in the header is not equal to HEADER_SIZE + DIB_HEADER_SIZE.
IntegerExceptionType::INVALID_DIB_HEADER_SIZEIf the DIB header size in the header is not equal to DIB_HEADER_SIZE.
IntegerExceptionType::INVALID_IMAGE_WIDTHIf the image width is 0 or greater than MAXIMUM_WIDTH.
IntegerExceptionType::INVALID_COLOR_PLANESIf the number of color planes is not NUMBER_OF_COLOR_PLANES.
IntegerExceptionType::INVALID_BITS_PER_PIXELIf the number of bits per pixel is not NUMBER_OF_COLORS * CHAR_BIT.
IntegerExceptionType::INVALID_COMPRESSIONIf the value of compression is not VALID_COMPRESSION.
IntegerExceptionType::INVALID_IMAGE_SIZEIf the image size is not valid.
IntegerExceptionType::INVALID_NUMBER_OF_COLORSIf the number of colors is not zero.
IntegerExceptionType::INVALID_NUMBER_OF_IMPORTANT_COLORSIf the number of important colors is not zero.
Returns
None
Note
If Path is not a valid pointer to a zero terminated string, the behavior is undefined.
See also
SHORT_DATA_SIZE
LONG_DATA_SIZE
HEADER_SIZE
OFFSET_OF_FILE_SIZE
HEADER_NAME_LENGTH
OFFSET_OF_BITMAP_OFFSET
HEADER_SIZE
DIB_HEADER_SIZE
OFFSET_OF_WIDTH
OFFSET_OF_HEIGHT
OFFSET_OF_COLOR_PLANES
OFFSET_OF_BITS_PER_PIXEL
CHAR_BIT
OFFSET_OF_COMPRESSION
OFFSET_OF_IMAGE_SIZE
OFFSET_OF_HORIZONTAL_RESOLUTION
OFFSET_OF_VERTICAL_RESOLUTION
OFFSET_OF_NUMBER_OF_COLORS
OFFSET_OF_NUMBER_OF_IMPORTANT_COLORS
NUMBER_OF_COLORS
MAXIMUM_WIDTH
MAXIMUM_HEIGHT
NUMBER_OF_COLOR_PLANES
VALID_COMPRESSION

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().

Here is the caller graph for this function:

◆ RoundedDivide()

uint_fast32_t GraphicSpace::Bitmap::RoundedDivide ( uint_fast32_t  Dividend,
uint_fast32_t  Divisor 
)
inlinestaticprivatenoexcept
Description:
Divide a uint_fast32_t by another, rounding the quotient.
Parameters
DividendDividend.
DivisorDivisor.
Exceptions
None.
Returns
uint_fast32_t The rounded quotient.
Note
If Divisor is zero, the behavior is undefined.
If Dividend + Divisor / 2 is greater than UINT_FAST32_MAX, the returned value is undefined.

Definition at line 265 of file Bitmap.inl.

Referenced by CorrectStrip().

Here is the caller graph for this function:

◆ StoreInteger()

void GraphicSpace::Bitmap::StoreInteger ( uint8_t  Buffer[],
uint_fast32_t  Value,
unsigned int  Size 
)
inlinestaticprivatenoexcept
Description:
Convert an integer to consecutive bytes, in little endian order.
Parameters
BufferArray where bytes will be stored.
ValueValue to be stored.
SizeThe number of bytes to convert.
Exceptions
None.
Returns
None.
Note
If Size is different from SHORT_DATA_SIZE or LONG_DATA_SIZE, the behavior is undefined.
If Buffer is not a pointer to an area of Size bytes, the behavior is undefined.

Definition at line 337 of file Bitmap.inl.

References LONG_DATA_SIZE, and SHORT_DATA_SIZE.

◆ ValidIndex()

bool GraphicSpace::Bitmap::ValidIndex ( unsigned int  Row,
unsigned int  Column 
) const
inlineprivatenoexcept
Description:
Check whether the Bitmap contains the pixel.
Parameters
RowRow index.
ColumnColumn index.
Exceptions
None.
Returns
bool true, if the Bitmap contains the pixel.

Definition at line 186 of file Bitmap.inl.

References Height, and Width.

◆ WriteFile()

void GraphicSpace::Bitmap::WriteFile ( const char *  Path)
noexcept
Description:
Write a bitmap image to a file.
Parameters
PathPathname of the file.
Exceptions
FileExceptionType::FILE_OPEN_ERRORIf an error occurs while opening the file.
FileExceptionType::FILE_WRITE_ERRORIf an error occurs while writing the file.
FileExceptionType::FILE_CLOSE_ERRORIf an error occurs while closing the file.
Returns
None
Note
If Path is not a valid pointer to a zero terminated string, the behavior is undefined.
See also
SHORT_DATA_SIZE
LONG_DATA_SIZE
HEADER_SIZE
OFFSET_OF_FILE_SIZE
HEADER_NAME_LENGTH
OFFSET_OF_BITMAP_OFFSET
HEADER_SIZE
DIB_HEADER_SIZE
OFFSET_OF_WIDTH
OFFSET_OF_HEIGHT
OFFSET_OF_COLOR_PLANES
OFFSET_OF_BITS_PER_PIXEL
OFFSET_OF_COMPRESSION
OFFSET_OF_HORIZONTAL_RESOLUTION
OFFSET_OF_VERTICAL_RESOLUTION
NUMBER_OF_COLORS
NUMBER_OF_COLOR_PLANES
VALID_COMPRESSION

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().

Here is the caller graph for this function:

Member Data Documentation

◆ ATTRACTION_SCALE

GraphicSpace::Bitmap::ATTRACTION_SCALE
staticconstexprprivate
Initial value:
=
0x800

Scale factor for attraction.

Note
The product ATTRACTION_SCALE * REPULSION_SCALE shall not exceed 0x200000.
See also
REPULSION_SCALE

Definition at line 255 of file Bitmap.h.

◆ BitmapSize

GraphicSpace::Bitmap::BitmapSize
private

Size of the image in pixels.

Definition at line 470 of file Bitmap.h.

Referenced by AllocateImage(), CorrectStrip(), and GetSize().

◆ BitsPerPixel

GraphicSpace::Bitmap::BitsPerPixel
private

Bits per pixels.

Definition at line 474 of file Bitmap.h.

Referenced by ComputeLineSize(), and GetBitsPerPixel().

◆ DescriptorPointer

GraphicSpace::Bitmap::DescriptorPointer
private

Array of descriptors used to split the work among threads.

Definition at line 526 of file Bitmap.h.

◆ DIB_HEADER_SIZE

GraphicSpace::Bitmap::DIB_HEADER_SIZE = 40
staticconstexpr

Size of the bitmap file DIB header in bytes.

Definition at line 63 of file Bitmap.h.

Referenced by WriteProperties().

◆ Generator

GraphicSpace::Bitmap::Generator
mutableprivate

Random numbers generator.

Note
It is declared mutable, as it is necessary to change its content to generate new numbers, even if the Bitmap is not changed.

Definition at line 514 of file Bitmap.h.

Referenced by CorrectStrip(), and Randomize().

◆ HEADER_NAME_LENGTH

GraphicSpace::Bitmap::HEADER_NAME_LENGTH = 2
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().

◆ HEADER_SIZE

GraphicSpace::Bitmap::HEADER_SIZE = 14
staticconstexpr

Size of the bitmap file header in bytes.

Definition at line 46 of file Bitmap.h.

Referenced by WriteProperties().

◆ HeaderName

GraphicSpace::Bitmap::HeaderName = { 'B', 'M' }
staticprivate

Name of the file type.

Definition at line 530 of file Bitmap.h.

◆ Height

GraphicSpace::Bitmap::Height
private

Height of the image in pixels.

Definition at line 466 of file Bitmap.h.

Referenced by GetHeight(), MakeIndex(), and ValidIndex().

◆ HorizontalResolution

GraphicSpace::Bitmap::HorizontalResolution
private

Horizontal resolution in pixel per meter.

Definition at line 478 of file Bitmap.h.

Referenced by GetHorizontalResolution().

◆ INITIAL_GENERATION

GraphicSpace::Bitmap::INITIAL_GENERATION
staticconstexprprivate
Initial value:
=
1000

Number of random numbers generated during the initialization of the generator.

Definition at line 240 of file Bitmap.h.

Referenced by Randomize().

◆ InitialRepulsionPointer

RepulsionType* GraphicSpace::Bitmap::InitialRepulsionPointer
mutableprivate

property InitialRepulsionPointer Pointer to an array of initial repulsion values, corresponding to zero visitors.

Note
It is declared mutable, as it is necessary to change its content to correct the image, even if the Bitmap is not changed.

Definition at line 506 of file Bitmap.h.

Referenced by CorrectStrip().

◆ LONG_DATA_SIZE

GraphicSpace::Bitmap::LONG_DATA_SIZE = 4
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().

◆ MAXIMUM_BITMAP_SIZE

GraphicSpace::Bitmap::MAXIMUM_BITMAP_SIZE
staticconstexpr
Initial value:
=
20000000

Maximum number of pixel in an image.

Definition at line 126 of file Bitmap.h.

Referenced by ReadFile().

◆ MAXIMUM_HEIGHT

GraphicSpace::Bitmap::MAXIMUM_HEIGHT = 10000
staticconstexpr

Maximum Height of an image.

Definition at line 122 of file Bitmap.h.

◆ MAXIMUM_NUMBER_OF_STEPS

GraphicSpace::Bitmap::MAXIMUM_NUMBER_OF_STEPS = 1000
staticconstexpr

Maximum number of steps.

Definition at line 151 of file Bitmap.h.

◆ MAXIMUM_NUMBER_OF_TERMITES

GraphicSpace::Bitmap::MAXIMUM_NUMBER_OF_TERMITES
staticconstexpr
Initial value:
=
1000

Maximum number of termites.

Definition at line 145 of file Bitmap.h.

◆ MAXIMUM_NUMBER_OF_THREADS

GraphicSpace::Bitmap::MAXIMUM_NUMBER_OF_THREADS = 100
staticconstexpr

Maximum number of threads.

Definition at line 140 of file Bitmap.h.

◆ MAXIMUM_WIDTH

GraphicSpace::Bitmap::MAXIMUM_WIDTH = 10000
staticconstexpr

Maximum width of an image.

Definition at line 118 of file Bitmap.h.

◆ NUMBER_OF_COLOR_PLANES

GraphicSpace::Bitmap::NUMBER_OF_COLOR_PLANES
staticconstexpr
Initial value:
=
1

Valid number of color planes.

Definition at line 131 of file Bitmap.h.

◆ NUMBER_OF_COLORS

GraphicSpace::Bitmap::NUMBER_OF_COLORS = 3
staticconstexpr

Number of color planes.

Definition at line 114 of file Bitmap.h.

Referenced by AllocateImage(), and DestroyImage().

◆ NUMBER_OF_NEIGHBOURS

GraphicSpace::Bitmap::NUMBER_OF_NEIGHBOURS
staticconstexprprivate
Initial value:
=
8

Number of neigbours of every pixel.

Definition at line 245 of file Bitmap.h.

◆ OFFSET_OF_BITMAP_OFFSET

GraphicSpace::Bitmap::OFFSET_OF_BITMAP_OFFSET = 10
staticconstexpr

Offset of the bitmap offset within the header.

Definition at line 55 of file Bitmap.h.

◆ OFFSET_OF_BITS_PER_PIXEL

GraphicSpace::Bitmap::OFFSET_OF_BITS_PER_PIXEL = 14
staticconstexpr

Offset of the number of bits per pixel within the DIB header.

Definition at line 81 of file Bitmap.h.

◆ OFFSET_OF_COLOR_PLANES

GraphicSpace::Bitmap::OFFSET_OF_COLOR_PLANES
staticconstexpr
Initial value:
=
12

Offset of the number of color planes within the DIB header.

Definition at line 75 of file Bitmap.h.

◆ OFFSET_OF_COMPRESSION

GraphicSpace::Bitmap::OFFSET_OF_COMPRESSION
staticconstexpr
Initial value:
=
16

Offset of the kind of compression within the DIB header.

Definition at line 85 of file Bitmap.h.

◆ OFFSET_OF_FILE_SIZE

GraphicSpace::Bitmap::OFFSET_OF_FILE_SIZE = 2
staticconstexpr

Offset of the file size within the header.

Definition at line 59 of file Bitmap.h.

◆ OFFSET_OF_HEIGHT

GraphicSpace::Bitmap::OFFSET_OF_HEIGHT = 8
staticconstexpr

Offset of the image height within the DIB header.

Definition at line 71 of file Bitmap.h.

◆ OFFSET_OF_HORIZONTAL_RESOLUTION

GraphicSpace::Bitmap::OFFSET_OF_HORIZONTAL_RESOLUTION = 24
staticconstexpr

Offset of the horizontal resolution within the DIB header.

Definition at line 95 of file Bitmap.h.

◆ OFFSET_OF_IMAGE_SIZE

GraphicSpace::Bitmap::OFFSET_OF_IMAGE_SIZE
staticconstexpr
Initial value:
=
20

Offset of the image size within the DIB header.

Definition at line 89 of file Bitmap.h.

◆ OFFSET_OF_NUMBER_OF_COLORS

GraphicSpace::Bitmap::OFFSET_OF_NUMBER_OF_COLORS = 32
staticconstexpr

Offset of the number of colors within the DIB header.

Definition at line 105 of file Bitmap.h.

◆ OFFSET_OF_NUMBER_OF_IMPORTANT_COLORS

GraphicSpace::Bitmap::OFFSET_OF_NUMBER_OF_IMPORTANT_COLORS = 36
staticconstexpr

Offset of the number of important colors within the DIB header.

Definition at line 110 of file Bitmap.h.

◆ OFFSET_OF_VERTICAL_RESOLUTION

GraphicSpace::Bitmap::OFFSET_OF_VERTICAL_RESOLUTION = 28
staticconstexpr

Offset of the vertical resolution within the DIB header.

Definition at line 100 of file Bitmap.h.

◆ OFFSET_OF_WIDTH

GraphicSpace::Bitmap::OFFSET_OF_WIDTH = 4
staticconstexpr

Offset of the image width within the DIB header.

Definition at line 67 of file Bitmap.h.

◆ OpenReadBinary

GraphicSpace::Bitmap::OpenReadBinary = "rb"
staticprivate

String used to specify binary read only mode when opening a file.

Definition at line 534 of file Bitmap.h.

◆ OpenWriteBinary

GraphicSpace::Bitmap::OpenWriteBinary = "wb"
staticprivate

String used to specify binary write only mode when opening a file.

Definition at line 538 of file Bitmap.h.

◆ PixelPointer

GraphicSpace::Bitmap::PixelPointer
private

Array of pointers to bitmaps, one for each color.

Definition at line 486 of file Bitmap.h.

Referenced by AllocateImage(), Correct(), and DestroyImage().

◆ REPULSION_SCALE

GraphicSpace::Bitmap::REPULSION_SCALE = 0x400
staticconstexprprivate

Scale factor for repulsion.

Note
REPULSION_SCALE shall not exceed USHRT_MAX and the product ATTRACTION_SCALE * REPULSION_SCALE shall not exceed 0x200000.
See also
ATTRACTION_SCALE

Definition at line 266 of file Bitmap.h.

◆ REPULSION_TABLE_SIZE

GraphicSpace::Bitmap::REPULSION_TABLE_SIZE
staticconstexprprivate
Initial value:
=
static_cast<size_t>
static_cast<size_t>

Number of elements in the repulsion table.

See also
MAXIMUM_NUMBER_OF_TERMITES
MAXIMUM_NUMBER_OF_STEPS

Definition at line 284 of file Bitmap.h.

◆ RepulsionTable

unsigned short GraphicSpace::Bitmap::RepulsionTable[REPULSION_TABLE_SIZE]
mutableprivate

property RepulsionTable Array of repulsion values; the index is the number of termites which already visited a pixel.

Note
It is declared mutable, as it is necessary to change its content to correct the image, even if the Bitmap is not changed.
See also
REPULSION_TABLE_SIZE

Definition at line 497 of file Bitmap.h.

◆ SHORT_DATA_SIZE

constexpr unsigned int GraphicSpace::Bitmap::SHORT_DATA_SIZE = 2
staticconstexpr

Definition at line 38 of file Bitmap.h.

Referenced by LoadInteger(), and StoreInteger().

◆ STRIP_HEIGHT

GraphicSpace::Bitmap::STRIP_HEIGHT = 5
staticconstexprprivate

Height of the strips given to each thread.

Definition at line 292 of file Bitmap.h.

◆ STRIP_INDEX_FORMAT

GraphicSpace::Bitmap::STRIP_INDEX_FORMAT
staticconstexprprivate
Initial value:
=
"Processing strip %" PRIuFAST32 "\n"

Format used to print the index of the strip being processed.

Definition at line 234 of file Bitmap.h.

◆ StripMutex

GraphicSpace::Bitmap::StripMutex
private

Mutex used by the thread to get new strips to process.

Definition at line 522 of file Bitmap.h.

◆ Strips

GraphicSpace::Bitmap::Strips
private

Number of strips.

Definition at line 518 of file Bitmap.h.

◆ TERMITES_SUM_SCALE

GraphicSpace::Bitmap::TERMITES_SUM_SCALE
staticconstexprprivate
Initial value:
=
0x4000

Scale factor for the sum of the contribution of the termites.

Note
The product UINT8_MAX * MAXIMUM_NUMBER_OF_TERMITES * TERMITES_SUM_SCALE shall not exceed UINT32_MAX.
See also
MAXIMUM_NUMBER_OF_TERMITES

Definition at line 276 of file Bitmap.h.

Referenced by CorrectStrip().

◆ VALID_COMPRESSION

GraphicSpace::Bitmap::VALID_COMPRESSION = 0
staticconstexpr

Valid value for compression.

Definition at line 135 of file Bitmap.h.

◆ VerticalResolution

GraphicSpace::Bitmap::VerticalResolution
private

Vertical resolution in pixel per meter.

Definition at line 482 of file Bitmap.h.

Referenced by GetVerticalResolution().

◆ Width

GraphicSpace::Bitmap::Width
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().


The documentation for this class was generated from the following files:
GraphicSpace::Bitmap::MAXIMUM_NUMBER_OF_STEPS
static constexpr unsigned int MAXIMUM_NUMBER_OF_STEPS
Definition: Bitmap.h:151
GraphicSpace::Bitmap::MAXIMUM_NUMBER_OF_TERMITES
static constexpr unsigned int MAXIMUM_NUMBER_OF_TERMITES
Definition: Bitmap.h:145