summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Dennedy <dan@dennedy.org>2016-10-09 19:12:52 (GMT)
committer GitHub <noreply@github.com>2016-10-09 19:12:52 (GMT)
commit8aff9f1ee3d032f549912d6d124902ec6969ac24 (patch)
treea357713d217caebd3ab08324a9497e172fb5c785
parenta244f0c8a0655f6435a13a8e4e2f6ad9b6a1eaa9 (diff)
parent9cad7c579af7ef919a29fc007eaa008466078aec (diff)
Merge pull request #4 from j-b-m/master
Fix cairo mixer image corruption
-rw-r--r--include/frei0r_cairo.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/frei0r_cairo.h b/include/frei0r_cairo.h
index cffbb0b..fea3b7d 100644
--- a/include/frei0r_cairo.h
+++ b/include/frei0r_cairo.h
@@ -22,6 +22,7 @@
#include <cairo.h>
#include <string.h>
+#include "frei0r_math.h"
/**
* String identifiers for gradient types available using Cairo.
@@ -254,9 +255,9 @@ void frei0r_cairo_unpremultiply_rgba (unsigned char *rgba, int pixels)
while ( --i ) {
register unsigned char a = rgba[3];
if (a != 0) {
- rgba[0] = ( rgba[0] << 8 ) / a;
- rgba[1] = ( rgba[1] << 8 ) / a;
- rgba[2] = ( rgba[2] << 8 ) / a;
+ rgba[0] = MIN(( rgba[0] << 8 ) / a, 255);
+ rgba[1] = MIN(( rgba[1] << 8 ) / a, 255);
+ rgba[2] = MIN(( rgba[2] << 8 ) / a, 255);
}
rgba += 4;
}