GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_dpi.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2/*
3 * Copyright (C) 2023 Cyril Hrubis <metan@ucw.cz>
4 */
5
6#ifndef BACKENDS_GP_DPI_H
7#define BACKENDS_GP_DPI_H
8
9#include <core/gp_debug.h>
10
20static inline unsigned int gp_dpi_from_size(unsigned int w, unsigned int w_mm,
21 unsigned int h, unsigned int h_mm)
22{
23 unsigned int dpi = ((w * 25.4) / w_mm + (h * 25.4) / h_mm + 1)/2;
24
25 GP_DEBUG(1, "Resolution %ux%u - %ummx%umm - dpi %u", w, h, w_mm, h_mm, dpi);
26
27 return dpi;
28}
29
36static inline float gp_dpi_to_ppmm(unsigned int dpi)
37{
38 return dpi / 25.4;
39}
40
47static inline gp_size gp_dpi_mm_to_px(unsigned int dpi, float mm)
48{
49 return gp_dpi_to_ppmm(dpi) * mm + 0.5;
50}
51
52#endif /* BACKENDS_GP_DPI_H */
unsigned int gp_size
Integer type for sizes i.e. w, h, ...
Definition gp_types.h:24
A debug message layer.
#define GP_DEBUG(level,...)
A debug printf-like macro.
Definition gp_debug.h:88