1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/
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
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.
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>
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/
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
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
52
#ifndef __XLIB_RGB_H__
53
#define __XLIB_RGB_H__
55
/* Force ANSI C prototypes from X11 headers */
60
#include <X11/Xutil.h>
62
#include <X11/Intrinsic.h>
67
* If you are going to use this code somewhere other than mozilla
68
* you will need to set these defines. It's pretty easy for Intel
69
* but I'm not sure about other platforms.
71
#ifdef USE_MOZILLA_TYPES
72
/* prtypes contains definitions for uint32/int32 and uint16/int16 */
76
#define NS_TO_XXLIB_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
78
typedef unsigned int uint32;
80
typedef unsigned short uint16;
82
#endif /* USE_MOZILLA_TYPES */
84
typedef struct _XlibRgbCmap XlibRgbCmap;
85
typedef struct _XlibRgbHandle XlibRgbHandle;
88
unsigned int colors[256];
89
unsigned char lut[256]; /* for 8-bit modes */
96
XLIB_RGB_DITHER_NORMAL,
102
const char *handle_name;
103
int pseudogray; /* emulate GrayScale via PseudoColor visuals */
104
int install_colormap;
105
int disallow_image_tiling;
106
int disallow_mit_shmem;
108
XVisualInfo xtemplate;
113
xxlib_rgb_create_handle (Display *display, Screen *screen,
117
xxlib_rgb_destroy_handle (XlibRgbHandle *handle);
120
xxlib_rgb_xpixel_from_rgb (XlibRgbHandle *handle, uint32 rgb);
123
xxlib_rgb_gc_set_foreground (XlibRgbHandle *handle, GC gc, uint32 rgb);
126
xxlib_rgb_gc_set_background (XlibRgbHandle *handle, GC gc, uint32 rgb);
129
xxlib_draw_rgb_image (XlibRgbHandle *handle, Drawable drawable,
136
unsigned char *rgb_buf,
140
xxlib_draw_rgb_image_dithalign (XlibRgbHandle *handle, Drawable drawable,
147
unsigned char *rgb_buf,
153
xxlib_draw_rgb_32_image (XlibRgbHandle *handle, Drawable drawable,
164
xxlib_draw_gray_image (XlibRgbHandle *handle, Drawable drawable,
175
xxlib_rgb_cmap_new (XlibRgbHandle *handle, uint32 *colors, int n_colors);
178
xxlib_rgb_cmap_free (XlibRgbHandle *handle, XlibRgbCmap *cmap);
181
xxlib_draw_indexed_image (XlibRgbHandle *handle, Drawable drawable,
193
xxlib_draw_xprint_scaled_rgb_image( XlibRgbHandle *handle,
195
long paper_resolution,
196
long image_resolution,
203
unsigned char *rgb_buf,
206
/* Below are some functions which are primarily useful for debugging
207
and experimentation. */
209
xxlib_rgb_ditherable (XlibRgbHandle *handle);
212
xxlib_rgb_set_verbose (XlibRgbHandle *handle, Bool verbose);
215
xxlib_rgb_set_min_colors (XlibRgbHandle *handle, int min_colors);
218
xxlib_rgb_get_cmap (XlibRgbHandle *handle);
221
xxlib_rgb_get_visual (XlibRgbHandle *handle);
224
xxlib_rgb_get_visual_info (XlibRgbHandle *handle);
227
xxlib_rgb_get_depth (XlibRgbHandle *handle);
229
/* hint: if you don't how to obtain a handle - use |xxlib_find_handle()| :-) */
231
xxlib_rgb_get_display (XlibRgbHandle *handle);
234
xxlib_rgb_get_screen (XlibRgbHandle *handle);
237
xxlib_get_prec_from_mask(unsigned long);
240
xxlib_get_shift_from_mask(unsigned long);
242
/* default name - for cases where there is only one XlibRgbHandle required */
243
#define XXLIBRGB_DEFAULT_HANDLE ("xxlib-default")
246
xxlib_register_handle(const char *name, XlibRgbHandle *handle);
249
xxlib_deregister_handle(const char *name);
252
xxlib_find_handle(const char *name);
256
#endif /* !__XLIB_RGB_H__ */