From fef45dfc302f1b317b12d6bc9005c977e074f020 Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Thu, 24 Jan 2019 20:37:33 +0100 Subject: [PATCH] gr: clamp rgb values --- src/backends/gr.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 1d4fbca6..f7ba5e04 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -1182,13 +1182,13 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) z = z[xinds, yinds] xmin, xmax = ignorenan_extrema(series[:x]); ymin, ymax = ignorenan_extrema(series[:y]) if eltype(z) <: Colors.AbstractGray - grey = round.(UInt8, float(z) * 255) + grey = round.(UInt8, clamp.(float(z) * 255, 0, 255)) rgba = map(c -> UInt32( 0xff000000 + UInt(c)<<16 + UInt(c)<<8 + UInt(c) ), grey) else - rgba = map(c -> UInt32( round(UInt, alpha(c) * 255) << 24 + - round(UInt, blue(c) * 255) << 16 + - round(UInt, green(c) * 255) << 8 + - round(UInt, red(c) * 255) ), z) + rgba = map(c -> UInt32( round(UInt, clamp(alpha(c) * 255, 0, 255)) << 24 + + round(UInt, clamp(blue(c) * 255, 0, 255)) << 16 + + round(UInt, clamp(green(c) * 255, 0, 255)) << 8 + + round(UInt, clamp(red(c) * 255, 0, 255)) ), z) end GR.drawimage(xmin, xmax, ymax, ymin, w, h, rgba) end