"Initial commit to Gerrit"
[profile/ivi/gdk-pixbuf.git] / contrib / gdk-pixbuf-xlib / gdk-pixbuf-xlibrgb.h
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2  *
3  * The contents of this file are subject to the Mozilla Public License
4  * Version 1.1 (the "MPL"); you may not use this file except in
5  * compliance with the MPL.  You may obtain a copy of the MPL at
6  * http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the MPL is distributed on an "AS IS" basis,
9  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
10  * for the specific language governing rights and limitations under the
11  * MPL.
12  *
13  * Alternatively, the contents of this file may be used under the
14  * terms of the GNU Library General Public License (the "LGPL"), in
15  * which case the provisions of the LGPL are applicable instead of
16  * those above.  If you wish to allow use of your version of this file
17  * only under the terms of the LGPL and not to allow others to use
18  * your version of this file under the MPL, indicate your decision by
19  * deleting the provisions above and replace them with the notice and
20  * other provisions required by the LGPL.  If you do not delete the
21  * provisions above, a recipient may use your version of this file
22  * under either the MPL or the LGPL.
23  */
24
25 /*
26  * This code is derived from GdkRgb.
27  * For more information on GdkRgb, see http://www.levien.com/gdkrgb/
28  * Raph Levien <raph@acm.org>
29  */
30
31 /* Ported by Christopher Blizzard to Xlib.  With permission from the
32  * original authors of this file, the contents of this file are also
33  * redistributable under the terms of the Mozilla Public license.  For
34  * information about the Mozilla Public License, please see the
35  * license information at http://www.mozilla.org/MPL/
36  */
37
38 /* This code is copyright the following authors:
39  * Raph Levien          <raph@acm.org>
40  * Manish Singh         <manish@gtk.org>
41  * Tim Janik            <timj@gtk.org>
42  * Peter Mattis         <petm@xcf.berkeley.edu>
43  * Spencer Kimball      <spencer@xcf.berkeley.edu>
44  * Josh MacDonald       <jmacd@xcf.berkeley.edu>
45  * Christopher Blizzard <blizzard@redhat.com>
46  * Owen Taylor          <otaylor@redhat.com>
47  * Shawn T. Amundson    <amundson@gtk.org>
48 */
49
50
51 #ifndef __XLIB_RGB_H__
52 #define __XLIB_RGB_H__
53
54 #include <glib.h>
55
56 G_BEGIN_DECLS
57
58 #include <X11/Xlib.h>
59 #include <X11/Xutil.h>
60
61 /**
62  * XlibRgbCmap:
63  * @colors: FIXME.
64  * @lut: FIXME.
65  * 
66  *     FIXME: Describe this.
67  */
68 typedef struct _XlibRgbCmap XlibRgbCmap;
69 struct _XlibRgbCmap {
70   unsigned int colors[256];
71   unsigned char lut[256]; /* for 8-bit modes */
72 };
73
74 void
75 xlib_rgb_init (Display *display, Screen *screen);
76 void
77 xlib_rgb_init_with_depth (Display *display, Screen *screen, int prefDepth);
78
79 unsigned long
80 xlib_rgb_xpixel_from_rgb (guint32 rgb);
81
82 void
83 xlib_rgb_gc_set_foreground (GC gc, guint32 rgb);
84
85 void
86 xlib_rgb_gc_set_background (GC gc, guint32 rgb);
87
88 /**
89  * XlibRgbDither:
90  * @XLIB_RGB_DITHER_NONE: Specifies no dithering.
91  * @XLIB_RGB_DITHER_NORMAL: Specifies dithering only on pseudocolor
92  *  displays.
93  * @XLIB_RGB_DITHER_MAX: Specifies dithering on high color displays.
94  * 
95  * These values are used to specify which dithering method should be
96  * used.  <symbol>XLIB_RGB_DITHER_NONE</symbol> will use no dithering
97  * and simply map the colors in an RGB buffer to the closest colors
98  * that the display can provide.
99  * <symbol>XLIB_RGB_DITHER_NORMAL</symbol> will provide dithering
100  * only on pseudocolor displays.
101  * <symbol>XLIB_RGB_DITHER_MAX</symbol> will provide dithering on
102  * pseudocolor and 16-bit truecolor or &ldquo;high color&rdquo;
103  * displays.
104  */
105 typedef enum
106 {
107   XLIB_RGB_DITHER_NONE,
108   XLIB_RGB_DITHER_NORMAL,
109   XLIB_RGB_DITHER_MAX
110 } XlibRgbDither;
111
112 void
113 xlib_draw_rgb_image (Drawable drawable,
114                      GC gc,
115                      int x,
116                      int y,
117                      int width,
118                      int height,
119                      XlibRgbDither dith,
120                      unsigned char *rgb_buf,
121                      int rowstride);
122
123 void
124 xlib_draw_rgb_image_dithalign (Drawable drawable,
125                                GC gc,
126                                int x,
127                                int y,
128                                int width,
129                                int height,
130                                XlibRgbDither dith,
131                                unsigned char *rgb_buf,
132                                int rowstride,
133                                int xdith,
134                                int ydith);
135
136 void
137 xlib_draw_rgb_32_image (Drawable drawable,
138                         GC gc,
139                         int x,
140                         int y,
141                         int width,
142                         int height,
143                         XlibRgbDither dith,
144                         unsigned char *buf,
145                         int rowstride);
146
147 void
148 xlib_draw_gray_image (Drawable drawable,
149                       GC gc,
150                       int x,
151                       int y,
152                       int width,
153                       int height,
154                       XlibRgbDither dith,
155                       unsigned char *buf,
156                       int rowstride);
157
158 XlibRgbCmap *
159 xlib_rgb_cmap_new (guint32 *colors, int n_colors);
160
161 void
162 xlib_rgb_cmap_free (XlibRgbCmap *cmap);
163
164 void
165 xlib_draw_indexed_image (Drawable drawable,
166                          GC gc,
167                          int x,
168                          int y,
169                          int width,
170                          int height,
171                          XlibRgbDither dith,
172                          unsigned char *buf,
173                          int rowstride,
174                          XlibRgbCmap *cmap);
175
176 /* Below are some functions which are primarily useful for debugging
177    and experimentation. */
178 Bool
179 xlib_rgb_ditherable (void);
180
181 void
182 xlib_rgb_set_verbose (Bool verbose);
183
184 /* experimental colormap stuff */
185 void
186 xlib_rgb_set_install (Bool install);
187
188 void
189 xlib_rgb_set_min_colors (int min_colors);
190
191 Colormap
192 xlib_rgb_get_cmap (void);
193
194 Visual *
195 xlib_rgb_get_visual (void);
196
197 XVisualInfo *
198 xlib_rgb_get_visual_info (void);
199
200 int
201 xlib_rgb_get_depth (void);
202
203 Display *
204 xlib_rgb_get_display (void);
205
206 Screen *
207 xlib_rgb_get_screen (void);
208
209 G_END_DECLS
210
211 #endif /* __XLIB_RGB_H__ */