Commit d18abf42 authored by Benjamin Otte's avatar Benjamin Otte

API: Get rid of GdkRGB

parent 17b8bee1
......@@ -28,7 +28,6 @@
<xi:include href="xml/drawing.xml" />
<xi:include href="xml/pixmaps.xml" />
<xi:include href="xml/rgb.xml" />
<xi:include href="xml/images.xml" />
<xi:include href="xml/pixbufs.xml" />
......
......@@ -89,7 +89,6 @@ gdk_notify_type_get_type
gdk_overlap_type_get_type
gdk_property_state_get_type
gdk_prop_mode_get_type
gdk_rgb_dither_get_type
gdk_scroll_direction_get_type
gdk_setting_action_get_type
gdk_status_get_type
......@@ -313,40 +312,6 @@ GdkImageClass
gdk_image_get_type
</SECTION>
<SECTION>
<TITLE>GdkRGB</TITLE>
<FILE>rgb</FILE>
<SUBSECTION>
gdk_draw_rgb_image
gdk_draw_rgb_image_dithalign
gdk_draw_indexed_image
gdk_draw_gray_image
gdk_draw_rgb_32_image
gdk_draw_rgb_32_image_dithalign
GdkRgbDither
<SUBSECTION>
gdk_rgb_cmap_new
gdk_rgb_cmap_free
GdkRgbCmap
<SUBSECTION>
gdk_rgb_find_color
<SUBSECTION>
gdk_rgb_set_install
gdk_rgb_set_min_colors
gdk_rgb_get_visual
gdk_rgb_get_colormap
gdk_rgb_ditherable
gdk_rgb_colormap_ditherable
gdk_rgb_set_verbose
<SUBSECTION Standard>
GDK_TYPE_RGB_DITHER
</SECTION>
<SECTION>
<TITLE>Pixbufs</TITLE>
<FILE>pixbufs</FILE>
......
......@@ -170,25 +170,6 @@ lines.
@n_points:
<!-- ##### FUNCTION gdk_draw_pixbuf ##### -->
<para>
</para>
@drawable:
@gc:
@pixbuf:
@src_x:
@src_y:
@dest_x:
@dest_y:
@width:
@height:
@dither:
@x_dither:
@y_dither:
<!-- ##### FUNCTION gdk_draw_segments ##### -->
<para>
</para>
......
......@@ -54,7 +54,6 @@ to create or modify a graphics context.
only sets the pixel value.
@background: the background color. Note that gdk_gc_get_values()
only sets the pixel value.
@font: the default font.
@function: the bitwise operation used when drawing.
@fill: the fill style.
@tile: the tile pixmap.
......
<!-- ##### SECTION Title ##### -->
GdkRGB
<!-- ##### SECTION Short_Description ##### -->
Renders RGB, grayscale, or indexed image data to a GdkDrawable
<!-- ##### SECTION Long_Description ##### -->
<para>
GdkRGB is a low-level module which renders RGB, grayscale, and indexed
colormap images to a #GdkDrawable. It does this as efficiently as
possible, handling issues such as colormaps, visuals, dithering,
temporary buffers, and so on. Most code should use the higher-level
#GdkPixbuf features in place of this module; for example,
gdk_draw_pixbuf() uses GdkRGB in its implementation.
</para>
<para>
GdkRGB allocates a color cube to use when rendering images. You can
set the threshold for installing colormaps with
gdk_rgb_set_min_colors(). The default is 5x5x5 (125). If a colorcube
of this size or larger can be allocated in the default colormap, then
that's done. Otherwise, GdkRGB creates its own private colormap.
Setting it to 0 means that it always tries to use the default
colormap, and setting it to 216 means that it always creates a private
one if it cannot allocate the 6x6x6 colormap in the default. If you
always want a private colormap (to avoid consuming too many colormap
entries for other apps, say), you can use
<literal>gdk_rgb_set_install(TRUE)</literal>.
Setting the value greater than 216 exercises a bug in older versions
of GdkRGB. Note, however, that setting it to 0 doesn't let you get
away with ignoring the colormap and visual - a colormap is always
created in grayscale and direct color modes, and the visual is changed
in cases where a "better" visual than the default is available.
</para>
<para>
If GDK is built with the Sun mediaLib library, the GdkRGB functions are
accelerated using mediaLib, which provides hardware acceleration on Intel,
AMD, and Sparc chipsets. If desired, mediaLib support can be turned off
by setting the GDK_DISABLE_MEDIALIB environment variable.
</para>
<example>
<title>A simple example program using GdkRGB</title>
<programlisting>
&num;include &lt;gtk/gtk.h&gt;
&num;define IMAGE_WIDTH 256
&num;define IMAGE_HEIGHT 256
guchar rgbbuf[IMAGE_WIDTH * IMAGE_HEIGHT * 3];
gboolean on_darea_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer user_data);
int
main (int argc, char *argv[])
{
GtkWidget *window, *darea;
gint x, y;
guchar *pos;
gtk_init (&amp;argc, &amp;argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
darea = gtk_drawing_area_new (<!-- -->);
gtk_widget_set_size_request (darea, IMAGE_WIDTH, IMAGE_HEIGHT);
gtk_container_add (GTK_CONTAINER (window), darea);
gtk_signal_connect (GTK_OBJECT (darea), "expose-event",
GTK_SIGNAL_FUNC (on_darea_expose), NULL);
gtk_widget_show_all (window);
/* Set up the RGB buffer. */
pos = rgbbuf;
for (y = 0; y &lt; IMAGE_HEIGHT; y++)
{
for (x = 0; x &lt; IMAGE_WIDTH; x++)
{
*pos++ = x - x % 32; /* Red. */
*pos++ = (x / 32) * 4 + y - y % 32; /* Green. */
*pos++ = y - y % 32; /* Blue. */
}
}
gtk_main (<!-- -->);
return 0;
}
gboolean
on_darea_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer user_data)
{
gdk_draw_rgb_image (widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
0, 0, IMAGE_WIDTH, IMAGE_HEIGHT,
GDK_RGB_DITHER_MAX, rgbbuf, IMAGE_WIDTH * 3);
return TRUE;
}
</programlisting>
</example>
<!-- ##### SECTION See_Also ##### -->
<para>
<variablelist>
<varlistentry>
<term>#GdkColor</term>
<listitem><para>The underlying GDK mechanism for allocating
colors.</para></listitem>
</varlistentry>
<varlistentry>
<term>#GdkPixbuf and gdk_draw_pixbuf()</term>
<listitem><para>Higher-level image handling.</para></listitem>
</varlistentry>
</variablelist>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### FUNCTION gdk_draw_rgb_image ##### -->
<para>
Draws an RGB image in the drawable. This is the core GdkRGB
function, and likely the only one you will need to use.
</para>
<para>
The @rowstride parameter allows for lines to be aligned more flexibly.
For example, lines may be allocated to begin on 32-bit boundaries,
even if the width of the rectangle is odd. Rowstride is also useful
when drawing a subrectangle of a larger image in memory. Finally, to
replicate the same line a number of times, the trick of setting
@rowstride to 0 is allowed.
</para>
<para>
In general, for 0 &lt;= i &lt; @width and 0 &lt;= j &lt; height,
the pixel (x + i, y + j) is colored with red value @rgb_buf[@j *
@rowstride + @i * 3], green value @rgb_buf[@j * @rowstride + @i * 3 +
1], and blue value @rgb_buf[@j * @rowstride + @i * 3 + 2].
</para>
@drawable: The #GdkDrawable to draw in (usually a #GdkWindow).
@gc: The graphics context (all GDK drawing operations require one; its
contents are ignored).
@x: The x coordinate of the top-left corner in the drawable.
@y: The y coordinate of the top-left corner in the drawable.
@width: The width of the rectangle to be drawn.
@height: The height of the rectangle to be drawn.
@dith: A #GdkRgbDither value, selecting the desired dither mode.
@rgb_buf: The pixel data, represented as packed 24-bit data.
@rowstride: The number of bytes from the start of one row in @rgb_buf to the
start of the next.
<!-- ##### FUNCTION gdk_draw_rgb_image_dithalign ##### -->
<para>
Draws an RGB image in the drawable, with an adjustment for dither alignment.
</para>
<para>
This function is useful when drawing dithered images into a window
that may be scrolled. Pixel (x, y) will be drawn dithered as if its
actual location is (x + @xdith, y + @ydith). Thus, if you draw an
image into a window using zero dither alignment, then scroll up one
pixel, subsequent draws to the window should have @ydith = 1.
</para>
<para>
Setting the dither alignment correctly allows updating of small parts
of the screen while avoiding visible "seams" between the different
dither textures.
</para>
@drawable: The #GdkDrawable to draw in (usually a #GdkWindow).
@gc: The graphics context.
@x: The x coordinate of the top-left corner in the drawable.
@y: The y coordinate of the top-left corner in the drawable.
@width: The width of the rectangle to be drawn.
@height: The height of the rectangle to be drawn.
@dith: A #GdkRgbDither value, selecting the desired dither mode.
@rgb_buf: The pixel data, represented as packed 24-bit data.
@rowstride: The number of bytes from the start of one row in @rgb_buf to the
start of the next.
@xdith: An x offset for dither alignment.
@ydith: A y offset for dither alignment.
<!-- ##### FUNCTION gdk_draw_indexed_image ##### -->
<para>
Draws an indexed image in the drawable, using a #GdkRgbCmap to assign
actual colors to the color indices.
</para>
@drawable: The #GdkDrawable to draw in (usually a #GdkWindow).
@gc: The graphics context.
@x: The x coordinate of the top-left corner in the drawable.
@y: The y coordinate of the top-left corner in the drawable.
@width: The width of the rectangle to be drawn.
@height: The height of the rectangle to be drawn.
@dith: A #GdkRgbDither value, selecting the desired dither mode.
@buf: The pixel data, represented as 8-bit color indices.
@rowstride: The number of bytes from the start of one row in @buf to the
start of the next.
@cmap: The #GdkRgbCmap used to assign colors to the color indices.
<!-- ##### FUNCTION gdk_draw_gray_image ##### -->
<para>
Draws a grayscale image in the drawable.
</para>
@drawable: The #GdkDrawable to draw in (usually a #GdkWindow).
@gc: The graphics context.
@x: The x coordinate of the top-left corner in the drawable.
@y: The y coordinate of the top-left corner in the drawable.
@width: The width of the rectangle to be drawn.
@height: The height of the rectangle to be drawn.
@dith: A #GdkRgbDither value, selecting the desired dither mode.
@buf: The pixel data, represented as 8-bit gray values.
@rowstride: The number of bytes from the start of one row in @buf to the
start of the next.
<!-- ##### FUNCTION gdk_draw_rgb_32_image ##### -->
<para>
Draws a padded RGB image in the drawable. The image is stored as one
pixel per 32-bit word. It is laid out as a red byte, a green byte, a
blue byte, and a padding byte.
</para>
<para>
It's unlikely that this function will give significant performance
gains in practice. In my experience, the performance gain from having
pixels aligned to 32-bit boundaries is cancelled out by the increased
memory bandwidth.
</para>
@drawable: The #GdkDrawable to draw in (usually a #GdkWindow).
@gc: The graphics context.
@x: The x coordinate of the top-left corner in the drawable.
@y: The y coordinate of the top-left corner in the drawable.
@width: The width of the rectangle to be drawn.
@height: The height of the rectangle to be drawn.
@dith: A #GdkRgbDither value, selecting the desired dither mode.
@buf: The pixel data, represented as padded 32-bit data.
@rowstride: The number of bytes from the start of one row in @buf to the
start of the next.
<!-- ##### FUNCTION gdk_draw_rgb_32_image_dithalign ##### -->
<para>
</para>
@drawable:
@gc:
@x:
@y:
@width:
@height:
@dith:
@buf:
@rowstride:
@xdith:
@ydith:
<!-- ##### ENUM GdkRgbDither ##### -->
<para>
Selects whether or not GdkRGB applies dithering
to the image on display.
</para>
<para>
Since GdkRGB currently only handles images with 8 bits per component,
dithering on 24 bit per pixel displays is a moot point.
</para>
@GDK_RGB_DITHER_NONE: Never use dithering.
@GDK_RGB_DITHER_NORMAL: Use dithering in 8 bits per pixel (and below)
only.
@GDK_RGB_DITHER_MAX: Use dithering in 16 bits per pixel and below.
<!-- ##### FUNCTION gdk_rgb_cmap_new ##### -->
<para>
Creates a new #GdkRgbCmap structure. The cmap maps color indexes to
RGB colors. If @n_colors is less than 256, then images containing
color values greater than or equal to @n_colors will produce undefined
results, including possibly segfaults.
</para>
@colors: The colors, represented as 0xRRGGBB integer values.
@n_colors: The number of colors in the cmap.
@Returns: The newly created #GdkRgbCmap
<!-- ##### FUNCTION gdk_rgb_cmap_free ##### -->
<para>
Frees the memory associated with a #GdkRgbCmap created by gdk_rgb_cmap_new().
</para>
@cmap: The #GdkRgbCmap to free.
<!-- ##### STRUCT GdkRgbCmap ##### -->
<para>
A private data structure which maps color indices to actual RGB
colors. This is used only for gdk_draw_indexed_image().
</para>
@colors: The colors, represented as 0xRRGGBB integer values.
@n_colors: The number of colors in the cmap.
<!-- ##### FUNCTION gdk_rgb_find_color ##### -->
<para>
</para>
@colormap:
@color:
<!-- ##### FUNCTION gdk_rgb_set_install ##### -->
<para>
If @install is %TRUE, directs GdkRGB to always install a new "private"
colormap rather than trying to find a best fit with the colors already
allocated. Ordinarily, GdkRGB will install a colormap only if a
sufficient cube cannot be allocated.
</para>
<para>
A private colormap has more colors, leading to better quality display,
but also leads to the dreaded "colormap flashing" effect.
</para>
@install: %TRUE to set install mode.
<!-- ##### FUNCTION gdk_rgb_set_min_colors ##### -->
<para>
Sets the minimum number of colors for the color cube. Generally,
GdkRGB tries to allocate the largest color cube it can. If it can't
allocate a color cube at least as large as @min_colors, it installs a
private colormap.
</para>
@min_colors: The minimum number of colors accepted.
<!-- ##### FUNCTION gdk_rgb_get_visual ##### -->
<para>
</para>
@void:
@Returns:
<!-- ##### FUNCTION gdk_rgb_get_colormap ##### -->
<para>
</para>
@void:
@Returns:
<!-- ##### FUNCTION gdk_rgb_ditherable ##### -->
<para>
Determines whether the preferred visual is ditherable. This function may be
useful for presenting a user interface choice to the user about which
dither mode is desired; if the display is not ditherable, it may make
sense to gray out or hide the corresponding UI widget.
</para>
@void:
@Returns: %TRUE if the preferred visual is ditherable.
<!-- ##### FUNCTION gdk_rgb_colormap_ditherable ##### -->
<para>
Determines whether the visual associated with @cmap is ditherable. This
function may be useful for presenting a user interface choice to the user
about which dither mode is desired; if the display is not ditherable, it may
make sense to gray out or hide the corresponding UI widget.
</para>
@cmap: a #GdkColormap
@Returns: %TRUE if the visual associated with @cmap is ditherable.
<!-- ##### FUNCTION gdk_rgb_set_verbose ##### -->
<para>
Sets the "verbose" flag. This is generally only useful for debugging.
</para>
@verbose: %TRUE if verbose messages are desired.
......@@ -91,7 +91,6 @@ gdk_public_h_sources = \
gdkpixmap.h \
gdkprivate.h \
gdkproperty.h \
gdkrgb.h \
gdkscreen.h \
gdkselection.h \
gdkspawn.h \
......@@ -134,7 +133,6 @@ gdk_c_sources = \
gdkpixbuf-render.c \
gdkpixmap.c \
gdkrectangle.c \
gdkrgb.c \
gdkscreen.c \
gdkselection.c \
gdkvisual.c \
......
......@@ -49,7 +49,6 @@
#include <gdk/gdkpixbuf.h>
#include <gdk/gdkpixmap.h>
#include <gdk/gdkproperty.h>
#include <gdk/gdkrgb.h>
#include <gdk/gdkscreen.h>
#include <gdk/gdkselection.h>
#include <gdk/gdkspawn.h>
......
......@@ -245,7 +245,6 @@ gdk_utf8_to_compound_text_for_display
#if IN_HEADER(__GDK_ENUM_TYPES_H__)
#if IN_FILE(__GDK_ENUM_TYPES_C__)
gdk_rgb_dither_get_type G_GNUC_CONST
gdk_drag_protocol_get_type G_GNUC_CONST
gdk_input_source_get_type G_GNUC_CONST
gdk_input_mode_get_type G_GNUC_CONST
......@@ -977,27 +976,6 @@ gdk_pixmap_lookup_for_display
#endif
#endif
#if IN_HEADER(__GDK_RGB_H__)
#if IN_FILE(__GDK_RGB_C__)
gdk_rgb_cmap_free
gdk_rgb_cmap_new
gdk_rgb_colormap_ditherable
gdk_rgb_ditherable
gdk_rgb_find_color
gdk_rgb_get_colormap
gdk_rgb_get_visual
gdk_rgb_set_install
gdk_rgb_set_min_colors
gdk_rgb_set_verbose
gdk_draw_gray_image
gdk_draw_indexed_image
gdk_draw_rgb_32_image
gdk_draw_rgb_32_image_dithalign
gdk_draw_rgb_image
gdk_draw_rgb_image_dithalign
#endif
#endif
#if IN_HEADER(__GDK_SCREEN_H__)
#if IN_FILE(__GDK_SCREEN_C__)
gdk_screen_get_type G_GNUC_CONST
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
#error "Only <gdk/gdk.h> can be included directly."
#endif
#ifndef __GDK_RGB_H__
#define __GDK_RGB_H__
#include <gdk/gdktypes.h>
G_BEGIN_DECLS
typedef struct _GdkRgbCmap GdkRgbCmap;
struct _GdkRgbCmap {
guint32 colors[256];
gint n_colors;
/*< private >*/
GSList *info_list;
};
void gdk_rgb_find_color (GdkColormap *colormap,
GdkColor *color);
typedef enum
{
GDK_RGB_DITHER_NONE,
GDK_RGB_DITHER_NORMAL,
GDK_RGB_DITHER_MAX
} GdkRgbDither;
void gdk_draw_rgb_image (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
gint width,
gint height,
GdkRgbDither dith,
const guchar *rgb_buf,
gint rowstride);
void gdk_draw_rgb_image_dithalign (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
gint width,
gint height,
GdkRgbDither dith,
const guchar *rgb_buf,
gint rowstride,
gint xdith,
gint ydith);
void gdk_draw_rgb_32_image (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
gint width,
gint height,
GdkRgbDither dith,
const guchar *buf,
gint rowstride);
void gdk_draw_rgb_32_image_dithalign (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
gint width,
gint height,
GdkRgbDither dith,
const guchar *buf,
gint rowstride,
gint xdith,
gint ydith);
void gdk_draw_gray_image (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
gint width,
gint height,
GdkRgbDither dith,
const guchar *buf,
gint rowstride);
void gdk_draw_indexed_image (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
gint width,
gint height,
GdkRgbDither dith,
const guchar *buf,
gint rowstride,
GdkRgbCmap *cmap);
GdkRgbCmap *gdk_rgb_cmap_new (guint32 *colors,
gint n_colors);
void gdk_rgb_cmap_free (GdkRgbCmap *cmap);
void gdk_rgb_set_verbose (gboolean verbose);
/* experimental colormap stuff */
void gdk_rgb_set_install (gboolean install);
void gdk_rgb_set_min_colors (gint min_colors);
#ifndef GDK_MULTIHEAD_SAFE
GdkColormap *gdk_rgb_get_colormap (void);
GdkVisual * gdk_rgb_get_visual (void);
gboolean gdk_rgb_ditherable (void);
gboolean gdk_rgb_colormap_ditherable (GdkColormap *cmap);
#endif
G_END_DECLS
#endif /* __GDK_RGB_H__ */
......@@ -87,7 +87,6 @@ gdk_OBJECTS = \
gdkpixbuf-render.obj \
gdkpixmap.obj \
gdkrectangle.obj \
gdkrgb.obj \
gdkscreen.obj \
gdkselection.obj \
gdkvisual.obj \
......@@ -109,7 +108,6 @@ gdk_public_h_sources = \
gdkpixbuf.h \
gdkpixmap.h \
gdkproperty.h \
gdkrgb.h \
gdkselection.h \
gdktypes.h \
gdkvisual.h \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment