[gthumb: 40/129] CAIRO_SET_RGBA: no need to multiply if alpha is 255
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb: 40/129] CAIRO_SET_RGBA: no need to multiply if alpha is 255
- Date: Wed, 27 Apr 2011 20:53:44 +0000 (UTC)
commit 1f7e49954574ded2013c24fced1de77eeda11c97
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Apr 17 21:50:19 2011 +0200
CAIRO_SET_RGBA: no need to multiply if alpha is 255
gthumb/cairo-utils.h | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/gthumb/cairo-utils.h b/gthumb/cairo-utils.h
index de78f50..d4c38ca 100644
--- a/gthumb/cairo-utils.h
+++ b/gthumb/cairo-utils.h
@@ -62,11 +62,18 @@
#define CAIRO_SET_RGBA(pixel, red, green, blue, alpha) \
G_STMT_START { \
- double factor = (gdouble) (alpha) / 0xff; \
- pixel[CAIRO_RED] = factor * (red); \
- pixel[CAIRO_GREEN] = factor * (green); \
- pixel[CAIRO_BLUE] = factor * (blue); \
- pixel[CAIRO_ALPHA] = alpha; \
+ pixel[CAIRO_ALPHA] = (alpha); \
+ if (pixel[CAIRO_ALPHA] == 0xff) { \
+ pixel[CAIRO_RED] = (red); \
+ pixel[CAIRO_GREEN] = (green); \
+ pixel[CAIRO_BLUE] = (blue); \
+ } \
+ else { \
+ double factor = (double) pixel[CAIRO_ALPHA] / 0xff; \
+ pixel[CAIRO_RED] = factor * (red); \
+ pixel[CAIRO_GREEN] = factor * (green); \
+ pixel[CAIRO_BLUE] = factor * (blue); \
+ } \
} G_STMT_END
#define CAIRO_GET_RGB(pixel, red, green, blue) \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]