summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2026-03-08 11:11:07 +0100
committerJörg Frings-Fürst <debian@jff.email>2026-03-08 11:11:07 +0100
commit210cc61ee4191465805a770881235c677041f929 (patch)
tree22dfc8a656a39b95dba2b537f11dcbe36b5c6f0c /src/util
parent7868ff68cff97b21fe6d8681f8bc0334849c4d38 (diff)
New upstream version 0.32.15upstream/0.32.15upstream
Diffstat (limited to 'src/util')
-rw-r--r--src/util/image.vala38
-rw-r--r--src/util/string.vala2
2 files changed, 35 insertions, 5 deletions
diff --git a/src/util/image.vala b/src/util/image.vala
index 5b78a50..e46233d 100644
--- a/src/util/image.vala
+++ b/src/util/image.vala
@@ -185,8 +185,39 @@ public Gdk.Point subtract_points(Gdk.Point p1, Gdk.Point p2) {
return result;
}
+Gdk.Pixbuf apply_alpha_channel(Gdk.Pixbuf source, bool strip = false) {
+ var dest = new Gdk.Pixbuf (source.colorspace, false, source.bits_per_sample, source.width, source.height);
+ uchar *sp = source.pixels;
+ uchar *dp = dest.pixels;
+
+ for (int j = 0; j < source.height; j++) {
+ uchar *s = sp;
+ uchar *d = dp;
+ uchar *end = s + 4 * source.width;
+ while (s < end) {
+ if (strip) {
+ d[0] = s[0];
+ d[1] = s[1];
+ d[2] = s[2];
+ } else {
+ double alpha = s[3] / 255.0;
+ d[0] = (uchar)Math.round((255.0 * (1.0 - alpha)) + (s[0] * alpha));
+ d[1] = (uchar)Math.round((255.0 * (1.0 - alpha)) + (s[1] * alpha));
+ d[2] = (uchar)Math.round((255.0 * (1.0 - alpha)) + (s[2] * alpha));
+ }
+ s += 4;
+ d += 3;
+ }
+
+ sp += source.rowstride;
+ dp += dest.rowstride;
+ }
+
+ return dest;
+}
+
// Converts XRGB/ARGB (Cairo)-formatted pixels to RGBA (GDK).
-void fix_cairo_pixbuf(Gdk.Pixbuf pixbuf) {
+void argb2rgba(Gdk.Pixbuf pixbuf) {
uchar *gdk_pixels = pixbuf.pixels;
for (int j = 0 ; j < pixbuf.height; ++j) {
uchar *p = gdk_pixels;
@@ -274,9 +305,8 @@ Gdk.Pixbuf rotate_arb(Gdk.Pixbuf source_pixbuf, double angle) {
// prepare the newly-drawn image for use by
// the rest of the pipeline.
- fix_cairo_pixbuf(dest_pixbuf);
-
- return dest_pixbuf;
+ argb2rgba(dest_pixbuf);
+ return apply_alpha_channel(dest_pixbuf, true);
}
/**
diff --git a/src/util/string.vala b/src/util/string.vala
index 5ca4680..521e2ba 100644
--- a/src/util/string.vala
+++ b/src/util/string.vala
@@ -203,7 +203,7 @@ public string remove_diacritics(string istring) {
case UnicodeType.FORMAT:
case UnicodeType.UNASSIGNED:
case UnicodeType.NON_SPACING_MARK:
- case UnicodeType.COMBINING_MARK:
+ case UnicodeType.SPACING_MARK:
case UnicodeType.ENCLOSING_MARK:
// Ignore those
continue;