Graphviz 13.0.0~dev.20250121.0651
|
Arithmetic helper functions. More...
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
Go to the source code of this file.
Enumerations | |
enum | { BYTES_PER_PIXEL = 4 } |
byte length of data per pixel in image data buffers More... | |
Functions | |
static int | fcmp (double a, double b) |
comparator for doubles | |
static int | imax (int a, int b) |
maximum of two integers | |
static int | imin (int a, int b) |
minimum of two integers | |
static bool | is_exactly_equal (double a, double b) |
are two values precisely the same? | |
static bool | is_exactly_zero (double v) |
is a value precisely 0.0? | |
static int | scale_clamp (int original, double scale) |
scale up or down a non-negative integer, clamping to [0, INT_MAX] | |
static void | argb2rgba (size_t width, size_t height, unsigned char *data) |
|
inlinestatic |
in-place conversion of ARGB32 big endian to RGBA32 little endian
Image data originating from sources like Cairo comes in a 4-byte-per-pixel format ordered {blue, green, red, alpha}. Some output libraries/devices instead consume a 4-byte-per-pixel format ordered {red, green, blue, alpha}. This function converts the former to the latter.
It is confusing to refer to these formats as ARGB32 and RGBA32 when the first is big endian and the second is little endian, and thus the mappings of letters in the acronym to bytes in memory are opposites. Nevertheless that appears to be what is in common usage.
width | Width of the image in pixels |
height | Height of the image in pixels |
data | [inout] Image data in ARGB32 format on entry and RGBA32 format on exit |
Definition at line 105 of file gv_math.h.
References BYTES_PER_PIXEL, and NULL.
Referenced by kitty_format().
|
inlinestatic |
Definition at line 14 of file gv_math.h.
Referenced by countHorzCross(), and countVertCross().
|
inlinestatic |
Definition at line 25 of file gv_math.h.
Referenced by agerr_va().
|
inlinestatic |
Definition at line 28 of file gv_math.h.
Referenced by common_init_node(), dfs(), dfs(), make_map_internal(), node_distinct_coloring_internal2(), QuadTree_get_nearest(), QuadTree_get_nearest_internal(), and sfprint().
|
inlinestatic |
This function should only be used when you know you want comparison with no tolerance, which is rare. Floating-point arithmetic accumulates imprecision, so equality comparisons should generally include a non-zero tolerance to account for this. In general, this function is only applicable for checking things like “is this variable unchanged since a previous assignment from a literal?”
a | First operand to comparison |
b | Second operand to comparison |
Definition at line 44 of file gv_math.h.
Referenced by is_exactly_zero(), is_set(), pango_textlayout(), point_init(), poly_init(), rgb2hsv(), and routesplines_().
|
inlinestatic |
This function should only be used when you know you want comparison with no tolerance, which is rare. Floating-point arithmetic accumulates imprecision, so equality comparisons should generally include a non-zero tolerance to account for this. Valid double
representations even include -0.0, for which this function will return false. In general, this function is only applicable for checking things like “is this variable unchanged since a previous assignment from the literal 0
?” or “did this value we parsed from user input originate from the string "0.0"?”
v | Value to check |
Definition at line 63 of file gv_math.h.
References is_exactly_equal().
Referenced by dotneato_args_initialize(), emit_begin_node(), get_inputscale(), isBox(), isRect(), poly_init(), and poly_inside().
|
inlinestatic |