blob: 6d36589e9e30d957d154ddd00dedfe66cc89d12e (
plain) (
tree)
|
|
diff --git a/backend/genesys/image_pixel.cpp b/backend/genesys/image_pixel.cpp
index 1b83e127d..1ebba7fe0 100644
--- a/backend/genesys/image_pixel.cpp
+++ b/backend/genesys/image_pixel.cpp
@@ -23,6 +23,7 @@
#include "image.h"
#include <array>
+#include <cmath>
namespace genesys {
@@ -184,7 +185,7 @@ void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel, PixelForma
float val = (pixel.r >> 8) * 0.3f;
val += (pixel.g >> 8) * 0.59f;
val += (pixel.b >> 8) * 0.11f;
- data[x] = static_cast<std::uint16_t>(val);
+ data[x] = static_cast<std::uint16_t>(roundf(val));
return;
}
case PixelFormat::I16: {
@@ -192,7 +193,7 @@ void set_pixel_to_row(std::uint8_t* data, std::size_t x, Pixel pixel, PixelForma
float val = pixel.r * 0.3f;
val += pixel.g * 0.59f;
val += pixel.b * 0.11f;
- auto val16 = static_cast<std::uint16_t>(val);
+ auto val16 = static_cast<std::uint16_t>(roundf(val));
data[x] = val16 & 0xff;
data[x + 1] = (val16 >> 8) & 0xff;
return;
|