diff options
| author | Jörg Frings-Fürst <debian@jff.email> | 2026-03-09 18:19:48 +0100 |
|---|---|---|
| committer | Jörg Frings-Fürst <debian@jff.email> | 2026-03-09 18:19:48 +0100 |
| commit | b11befe1c9ea84969ebd418e96f7209b772b58d0 (patch) | |
| tree | 4cee94cb12ad4dd24253c2a111b87577f50ed80d /src/util | |
| parent | d048b2c970f6182a2201b5ba6c29d0d155abc22b (diff) | |
| parent | 8656a544ddcf098e10df1430eecb75902dbc7999 (diff) | |
Merge branch 'release/debian/0.32.15-1'HEADdebian/0.32.15-1master
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/image.vala | 38 | ||||
| -rw-r--r-- | src/util/string.vala | 2 |
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; |
