Skip to content

Commit 99288e1

Browse files
committed
Fix color for SVG rendering.
Good ol' RGBA vs BGRA issue.
1 parent a666abe commit 99288e1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: src/svg-image-source.cc

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <librsvg/rsvg.h>
2020
#include <stdlib.h>
2121

22+
#include <algorithm>
23+
2224
#include "framebuffer.h"
2325

2426
namespace timg {
@@ -84,6 +86,11 @@ bool SVGImageSource::LoadAndScale(const DisplayOptions &opts, int, int) {
8486
cairo_surface_destroy(surface);
8587
g_object_unref(svg);
8688

89+
// Cairo stores A (high-byte), R, G, B (low-byte). We need ABGR.
90+
for (rgba_t &pixel : *image_) {
91+
std::swap(pixel.r, pixel.b);
92+
}
93+
8794
// TODO: for non-1:1 aspect ratio of the output (e.g. pixelation=quarter),
8895
// the resulting aspect ratio is squished, as we have to do the
8996
// distortion ourself.

0 commit comments

Comments
 (0)