summaryrefslogtreecommitdiff
path: root/gtk2_ardour/utils.cc
diff options
context:
space:
mode:
authorNick Mainsbridge <beatroute@iprimus.com.au>2009-05-19 14:38:37 +0000
committerNick Mainsbridge <beatroute@iprimus.com.au>2009-05-19 14:38:37 +0000
commit337fae8183800ecd4967206507e16f285b34e88d (patch)
tree7f30c96ce03ce25dd13270d1193dd7a0d1b21535 /gtk2_ardour/utils.cc
parentc04d9d1975402c514d2feb44d997f0941d1f34c3 (diff)
Fix record crash, use pixfufs instead of canvas text in markers, use leftmost_frame instead of querying canvas coords when scrolling (speeds up canvas scrolling somewhat).
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5101 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r--gtk2_ardour/utils.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index 2e98fad06e..d4228781de 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -758,3 +758,34 @@ possibly_translate_keyval_to_make_legal_accelerator (uint32_t& keyval)
return false;
}
+inline guint8
+convert_color_channel (guint8 src,
+ guint8 alpha)
+{
+ return alpha ? ((guint (src) << 8) - src) / alpha : 0;
+}
+
+void
+convert_bgra_to_rgba (guint8 const* src,
+ guint8* dst,
+ int width,
+ int height)
+{
+ guint8 const* src_pixel = src;
+ guint8* dst_pixel = dst;
+
+ for (int y = 0; y < height; y++)
+ for (int x = 0; x < width; x++)
+ {
+ dst_pixel[0] = convert_color_channel (src_pixel[2],
+ src_pixel[3]);
+ dst_pixel[1] = convert_color_channel (src_pixel[1],
+ src_pixel[3]);
+ dst_pixel[2] = convert_color_channel (src_pixel[0],
+ src_pixel[3]);
+ dst_pixel[3] = src_pixel[3];
+
+ dst_pixel += 4;
+ src_pixel += 4;
+ }
+}