blob: 64b7dca0237a6d3cd83af988625596143f5bcf45 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
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
@@ -46,6 +46,7 @@
#include "image.h"
#include <array>
+#include <cmath>
namespace genesys {
@@ -207,7 +208,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: {
@@ -215,7 +216,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;
|