Skip to content

Commit

Permalink
Fix color for SVG rendering.
Browse files Browse the repository at this point in the history
Good ol' RGBA vs BGRA issue.
  • Loading branch information
hzeller committed Dec 20, 2023
1 parent a666abe commit 99288e1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/svg-image-source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <librsvg/rsvg.h>
#include <stdlib.h>

#include <algorithm>

#include "framebuffer.h"

namespace timg {
Expand Down Expand Up @@ -84,6 +86,11 @@ bool SVGImageSource::LoadAndScale(const DisplayOptions &opts, int, int) {
cairo_surface_destroy(surface);
g_object_unref(svg);

// Cairo stores A (high-byte), R, G, B (low-byte). We need ABGR.
for (rgba_t &pixel : *image_) {
std::swap(pixel.r, pixel.b);
}

// TODO: for non-1:1 aspect ratio of the output (e.g. pixelation=quarter),
// the resulting aspect ratio is squished, as we have to do the
// distortion ourself.
Expand Down

0 comments on commit 99288e1

Please sign in to comment.