output: use doubles when converting in out_colour_get_rgb()

and `out_colour_get_cmyk()`, to lessen chances of rounding
  errors (in particular for VC6)
test_large: fix regression in change to test for formatting
  `uint64_t` for `printf()`
win32/README: update MinGW/MSYS Qt version
This commit is contained in:
gitlost 2024-01-19 09:28:03 +00:00
parent 57fac4048d
commit 7c1bdba8ae
8 changed files with 33 additions and 32 deletions

View file

@ -1,7 +1,7 @@
/* filemem.c - write to file/memory abstraction */
/*
libzint - the open source barcode library
Copyright (C) 2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2023-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -287,7 +287,7 @@ static int fm_vprintf(struct filemem *restrict const fmp, const char *fmt, va_li
return 1;
}
/* `fprintf()` to memory or file, returning 1 on success, 0 on failure */
/* `fprintf()` to file or memory, returning 1 on success, 0 on failure */
INTERNAL int fm_printf(struct filemem *restrict const fmp, const char *fmt, ...) {
va_list ap;
int ret;

View file

@ -1,7 +1,7 @@
/* filemem.h - write to file/memory abstraction */
/*
libzint - the open source barcode library
Copyright (C) 2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2023-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -67,7 +67,7 @@ INTERNAL int fm_putc(const int ch, struct filemem *restrict const fmp);
/* `fputs()` to file or memory, returning 1 on success, 0 on failure */
INTERNAL int fm_puts(const char *str, struct filemem *restrict const fmp);
/* `fprintf()` to memory or file, returning 1 on success, 0 on failure */
/* `fprintf()` to file or memory, returning 1 on success, 0 on failure */
INTERNAL int fm_printf(struct filemem *restrict const fmp, const char *format, ...);
/* Output float without trailing zeroes to `fmp` with decimal pts `dp` (precision), returning 1 on success, 0 on

View file

@ -129,13 +129,13 @@ INTERNAL int out_colour_get_rgb(const char *colour, unsigned char *red, unsigned
black = 100 - to_int((const unsigned char *) (comma3 + 1), (int) strlen(comma3 + 1));
val = 100 - to_int((const unsigned char *) colour, (int) (comma1 - colour)); /* Cyan */
*red = (int) roundf((0xFF * val * black) / 10000.0f);
*red = (int) round((0xFF * val * black) / 10000.0);
val = 100 - to_int((const unsigned char *) (comma1 + 1), (int) (comma2 - (comma1 + 1))); /* Magenta */
*green = (int) roundf((0xFF * val * black) / 10000.0f);
*green = (int) round((0xFF * val * black) / 10000.0);
val = 100 - to_int((const unsigned char *) (comma2 + 1), (int) (comma3 - (comma2 + 1))); /* Yellow */
*blue = (int) roundf((0xFF * val * black) / 10000.0f);
*blue = (int) round((0xFF * val * black) / 10000.0);
if (alpha) {
*alpha = 0xFF;
@ -176,10 +176,10 @@ INTERNAL int out_colour_get_cmyk(const char *colour, int *cyan, int *magenta, in
*cyan = *magenta = *yellow = 0;
*black = 100;
} else {
*cyan = (int) roundf((k - red) * 100.0f / k);
*magenta = (int) roundf((k - green) * 100.0f / k);
*yellow = (int) roundf((k - blue) * 100.0f / k);
*black = (int) roundf(((0xFF - k) * 100.0f) / 0xFF);
*cyan = (int) round((k - red) * 100.0 / k);
*magenta = (int) round((k - green) * 100.0 / k);
*yellow = (int) round((k - blue) * 100.0 / k);
*black = (int) round(((0xFF - k) * 100.0) / 0xFF);
}
if (rgb_alpha) {

View file

@ -43,9 +43,10 @@
# if defined(__clang__)
# pragma GCC diagnostic ignored "-Wformat-non-iso"
# elif defined(__GNUC__)
# pragma GCC diagnostic ignored "-Wformat" /* Unfortunately doesn't seem to be way to only avoid non-ISO warnings */
# pragma GCC diagnostic ignored "-Wformat" /* Doesn't seem to be way to only avoid non-ISO warnings */
# endif
#elif (defined(__WORDSIZE) && __WORDSIZE == 32) || (defined(ULONG_MAX) && ULONG_MAX <= 0xFFFFFFFF)
#elif (defined(__WORDSIZE) && __WORDSIZE == 32) || (defined(ULONG_MAX) && ULONG_MAX <= 0xFFFFFFFF) \
|| defined(__APPLE__) || defined(__OpenBSD__)
# define LX_FMT "ll"
#else
# define LX_FMT "l"