projects
/
platform
/
upstream
/
pixman.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e291764
)
test/utils.c: Clip values to the [0, 255] interval
author
Søren Sandmann Pedersen
<ssp@redhat.com>
Thu, 5 Apr 2012 04:42:55 +0000
(
00:42
-0400)
committer
Søren Sandmann Pedersen
<ssp@redhat.com>
Fri, 20 Apr 2012 14:17:13 +0000
(10:17 -0400)
Unpremultiplying a superluminescent pixel can result in values greater
than 255.
test/utils.c
patch
|
blob
|
history
diff --git
a/test/utils.c
b/test/utils.c
index
cc0365a
..
c1bf6dc
100644
(file)
--- a/
test/utils.c
+++ b/
test/utils.c
@@
-358,9
+358,16
@@
a8r8g8b8_to_rgba_np (uint32_t *dst, uint32_t *src, int n_pixels)
if (a != 0)
{
- r = (r * 255) / a;
- g = (g * 255) / a;
- b = (b * 255) / a;
+#define DIVIDE(c, a) \
+ do \
+ { \
+ int t = ((c) * 255) / a; \
+ (c) = t < 0? 0 : t > 255? 255 : t; \
+ } while (0)
+
+ DIVIDE (r, a);
+ DIVIDE (g, a);
+ DIVIDE (b, a);
}
*dst8++ = r;