mirror of
https://github.com/gnuradio/gnuradio-companion.git
synced 2025-12-11 04:34:56 -06:00
GRC/Screenshots: create ImageSurface with int dimensions
Since cairo.ImageSurface is pixel-based, it only accepts integer dimensions. No need to round up – proper rounding and padding make this quite safe. Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
This commit is contained in:
parent
75bf01eeca
commit
f302cf5eee
@ -108,7 +108,13 @@ def make_screenshot(flow_graph, file_path, transparent_bg=False):
|
|||||||
height = y_max - y_min + 2 * padding
|
height = y_max - y_min + 2 * padding
|
||||||
|
|
||||||
if file_path.endswith('.png'):
|
if file_path.endswith('.png'):
|
||||||
psurf = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
|
# ImageSurface is pixel-based, so dimensions need to be integers
|
||||||
|
# We don't round up here, because our padding should allow for up
|
||||||
|
# to half a pixel size in loss of image area without optically bad
|
||||||
|
# effects
|
||||||
|
psurf = cairo.ImageSurface(cairo.FORMAT_ARGB32,
|
||||||
|
round(width),
|
||||||
|
round(height))
|
||||||
elif file_path.endswith('.pdf'):
|
elif file_path.endswith('.pdf'):
|
||||||
psurf = cairo.PDFSurface(file_path, width, height)
|
psurf = cairo.PDFSurface(file_path, width, height)
|
||||||
elif file_path.endswith('.svg'):
|
elif file_path.endswith('.svg'):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user