oops, I shifted the wrong value.
[swfdec.git] / swfdec / swfdec_color.h
blob6ec584288d0372919c3daff4308914855d3fa0ac
1 /* Swfdec
2 * Copyright (C) 2003-2006 David Schleef <ds@schleef.org>
3 * 2005-2006 Eric Anholt <eric@anholt.net>
4 * 2006-2007 Benjamin Otte <otte@gnome.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA
22 #ifndef __SWFDEC_COLOR_H__
23 #define __SWFDEC_COLOR_H__
25 #include <swfdec/swfdec_types.h>
27 G_BEGIN_DECLS
29 struct _SwfdecColorTransform {
30 gboolean mask; /* TRUE if this is a mask - masks are always black */
31 /* naming here is taken from ActionScript, where ?a is the multiplier and ?b the offset */
32 int ra, rb, ga, gb, ba, bb, aa, ab;
35 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
36 #define SWFDEC_COLOR_INDEX_ALPHA (3)
37 #define SWFDEC_COLOR_INDEX_RED (2)
38 #define SWFDEC_COLOR_INDEX_GREEN (1)
39 #define SWFDEC_COLOR_INDEX_BLUE (0)
40 #elif G_BYTE_ORDER == G_BIG_ENDIAN
41 #define SWFDEC_COLOR_INDEX_ALPHA (0)
42 #define SWFDEC_COLOR_INDEX_RED (1)
43 #define SWFDEC_COLOR_INDEX_GREEN (2)
44 #define SWFDEC_COLOR_INDEX_BLUE (3)
45 #else
46 #error "Unknown byte order"
47 #endif
49 #define SWFDEC_COLOR_COMBINE(r,g,b,a) ((SwfdecColor) (((a)<<24) | ((r)<<16) | ((g)<<8) | (b)))
50 #define SWFDEC_COLOR_OPAQUE(color) ((SwfdecColor) ((color) | SWFDEC_COLOR_COMBINE (0, 0, 0, 0xFF)))
51 #define SWFDEC_COLOR_ALPHA(x) (((x)>>24)&0xff)
52 #define SWFDEC_COLOR_RED(x) (((x)>>16)&0xff)
53 #define SWFDEC_COLOR_GREEN(x) (((x)>>8)&0xff)
54 #define SWFDEC_COLOR_BLUE(x) ((x)&0xff)
56 #define SWFDEC_COLOR_WHITE SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0xFF)
58 SwfdecColor swfdec_color_apply_morph (SwfdecColor start, SwfdecColor end, guint ratio);
59 void swfdec_color_set_source (cairo_t *cr, SwfdecColor color);
60 void swfdec_color_transform_init_identity (SwfdecColorTransform * trans);
61 void swfdec_color_transform_init_mask (SwfdecColorTransform * trans);
62 void swfdec_color_transform_init_color (SwfdecColorTransform *trans, SwfdecColor color);
63 gboolean swfdec_color_transform_is_identity (const SwfdecColorTransform * trans);
64 gboolean swfdec_color_transform_is_alpha (const SwfdecColorTransform * trans);
65 #define swfdec_color_transform_is_mask(trans) ((trans)->mask)
66 void swfdec_color_transform_chain (SwfdecColorTransform *dest,
67 const SwfdecColorTransform *last, const SwfdecColorTransform *first);
68 SwfdecColor swfdec_color_apply_transform (SwfdecColor in,
69 const SwfdecColorTransform * trans);
70 SwfdecColor swfdec_color_apply_transform_premultiplied (SwfdecColor in,
71 const SwfdecColorTransform * trans);
73 void swfdec_matrix_ensure_invertible (cairo_matrix_t *matrix, cairo_matrix_t *inverse);
74 double swfdec_matrix_get_xscale (const cairo_matrix_t *matrix);
75 double swfdec_matrix_get_yscale (const cairo_matrix_t *matrix);
76 double swfdec_matrix_get_rotation (const cairo_matrix_t *matrix);
77 void swfdec_matrix_morph (cairo_matrix_t *dest, const cairo_matrix_t *start,
78 const cairo_matrix_t *end, guint ratio);
81 G_END_DECLS
82 #endif