A bunch of utility functions.
More...
#include <libCZI_Utilities.h>
|
| static char | DimensionToChar (libCZI::DimensionIndex dim) |
| |
| static libCZI::DimensionIndex | CharToDimension (char c) |
| |
| static int | CalcMd5SumHash (libCZI::IBitmapData *bm, std::uint8_t *ptrHash, int hashSize) |
| |
| static int | CalcMd5SumHash (const void *ptrData, size_t sizeData, std::uint8_t *ptrHash, int hashSize) |
| |
| static std::vector< std::uint8_t > | Create8BitLookUpTableFromSplines (int tableElementCnt, float blackPoint, float whitePoint, const std::vector< libCZI::IDisplaySettings::SplineData > &splineData) |
| |
| static std::vector< std::uint8_t > | Create8BitLookUpTableFromGamma (int tableElementCnt, float blackPoint, float whitePoint, float gamma) |
| |
| static std::vector< libCZI::IDisplaySettings::SplineData > | CalcSplineDataFromPoints (int pointCnt, std::function< std::tuple< double, double >(int idx)> getPoint) |
| |
| static std::shared_ptr< libCZI::IBitmapData > | NearestNeighborResize (libCZI::IBitmapData *bmSrc, int dstWidth, int dstHeight) |
| |
| static std::shared_ptr< libCZI::IBitmapData > | NearestNeighborResize (libCZI::IBitmapData *bmSrc, int dstWidth, int dstHeight, const DblRect &roiSrc, const DblRect &roiDest) |
| |
| static float | CalcZoom (const libCZI::IntRect &logicalRect, const libCZI::IntSize &physicalSize) |
| |
| static float | CalcZoom (const libCZI::IntSize &logicalSize, const libCZI::IntSize &physicalSize) |
| |
| static const char * | PixelTypeToInformalString (libCZI::PixelType pixeltype) |
| |
| static const char * | CompressionModeToInformalString (libCZI::CompressionMode compressionMode) |
| |
| static std::string | DimCoordinateToString (const libCZI::IDimCoordinate *coord) |
| |
| static bool | StringToDimCoordinate (const char *sz, libCZI::CDimCoordinate *coord) |
| |
| static std::string | DimBoundsToString (const libCZI::IDimBounds *bounds) |
| |
| static std::shared_ptr< libCZI::IIndexSet > | IndexSetFromString (const std::wstring &s) |
| |
| static libCZI::PixelType | TryDeterminePixelTypeForChannel (libCZI::ISubBlockRepository *repository, int channelIdx) |
| |
| static int | Compare (const IDimCoordinate *a, const IDimCoordinate *b) |
| |
| static bool | HasSameDimensions (const IDimCoordinate *a, const IDimCoordinate *b) |
| |
| static bool | EnumAllCoordinates (const libCZI::CDimBounds &bounds, const std::function< bool(std::uint64_t, const libCZI::CDimCoordinate &coord)> &func) |
| |
| static void | FillBitmap (libCZI::IBitmapData *bm, const libCZI::RgbFloatColor &floatColor) |
| |
A bunch of utility functions.
◆ CalcMd5SumHash() [1/2]
| static int libCZI::Utils::CalcMd5SumHash |
( |
libCZI::IBitmapData * |
bm, |
|
|
std::uint8_t * |
ptrHash, |
|
|
int |
hashSize |
|
) |
| |
|
static |
Calculates the MD5SUM hash for the pixels in the specified bitmap.
- Parameters
-
| [in] | bm | The bitmap. |
| [in,out] | ptrHash | Pointer to the hash-code result. The result will be of size 16 bytes. |
| hashSize | Size of the hash-code result pointed to by ptrHash. We need 16 bytes. |
- Returns
- The count of bytes that were written to in ptrHash as the MD5SUM-hash (always 16).
◆ CalcMd5SumHash() [2/2]
| static int libCZI::Utils::CalcMd5SumHash |
( |
const void * |
ptrData, |
|
|
size_t |
sizeData, |
|
|
std::uint8_t * |
ptrHash, |
|
|
int |
hashSize |
|
) |
| |
|
static |
Calculates the MD5SUM hash for the specified data.
- Parameters
-
| [in] | ptrData | Pointer to the data (for which to calculate the MD5SUM-hash). |
| [in] | sizeData | The size of the data (pointed to by ptrData). |
| [in,out] | ptrHash | Pointer to the hash-code result. The result will be of size 16 bytes. |
| hashSize | Size of the hash-code result pointed to by ptrHash. We need 16 bytes. |
- Returns
- The count of bytes that were written to in ptrHash as the MD5SUM-hash (always 16).
◆ CalcSplineDataFromPoints()
Calculates the spline coefficients from a list of control points.
- Parameters
-
| pointCnt | Number of control points. |
| getPoint | A functor which will be used to retrieve the control point's coordinates. |
- Returns
- The calculated spline data from the specified control points.
◆ CalcZoom() [1/2]
Calculate a zoom-factor from the physical- and logical size.
- Parameters
-
| logicalRect | The logical rectangle. |
| physicalSize | Physical size. |
- Returns
- The calculated zoom.
◆ CalcZoom() [2/2]
Calculate a zoom-factor from the physical- and logical size.
- Parameters
-
| logicalSize | The logical size. |
| physicalSize | The physical size. |
- Returns
- The calculated zoom.
◆ CharToDimension()
Convert the specifed single character to the corresponding dimension enum. The single character may be given uppercase or lowercase. In case that no corresponding dimension enum exists, DimensionIndex::invalid is returned.
- Parameters
-
| c | The "single char representation" of a dimension. |
- Returns
- A enum value representing the specified dimension if it exists,
DimensionIndex::invalid otherwise.
◆ Compare()
Compares two coordinate-objects to determine their relative ordering. The algorithm employed is: we check for all coordinates which are marked valid in a or b (in the order of the numerical value or the enum)...
- coordinateA(dim) is valid and coordinateB(dim) is invalid -> a > b
- coordinateA(dim) is invalid and coordinateB(dim) is valid -> a < b
- if both are valid, then the coordinate-values are determined and compared
- Parameters
-
| a | First coordinate to be compared. |
| b | Second coordinate to be compared. |
- Returns
- Negative if 'a' is less than 'b', 0 if they are equal, or positive if it is greater.
◆ CompressionModeToInformalString()
Retrieves an informal string representing the specified compression mode.
- Parameters
-
| compressionMode | The pixel-type. |
- Returns
- A pointer to a static string. Will always be non-null (even in case of an invalid value for
compressionMode).
◆ Create8BitLookUpTableFromGamma()
| static std::vector<std::uint8_t> libCZI::Utils::Create8BitLookUpTableFromGamma |
( |
int |
tableElementCnt, |
|
|
float |
blackPoint, |
|
|
float |
whitePoint, |
|
|
float |
gamma |
|
) |
| |
|
static |
Creates 8-bit look-up table from the specified gamma value. An exponential with the specified gamma is sampled between blackPoint and whitePoint (i. e. points left of blackPoint are set to 0 and right of whitePoint are set to 1).
- Parameters
-
| tableElementCnt | Number of points to sample - the result will have as many samples as specified here. |
| blackPoint | The black point. |
| whitePoint | The white point. |
| gamma | The gamma. |
- Returns
- The new 8-bit look up table generated from the spline. The number is elements is as specified by
tableElementCount.
◆ Create8BitLookUpTableFromSplines()
| static std::vector<std::uint8_t> libCZI::Utils::Create8BitLookUpTableFromSplines |
( |
int |
tableElementCnt, |
|
|
float |
blackPoint, |
|
|
float |
whitePoint, |
|
|
const std::vector< libCZI::IDisplaySettings::SplineData > & |
splineData |
|
) |
| |
|
static |
Creates an 8-bit look-up table from the specifed splines. A spline is sampled between blackPoint and whitePoint (i. e. points left of blackPoint are set to 0 and right of whitePoint are set to 1).
- Parameters
-
| tableElementCnt | Number of points to sample - the result will have as many samples as specified here. |
| blackPoint | The black point. |
| whitePoint | The white point. |
| splineData | Information describing the spline. |
- Returns
- The new 8-bit look up table generated from the spline. The number is elements is as specified by
tableElementCount.
◆ DimBoundsToString()
Get a string representation of the specified bounds.
- Parameters
-
- Returns
- A string representation of the specified bounds.
◆ DimCoordinateToString()
Get a string representation of the specified coordinate.
- Parameters
-
- Returns
- A string representation of the specified coordinate.
◆ DimensionToChar()
Convert the specifed dimension enum to the corresponding "single char representation". The returned character will be uppercase. If the specified dimension enum cannot be converted, '?' is returned.
- Parameters
-
- Returns
- A character representing the specified dimension.
◆ EnumAllCoordinates()
Enumerate all coordinates "contained" in the specified bounds. The specified function is called with all valid coordinates (which lie inside the bounds). The first argument to the function is a counter which increments for each generated coordinate (and starts with 0). If the function returns false, the enumeration is ended, and this function returns immediately with false.
- Parameters
-
| bounds | The bounds. |
| func | The function to be called with the generated coordinates. |
- Returns
- True if the enumeration completed, false if it was cancelled (by returning false from the callback).
◆ FillBitmap()
Fill the specified bitmap with the specified color.
- Parameters
-
| [in,out] | bm | The bitmap. |
| floatColor | The color. |
◆ HasSameDimensions()
Test whether the two specified coordinates have the same set of valid dimensions.
- Parameters
-
| a | The first coordinate-object to compare. |
| b | The second coordinate-object to compare. |
- Returns
- True if the two coordinates have the same set of valid dimensions, false otherwise.
◆ IndexSetFromString()
| static std::shared_ptr<libCZI::IIndexSet> libCZI::Utils::IndexSetFromString |
( |
const std::wstring & |
s | ) |
|
|
static |
Create an index-set object from a string representation. The string is a list of intervals, seperated by comma (','). It can be of the form "5", "17", "3-5", "-3-5". The string "inf" (meaning 'infinity') is recognized in order to express "all numbers up to" or "all numbers after" , e. g. "-inf-4" or "5-inf". In case of an invalid string, an LibCZIStringParseException exception is thrown.
- Parameters
-
| s | The string to convert to an index-set object. |
- Returns
- A newly create std::shared_ptr<libCZI::IIndexSet> object.
◆ NearestNeighborResize() [1/2]
Resize the specified bitmap to the specified width and height. This method employs a nearest-neighbor-scaling algorihm.
- Parameters
-
| [in] | bmSrc | The source bitmap. |
| dstWidth | Width of the destination. |
| dstHeight | Height of the destination. |
- Returns
- A std::shared_ptr<libCZI::IBitmapData > containing the scaled bitmap.
◆ NearestNeighborResize() [2/2]
Resize a ROI from the specified bitmap to the specified width and height. This method employs a nearest-neighbor-scaling algorihm.
- Parameters
-
| [in] | bmSrc | The source bitmap. |
| dstWidth | Width of the destination. |
| dstHeight | Height of the destination. |
| roiSrc | The ROI (in the source bitmap). |
| roiDest | The ROI (in the destination bitmap) |
- Returns
- A std::shared_ptr<libCZI::IBitmapData >
◆ PixelTypeToInformalString()
| static const char* libCZI::Utils::PixelTypeToInformalString |
( |
libCZI::PixelType |
pixeltype | ) |
|
|
static |
Retrieves an informal string representing the specified pixeltype.
- Parameters
-
- Returns
- A pointer to a static string. Will always be non-null (even in case of an invalid value for
pxltp.
◆ StringToDimCoordinate()
Convert the specified string into a dimension-coordinate instance.
- Parameters
-
| sz | The string to convert. |
| [out] | coord | If non-null and if the parsing was successful, the information will be put here. |
- Returns
- True if the string parsed successfully, false otherwise.
◆ TryDeterminePixelTypeForChannel()
Try to determine the pixel type for channel. This is done by looking at an (arbitrary) subblock within the specified channel. There are cases where this does not yield a result - e. g. if there is no subblock present with the specified channel-index.
- Parameters
-
| [in] | repository | The CZI-document. |
| channelIdx | The channel index. |
- Returns
- The pixeltype if it can be determined. If it cannot be determined reliably (e.g. there is no subblock with the specified channel-index), then PixelType::Invalid is returned.
The documentation for this class was generated from the following file: