Commit 14fe04ec authored by Benjamin Otte's avatar Benjamin Otte

API: remove GdkImage

It was unused and buggy.
parent 6f508455
......@@ -134,7 +134,6 @@
<File RelativePath="..\..\..\gdk\win32\gdkgeometry-win32.c" />
<File RelativePath="..\..\..\gdk\win32\gdkglobals-win32.c" />
<File RelativePath="..\..\..\gdk\win32\gdkim-win32.c" />
<File RelativePath="..\..\..\gdk\win32\gdkimage-win32.c" />
<File RelativePath="..\..\..\gdk\win32\gdkinput-win32.c" />
<File RelativePath="..\..\..\gdk\win32\gdkinput.c" />
<File RelativePath="..\..\..\gdk\win32\gdkkeys-win32.c" />
......
......@@ -108,7 +108,6 @@ copy ..\..\..\gdk\gdkevents.h $(OutDir)\include\gtk-$(GtkApiVersion)\gdk&#x0D;&#
copy ..\..\..\gdk\gdkfont.h $(OutDir)\include\gtk-$(GtkApiVersion)\gdk&#x0D;&#x0A;
copy ..\..\..\gdk\gdkgc.h $(OutDir)\include\gtk-$(GtkApiVersion)\gdk&#x0D;&#x0A;
copy ..\..\..\gdk\gdki18n.h $(OutDir)\include\gtk-$(GtkApiVersion)\gdk&#x0D;&#x0A;
copy ..\..\..\gdk\gdkimage.h $(OutDir)\include\gtk-$(GtkApiVersion)\gdk&#x0D;&#x0A;
copy ..\..\..\gdk\gdkinput.h $(OutDir)\include\gtk-$(GtkApiVersion)\gdk&#x0D;&#x0A;
copy ..\..\..\gdk\gdkkeys.h $(OutDir)\include\gtk-$(GtkApiVersion)\gdk&#x0D;&#x0A;
copy ..\..\..\gdk\gdkkeysyms.h $(OutDir)\include\gtk-$(GtkApiVersion)\gdk&#x0D;&#x0A;
......
......@@ -28,7 +28,6 @@
<xi:include href="xml/drawing.xml" />
<xi:include href="xml/pixmaps.xml" />
<xi:include href="xml/images.xml" />
<xi:include href="xml/pixbufs.xml" />
<xi:include href="xml/colors.xml" />
......
......@@ -79,7 +79,6 @@ gdk_gc_values_mask_get_type
gdk_grab_ownership_get_type
gdk_grab_status_get_type
gdk_gravity_get_type
gdk_image_type_get_type
gdk_input_mode_get_type
gdk_input_source_get_type
gdk_join_style_get_type
......@@ -275,43 +274,6 @@ GdkPixmapObject
GdkPixmapObjectClass
</SECTION>
<SECTION>
<TITLE>Images</TITLE>
<FILE>images</FILE>
GdkImage
gdk_image_new
GdkImageType
gdk_image_get_colormap
gdk_image_set_colormap
gdk_image_get_bits_per_pixel
gdk_image_get_bytes_per_pixel
gdk_image_get_bytes_per_line
gdk_image_get_byte_order
gdk_image_get_depth
gdk_image_get_height
gdk_image_get_image_type
gdk_image_get_visual
gdk_image_get_width
gdk_image_get_pixels
<SUBSECTION>
gdk_image_put_pixel
gdk_image_get_pixel
<SUBSECTION Standard>
GDK_IMAGE
GDK_TYPE_IMAGE
GDK_IS_IMAGE
GDK_IMAGE_CLASS
GDK_IMAGE_GET_CLASS
GDK_IS_IMAGE_CLASS
GDK_TYPE_IMAGE_TYPE
<SUBSECTION Private>
GdkImageClass
gdk_image_get_type
</SECTION>
<SECTION>
<TITLE>Pixbufs</TITLE>
<FILE>pixbufs</FILE>
......@@ -1176,8 +1138,6 @@ GDK_PIXMAP_XID
GDK_DISPLAY_XDISPLAY
GDK_DRAWABLE_XDISPLAY
GDK_DRAWABLE_XID
GDK_IMAGE_XDISPLAY
GDK_IMAGE_XIMAGE
GDK_GC_XDISPLAY
GDK_COLORMAP_XDISPLAY
GDK_COLORMAP_XCOLORMAP
......@@ -1232,8 +1192,6 @@ gdk_x11_get_default_root_xwindow
gdk_x11_get_default_screen
gdk_x11_get_default_xdisplay
gdk_x11_grab_server
gdk_x11_image_get_xdisplay
gdk_x11_image_get_ximage
gdk_x11_screen_get_screen_number
gdk_x11_screen_get_xscreen
gdk_x11_ungrab_server
......
<!-- ##### SECTION Title ##### -->
Images
<!-- ##### SECTION Short_Description ##### -->
A client-side area for bit-mapped graphics
<!-- ##### SECTION Long_Description ##### -->
<para>
The #GdkImage type represents an area for drawing graphics.
It has now been superceded to a large extent by the much more flexible
<link linkend="gdk-GdkRGB">GdkRGB</link> functions.
</para>
<para>
To create an empty #GdkImage use gdk_image_new().
To create an image from part of a #GdkWindow use gdk_drawable_get_image().
</para>
<para>
The image can be manipulated with gdk_image_get_pixel() and
gdk_image_put_pixel(), or alternatively by changing the actual pixel data.
Though manipulating the pixel data requires complicated code to cope with
the different formats that may be used.
</para>
<para>
To draw a #GdkImage in a #GdkWindow or #GdkPixmap use gdk_draw_image().
</para>
<para>
To destroy a #GdkImage use g_object_unref().
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
<variablelist>
<varlistentry>
<term><link linkend="gdk-Bitmaps-and-Pixmaps">Bitmaps and Pixmaps</link></term>
<listitem><para>
Graphics which are stored on the X Windows server.
Since these are stored on the server they can be drawn very quickly, and all
of the <link linkend="gdk-Drawing-Primitives">Drawing Primitives</link> can be
used to draw on them. Their main disadvantage is that manipulating individual
pixels can be very slow.
</para></listitem>
</varlistentry>
<varlistentry>
<term><link linkend="gdk-GdkRGB">GdkRGB</link></term>
<listitem><para>
Built on top of #GdkImage, this provides much more functionality,
including the dithering of colors to produce better output on low-color
displays.
</para></listitem>
</varlistentry>
</variablelist>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### STRUCT GdkImage ##### -->
<para>
The #GdkImage struct contains information on the image and the pixel data.
</para>
@parent_instance: the parent instance
<!-- ##### FUNCTION gdk_image_new ##### -->
<para>
Creates a new #GdkImage.
</para>
@type: the type of the #GdkImage, one of %GDK_IMAGE_NORMAL, %GDK_IMAGE_SHARED
and %GDK_IMAGE_FASTEST. %GDK_IMAGE_FASTEST is probably the best choice, since
it will try creating a %GDK_IMAGE_SHARED image first and if that fails it will
then use %GDK_IMAGE_NORMAL.
@visual: the #GdkVisual to use for the image.
@width: the width of the image in pixels.
@height: the height of the image in pixels.
@Returns: a new #GdkImage, or %NULL if the image could not be created.
<!-- ##### ENUM GdkImageType ##### -->
<para>
Specifies the type of a #GdkImage.
</para>
@GDK_IMAGE_NORMAL: The original X image type, which is quite slow since the
image has to be transferred from the client to the server to display it.
@GDK_IMAGE_SHARED: A faster image type, which uses shared memory to transfer
the image data between client and server. However this will only be available
if client and server are on the same machine and the shared memory extension
is supported by the server.
@GDK_IMAGE_FASTEST: Specifies that %GDK_IMAGE_SHARED should be tried first,
and if that fails then %GDK_IMAGE_NORMAL will be used.
<!-- ##### FUNCTION gdk_image_get_colormap ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_image_set_colormap ##### -->
<para>
</para>
@image:
@colormap:
<!-- ##### FUNCTION gdk_image_get_bits_per_pixel ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_image_get_bytes_per_pixel ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_image_get_bytes_per_line ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_image_get_byte_order ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_image_get_depth ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_image_get_height ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_image_get_image_type ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_image_get_visual ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_image_get_width ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_image_get_pixels ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_image_put_pixel ##### -->
<para>
Sets a pixel in a #GdkImage to a given pixel value.
</para>
@image: a #GdkImage.
@x: the x coordinate of the pixel to set.
@y: the y coordinate of the pixel to set.
@pixel: the pixel value to set.
<!-- ##### FUNCTION gdk_image_get_pixel ##### -->
<para>
Gets a pixel value at a specified position in a #GdkImage.
</para>
@image: a #GdkImage.
@x: the x coordinate of the pixel to get.
@y: the y coordinate of the pixel to get.
@Returns: the pixel value at the given position.
......@@ -17,14 +17,6 @@ of an RGB pixel may be in the top 8 bits of the pixel, or may be in the lower
4 bits.
</para>
<para>
Usually you can avoid thinking about visuals in GTK+. Visuals are useful to
interpret the contents of a #GdkImage, but you should avoid #GdkImage precisely
because its contents depend on the display hardware; use #GdkPixbuf instead, for
all but the most low-level purposes. Also, anytime you provide a #GdkColormap,
the visual is implied as part of the colormap (gdk_colormap_get_visual()), so
you won't have to provide a visual in addition.
</para>
<para>
There are several standard visuals. The visual returned
by gdk_visual_get_system() is the system's default
visual. gdk_rgb_get_visual() return the visual most
......@@ -48,7 +40,7 @@ then %GDK_VISUAL_STATIC_GRAY.
<!-- ##### SECTION See_Also ##### -->
<para>
#GdkImage, #GdkColormap, #GdkRGB
#GdkColormap
</para>
<!-- ##### SECTION Stability_Level ##### -->
......
......@@ -97,24 +97,6 @@ Returns the X resource (window or pixmap) belonging to a #GdkDrawable.
@Returns: the ID of @win's X resource.
<!-- ##### MACRO GDK_IMAGE_XDISPLAY ##### -->
<para>
Returns the display of a #GdkImage.
</para>
@image: a #GdkImage.
@Returns: an Xlib <type>Display*</type>.
<!-- ##### MACRO GDK_IMAGE_XIMAGE ##### -->
<para>
Returns the X image belonging to a #GdkImage.
</para>
@image: a #GdkImage.
@Returns: an <type>XImage*</type>.
<!-- ##### MACRO GDK_GC_XDISPLAY ##### -->
<para>
Returns the display of a #GdkGC.
......@@ -610,24 +592,6 @@ Another name for GDK_DRAWABLE_XID().
@void:
<!-- ##### FUNCTION gdk_x11_image_get_xdisplay ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_x11_image_get_ximage ##### -->
<para>
</para>
@image:
@Returns:
<!-- ##### FUNCTION gdk_x11_screen_get_screen_number ##### -->
<para>
......
......@@ -82,7 +82,6 @@ gdk_public_h_sources = \
gdkdrawable.h \
gdkevents.h \
gdkgc.h \
gdkimage.h \
gdkinput.h \
gdkkeys.h \
gdkkeysyms.h \
......@@ -124,7 +123,6 @@ gdk_c_sources = \
gdkevents.c \
gdkgc.c \
gdkglobals.c \
gdkimage.c \
gdkkeys.c \
gdkkeyuni.c \
gdkoffscreenwindow.c \
......@@ -214,7 +212,6 @@ x11_introspection_files = \
x11/gdkgc-x11.c \
x11/gdkgeometry-x11.c \
x11/gdkglobals-x11.c \
x11/gdkimage-x11.c \
x11/gdkim-x11.c \
x11/gdkinput.c \
x11/gdkkeys-x11.c \
......
......@@ -31,7 +31,6 @@ libgdk_directfb_la_SOURCES = \
gdkgeometry-directfb.c \
gdkglobals-directfb.c \
gdkim-directfb.c \
gdkimage-directfb.c \
gdkinput-directfb.c \
gdkinput-directfb.h \
gdkkeys-directfb.c \
......
......@@ -34,7 +34,6 @@ gdkevents-directfb.c
gdkgc-directfb.c
gdkgeometry-directfb.c
gdkglobals-directfb.c
gdkimage-directfb.c
gdkim-directfb.c
gdkinput-directfb.c
gdkkeys-directfb.c
......
......@@ -39,7 +39,6 @@ extern void _gdk_events_init (void);
extern void _gdk_input_init (void);
extern void _gdk_dnd_init (void);
extern void _gdk_windowing_window_init (void);
extern void _gdk_windowing_image_init (void);
extern void _gdk_directfb_keyboard_init (void);
static gboolean gdk_directfb_argb_font = FALSE;
......
/* GDK - The GIMP Drawing Kit
* 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.
*/
/*
* GTK+ DirectFB backend
* Copyright (C) 2001-2002 convergence integrated media GmbH
* Copyright (C) 2002-2004 convergence GmbH
* Written by Denis Oliver Kropp <dok@convergence.de> and
* Sven Neumann <sven@convergence.de>
*/
#include "config.h"
#include "gdk.h"
#include "gdkdirectfb.h"
#include "gdkprivate-directfb.h"
#include "gdkinternals.h"
#include "gdkimage.h"
static GList *image_list = NULL;
static gpointer parent_class = NULL;
static void gdk_directfb_image_destroy (GdkImage *image);
static void gdk_image_init (GdkImage *image);
static void gdk_image_class_init (GdkImageClass *klass);
static void gdk_image_finalize (GObject *object);
GType
gdk_image_get_type (void)
{
static GType object_type = 0;
if (!object_type)
{
const GTypeInfo object_info =
{
sizeof (GdkImageClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gdk_image_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkImage),
0, /* n_preallocs */
(GInstanceInitFunc) gdk_image_init,
};
object_type = g_type_register_static (G_TYPE_OBJECT,
"GdkImage",
&object_info, 0);
}
return object_type;
}
static void
gdk_image_init (GdkImage *image)
{
image->windowing_data = g_new0 (GdkImageDirectFB, 1);
image->mem = NULL;
image_list = g_list_prepend (image_list, image);
}
static void
gdk_image_class_init (GdkImageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_image_finalize;
}
static void
gdk_image_finalize (GObject *object)
{
GdkImage *image;
image = GDK_IMAGE (object);
image_list = g_list_remove (image_list, image);
if (image->depth == 1)
g_free (image->mem);
gdk_directfb_image_destroy (image);
if (G_OBJECT_CLASS (parent_class)->finalize)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/* this function is called from the atexit handler! */
void
_gdk_image_exit (void)
{
GObject *image;
while (image_list)
{
image = image_list->data;
gdk_image_finalize (image);
}
}
void
_gdk_windowing_image_init (void)
{
}
GdkImage*
_gdk_image_new_for_depth (GdkScreen *screen,
GdkImageType type,
GdkVisual *visual,
gint width,
gint height,
gint depth)
{
GdkImage *image;
GdkImageDirectFB *private;
DFBResult ret;
gint pitch;
DFBSurfacePixelFormat format;
IDirectFBSurface *surface;
if (type == GDK_IMAGE_FASTEST || type == GDK_IMAGE_NORMAL)
type = GDK_IMAGE_SHARED;
if (visual)
depth = visual->depth;
switch (depth)
{
case 8:
format = DSPF_LUT8;
break;
case 15:
format = DSPF_ARGB1555;
break;
case 16:
format = DSPF_RGB16;
break;
case 24:
format = DSPF_RGB32;
break;
case 32:
format = DSPF_ARGB;
break;
default:
g_message ("unimplemented %s for depth %d", G_STRFUNC, depth);
return NULL;
}
surface = gdk_display_dfb_create_surface(_gdk_display,format,width,height);
if (!surface)
{
return NULL;
}
surface->GetPixelFormat( surface, &format );
image = g_object_new (gdk_image_get_type (), NULL);
private = image->windowing_data;
private->surface = surface;
ret = surface->Lock( surface, DSLF_WRITE, &image->mem, &pitch );
if (ret)
{
DirectFBError( "IDirectFBSurface::Lock() for writing failed!\n", ret );
g_object_unref( image );
return NULL;
}
image->type = type;
image->visual = visual;
#if G_BYTE_ORDER == G_BIG_ENDIAN
image->byte_order = GDK_MSB_FIRST;
#else
image->byte_order = GDK_LSB_FIRST;
#endif
image->width = width;
image->height = height;
image->depth = depth;
image->bpp = DFB_BYTES_PER_PIXEL (format);
image->bpl = pitch;
image->bits_per_pixel = DFB_BITS_PER_PIXEL (format);
image_list = g_list_prepend (image_list, image);
return image;
}
guint32
gdk_image_get_pixel (GdkImage *image,
gint x,
gint y)
{
guint32 pixel = 0;
g_return_val_if_fail (GDK_IS_IMAGE (image), 0);
if (!(x >= 0 && x < image->width && y >= 0 && y < image->height))
return 0;
if (image->depth == 1)
pixel = (((guchar *) image->mem)[y * image->bpl + (x >> 3)] & (1 << (7 - (x & 0x7)))) != 0;
else
{
guchar *pixelp = (guchar *) image->mem + y * image->bpl + x * image->bpp;
switch (image->bpp)
{
case 1:
pixel = *pixelp;
break;
case 2:
pixel = pixelp[0] | (pixelp[1] << 8);
break;
case 3:
pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
break;
case 4:
pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
break;
}
}
return pixel;
}
void
gdk_image_put_pixel (GdkImage *image,
gint x,
gint y,
guint32 pixel)
{
g_return_if_fail (image != NULL);
if (!(x >= 0 && x < image->width && y >= 0 && y < image->height))
return;
if (image->depth == 1)
if (pixel & 1)
((guchar *) image->mem)[y * image->bpl + (x >> 3)] |= (1 << (7 - (x & 0x7)));
else
((guchar *) image->mem)[y * image->bpl + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
else
{
guchar *pixelp = (guchar *) image->mem + y * image->bpl + x * image->bpp;
switch (image->bpp)
{
case 4:
pixelp[3] = 0xFF;