1999-10-27 23:36:44 +00:00
|
|
|
/* GdkPixbuf library - Rendering functions
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 The Free Software Foundation
|
|
|
|
*
|
|
|
|
* Author: Federico Mena-Quintero <federico@gimp.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1999-10-27 23:36:44 +00:00
|
|
|
* 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
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1999-10-27 23:36:44 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1999-10-27 23:36:44 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
1999-10-27 23:36:44 +00:00
|
|
|
#include <gdk/gdk.h>
|
2010-06-26 05:06:30 +00:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2000-06-21 20:47:22 +00:00
|
|
|
#include "gdkpixbuf.h"
|
2002-04-25 22:29:14 +00:00
|
|
|
#include "gdkscreen.h"
|
2004-02-18 00:59:14 +00:00
|
|
|
#include "gdkinternals.h"
|
1999-10-27 23:36:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_pixbuf_render_threshold_alpha:
|
|
|
|
* @pixbuf: A pixbuf.
|
|
|
|
* @bitmap: Bitmap where the bilevel mask will be painted to.
|
|
|
|
* @src_x: Source X coordinate.
|
|
|
|
* @src_y: source Y coordinate.
|
|
|
|
* @dest_x: Destination X coordinate.
|
|
|
|
* @dest_y: Destination Y coordinate.
|
2001-09-19 20:13:16 +00:00
|
|
|
* @width: Width of region to threshold, or -1 to use pixbuf width
|
|
|
|
* @height: Height of region to threshold, or -1 to use pixbuf height
|
1999-10-27 23:36:44 +00:00
|
|
|
* @alpha_threshold: Opacity values below this will be painted as zero; all
|
|
|
|
* other values will be painted as one.
|
1999-10-28 23:25:02 +00:00
|
|
|
*
|
|
|
|
* Takes the opacity values in a rectangular portion of a pixbuf and thresholds
|
|
|
|
* them to produce a bi-level alpha mask that can be used as a clipping mask for
|
|
|
|
* a drawable.
|
1999-11-04 20:16:17 +00:00
|
|
|
*
|
1999-10-27 23:36:44 +00:00
|
|
|
**/
|
|
|
|
void
|
2000-06-21 23:29:51 +00:00
|
|
|
gdk_pixbuf_render_threshold_alpha (GdkPixbuf *pixbuf,
|
2010-06-27 10:28:44 +00:00
|
|
|
GdkBitmap *bitmap,
|
|
|
|
int src_x,
|
|
|
|
int src_y,
|
|
|
|
int dest_x,
|
|
|
|
int dest_y,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int alpha_threshold)
|
1999-10-27 23:36:44 +00:00
|
|
|
{
|
2000-06-21 23:29:51 +00:00
|
|
|
GdkGC *gc;
|
|
|
|
GdkColor color;
|
|
|
|
int x, y;
|
|
|
|
guchar *p;
|
|
|
|
int start, start_status;
|
|
|
|
int status;
|
|
|
|
|
2010-06-27 10:28:44 +00:00
|
|
|
g_return_if_fail (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB);
|
|
|
|
g_return_if_fail (gdk_pixbuf_get_n_channels (pixbuf) == 3 ||
|
|
|
|
gdk_pixbuf_get_n_channels (pixbuf) == 4);
|
|
|
|
g_return_if_fail (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
|
2000-06-21 23:29:51 +00:00
|
|
|
|
2001-09-19 20:13:16 +00:00
|
|
|
if (width == -1)
|
2010-06-26 05:06:30 +00:00
|
|
|
width = gdk_pixbuf_get_width (pixbuf);
|
2001-09-19 20:13:16 +00:00
|
|
|
if (height == -1)
|
2010-06-26 05:06:30 +00:00
|
|
|
height = gdk_pixbuf_get_height (pixbuf);
|
2001-09-19 20:13:16 +00:00
|
|
|
|
2000-06-21 23:29:51 +00:00
|
|
|
g_return_if_fail (bitmap != NULL);
|
|
|
|
g_return_if_fail (width >= 0 && height >= 0);
|
2010-06-26 05:06:30 +00:00
|
|
|
g_return_if_fail (src_x >= 0 && src_x + width <= gdk_pixbuf_get_width (pixbuf));
|
|
|
|
g_return_if_fail (src_y >= 0 && src_y + height <= gdk_pixbuf_get_height (pixbuf));
|
2000-06-21 23:29:51 +00:00
|
|
|
|
|
|
|
g_return_if_fail (alpha_threshold >= 0 && alpha_threshold <= 255);
|
|
|
|
|
|
|
|
if (width == 0 || height == 0)
|
|
|
|
return;
|
|
|
|
|
2004-02-18 17:03:46 +00:00
|
|
|
gc = _gdk_drawable_get_scratch_gc (bitmap, FALSE);
|
2000-06-21 23:29:51 +00:00
|
|
|
|
2010-06-26 05:06:30 +00:00
|
|
|
if (!gdk_pixbuf_get_has_alpha (pixbuf))
|
2000-06-21 23:29:51 +00:00
|
|
|
{
|
|
|
|
color.pixel = (alpha_threshold == 255) ? 0 : 1;
|
|
|
|
gdk_gc_set_foreground (gc, &color);
|
|
|
|
gdk_draw_rectangle (bitmap, gc, TRUE, dest_x, dest_y, width, height);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
color.pixel = 0;
|
|
|
|
gdk_gc_set_foreground (gc, &color);
|
|
|
|
gdk_draw_rectangle (bitmap, gc, TRUE, dest_x, dest_y, width, height);
|
|
|
|
|
|
|
|
color.pixel = 1;
|
|
|
|
gdk_gc_set_foreground (gc, &color);
|
|
|
|
|
|
|
|
for (y = 0; y < height; y++)
|
|
|
|
{
|
2010-06-26 05:06:30 +00:00
|
|
|
p = (gdk_pixbuf_get_pixels (pixbuf) + (y + src_y) * gdk_pixbuf_get_rowstride (pixbuf) + src_x * gdk_pixbuf_get_n_channels (pixbuf)
|
|
|
|
+ gdk_pixbuf_get_n_channels (pixbuf) - 1);
|
2000-06-21 23:29:51 +00:00
|
|
|
|
|
|
|
start = 0;
|
|
|
|
start_status = *p < alpha_threshold;
|
|
|
|
|
|
|
|
for (x = 0; x < width; x++)
|
|
|
|
{
|
|
|
|
status = *p < alpha_threshold;
|
|
|
|
|
|
|
|
if (status != start_status)
|
|
|
|
{
|
|
|
|
if (!start_status)
|
|
|
|
gdk_draw_line (bitmap, gc,
|
|
|
|
start + dest_x, y + dest_y,
|
|
|
|
x - 1 + dest_x, y + dest_y);
|
|
|
|
|
|
|
|
start = x;
|
|
|
|
start_status = status;
|
|
|
|
}
|
|
|
|
|
2010-06-26 05:06:30 +00:00
|
|
|
p += gdk_pixbuf_get_n_channels (pixbuf);
|
1999-10-27 23:36:44 +00:00
|
|
|
}
|
2000-06-21 23:29:51 +00:00
|
|
|
|
|
|
|
if (!start_status)
|
|
|
|
gdk_draw_line (bitmap, gc,
|
|
|
|
start + dest_x, y + dest_y,
|
|
|
|
x - 1 + dest_x, y + dest_y);
|
|
|
|
}
|
1999-10-27 23:36:44 +00:00
|
|
|
}
|
|
|
|
|
2000-01-14 20:59:18 +00:00
|
|
|
/**
|
2000-01-17 01:48:21 +00:00
|
|
|
* gdk_pixbuf_render_pixmap_and_mask:
|
2000-04-11 07:03:25 +00:00
|
|
|
* @pixbuf: A pixbuf.
|
2002-08-11 02:20:16 +00:00
|
|
|
* @pixmap_return: Location to store a pointer to the created pixmap,
|
|
|
|
* or %NULL if the pixmap is not needed.
|
|
|
|
* @mask_return: Location to store a pointer to the created mask,
|
|
|
|
* or %NULL if the mask is not needed.
|
2000-01-17 01:48:21 +00:00
|
|
|
* @alpha_threshold: Threshold value for opacity values.
|
2000-01-14 20:59:18 +00:00
|
|
|
*
|
2000-01-17 01:48:21 +00:00
|
|
|
* Creates a pixmap and a mask bitmap which are returned in the @pixmap_return
|
|
|
|
* and @mask_return arguments, respectively, and renders a pixbuf and its
|
2001-09-07 22:33:09 +00:00
|
|
|
* corresponding thresholded alpha mask to them. This is merely a convenience
|
2000-01-17 01:48:21 +00:00
|
|
|
* function; applications that need to render pixbufs with dither offsets or to
|
2003-01-31 00:37:38 +00:00
|
|
|
* given drawables should use gdk_draw_pixbuf() and gdk_pixbuf_render_threshold_alpha().
|
2000-04-11 07:03:25 +00:00
|
|
|
*
|
2001-09-07 22:33:09 +00:00
|
|
|
* The pixmap that is created is created for the colormap returned
|
|
|
|
* by gdk_rgb_get_colormap(). You normally will want to instead use
|
|
|
|
* the actual colormap for a widget, and use
|
2005-07-18 19:48:52 +00:00
|
|
|
* gdk_pixbuf_render_pixmap_and_mask_for_colormap().
|
2001-09-07 22:33:09 +00:00
|
|
|
*
|
2000-04-11 07:03:25 +00:00
|
|
|
* If the pixbuf does not have an alpha channel, then *@mask_return will be set
|
2005-07-18 19:48:52 +00:00
|
|
|
* to %NULL.
|
2000-01-14 20:59:18 +00:00
|
|
|
**/
|
|
|
|
void
|
2000-06-21 23:29:51 +00:00
|
|
|
gdk_pixbuf_render_pixmap_and_mask (GdkPixbuf *pixbuf,
|
|
|
|
GdkPixmap **pixmap_return,
|
|
|
|
GdkBitmap **mask_return,
|
|
|
|
int alpha_threshold)
|
2001-09-07 22:33:09 +00:00
|
|
|
{
|
|
|
|
gdk_pixbuf_render_pixmap_and_mask_for_colormap (pixbuf,
|
|
|
|
gdk_rgb_get_colormap (),
|
|
|
|
pixmap_return, mask_return,
|
|
|
|
alpha_threshold);
|
|
|
|
}
|
|
|
|
|
2010-07-12 21:09:53 +00:00
|
|
|
static void
|
|
|
|
remove_alpha_channel (GdkPixbuf *pixbuf)
|
|
|
|
{
|
|
|
|
unsigned int x, y, width, height, stride;
|
|
|
|
unsigned char *data;
|
|
|
|
|
|
|
|
if (!gdk_pixbuf_get_has_alpha (pixbuf))
|
|
|
|
return;
|
|
|
|
|
|
|
|
width = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
height = gdk_pixbuf_get_height (pixbuf);
|
|
|
|
stride = gdk_pixbuf_get_rowstride (pixbuf);
|
|
|
|
data = gdk_pixbuf_get_pixels (pixbuf);
|
|
|
|
|
|
|
|
for (y = 0; y < height; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < width; x++)
|
|
|
|
{
|
|
|
|
data[x * 4 + 3] = 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
data += stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-07 22:33:09 +00:00
|
|
|
/**
|
|
|
|
* gdk_pixbuf_render_pixmap_and_mask_for_colormap:
|
|
|
|
* @pixbuf: A pixbuf.
|
|
|
|
* @colormap: A #GdkColormap
|
2002-08-11 02:20:16 +00:00
|
|
|
* @pixmap_return: Location to store a pointer to the created pixmap,
|
|
|
|
* or %NULL if the pixmap is not needed.
|
|
|
|
* @mask_return: Location to store a pointer to the created mask,
|
|
|
|
* or %NULL if the mask is not needed.
|
2001-09-07 22:33:09 +00:00
|
|
|
* @alpha_threshold: Threshold value for opacity values.
|
|
|
|
*
|
|
|
|
* Creates a pixmap and a mask bitmap which are returned in the @pixmap_return
|
|
|
|
* and @mask_return arguments, respectively, and renders a pixbuf and its
|
|
|
|
* corresponding tresholded alpha mask to them. This is merely a convenience
|
|
|
|
* function; applications that need to render pixbufs with dither offsets or to
|
2003-01-31 00:37:38 +00:00
|
|
|
* given drawables should use gdk_draw_pixbuf(), and gdk_pixbuf_render_threshold_alpha().
|
2001-09-07 22:33:09 +00:00
|
|
|
*
|
|
|
|
* The pixmap that is created uses the #GdkColormap specified by @colormap.
|
|
|
|
* This colormap must match the colormap of the window where the pixmap
|
|
|
|
* will eventually be used or an error will result.
|
|
|
|
*
|
|
|
|
* If the pixbuf does not have an alpha channel, then *@mask_return will be set
|
2005-07-18 19:48:52 +00:00
|
|
|
* to %NULL.
|
2001-09-07 22:33:09 +00:00
|
|
|
**/
|
|
|
|
void
|
|
|
|
gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf *pixbuf,
|
|
|
|
GdkColormap *colormap,
|
|
|
|
GdkPixmap **pixmap_return,
|
|
|
|
GdkBitmap **mask_return,
|
|
|
|
int alpha_threshold)
|
2000-01-14 20:59:18 +00:00
|
|
|
{
|
Changes multihead reorganizing code for win32 support, mostly from a patch
Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com>
Changes multihead reorganizing code for win32 support,
mostly from a patch by Hans Breuer.
* gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c
gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c
gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c
gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c
gdk/gdkscreen.c gdk/x11/gdkmain-x11.c
gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c
gdk/x11/gdkpango-x11.c gdk/gdkselection.c
gdk/x11/gdkselection-x11.c gdk/gdkwindow.c
gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c:
Move port-independent singlehead wrapper functions into
port-independent part of GDK. (#80009)
* gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c
gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c
gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c
gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c
gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c:
Turn singlehead functions into "multihead" functions that ignore
their GdkDisplay or GdkScreen arguments.
* gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h:
Misc multihead-compatibility changes.
* gtk/gtk.def gdk/gdk.def: Update for multihead functions.
* gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c
gdk/x11/gdkvisual-x11.c: Remove the screen fields
from the public parts of the colormap/visual structures, add accessors
instead.
* gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c
gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c
gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen
for colormaps, visuals; move the fields into the private
structures for the x11 backend.
* gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c:
Remove virtualization of screen and display functions.
(#79990, patch from Erwann Chenede)
* gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c
gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}:
New files containing stub implementations of Display,
Screen functions.
* gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/x11/gdkx.h: Clean up function exports and what
headers they are in. (#79954)
* gdk/x11/gdkx.h: Fix macro that was referring to a non-existant
screen->screen_num. (In the patch for #79972, Erwann Chenede)
* gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h
gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer()
to use window hooks. (#79972, patch partly from Erwann Chenede)
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix
some warnings.
2002-06-06 00:26:42 +00:00
|
|
|
GdkScreen *screen;
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
|
|
|
|
g_return_if_fail (GDK_IS_COLORMAP (colormap));
|
|
|
|
|
|
|
|
screen = gdk_colormap_get_screen (colormap);
|
2000-06-21 23:29:51 +00:00
|
|
|
|
|
|
|
if (pixmap_return)
|
|
|
|
{
|
2010-07-12 21:09:53 +00:00
|
|
|
GdkPixbuf *tmp_pixbuf;
|
|
|
|
cairo_t *cr;
|
|
|
|
|
Changes multihead reorganizing code for win32 support, mostly from a patch
Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com>
Changes multihead reorganizing code for win32 support,
mostly from a patch by Hans Breuer.
* gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c
gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c
gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c
gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c
gdk/gdkscreen.c gdk/x11/gdkmain-x11.c
gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c
gdk/x11/gdkpango-x11.c gdk/gdkselection.c
gdk/x11/gdkselection-x11.c gdk/gdkwindow.c
gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c:
Move port-independent singlehead wrapper functions into
port-independent part of GDK. (#80009)
* gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c
gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c
gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c
gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c
gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c:
Turn singlehead functions into "multihead" functions that ignore
their GdkDisplay or GdkScreen arguments.
* gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h:
Misc multihead-compatibility changes.
* gtk/gtk.def gdk/gdk.def: Update for multihead functions.
* gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c
gdk/x11/gdkvisual-x11.c: Remove the screen fields
from the public parts of the colormap/visual structures, add accessors
instead.
* gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c
gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c
gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen
for colormaps, visuals; move the fields into the private
structures for the x11 backend.
* gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c:
Remove virtualization of screen and display functions.
(#79990, patch from Erwann Chenede)
* gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c
gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}:
New files containing stub implementations of Display,
Screen functions.
* gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/x11/gdkx.h: Clean up function exports and what
headers they are in. (#79954)
* gdk/x11/gdkx.h: Fix macro that was referring to a non-existant
screen->screen_num. (In the patch for #79972, Erwann Chenede)
* gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h
gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer()
to use window hooks. (#79972, patch partly from Erwann Chenede)
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix
some warnings.
2002-06-06 00:26:42 +00:00
|
|
|
*pixmap_return = gdk_pixmap_new (gdk_screen_get_root_window (screen),
|
2002-04-25 22:29:14 +00:00
|
|
|
gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
|
2002-08-05 19:28:56 +00:00
|
|
|
gdk_colormap_get_visual (colormap)->depth);
|
2002-04-25 22:29:14 +00:00
|
|
|
|
|
|
|
gdk_drawable_set_colormap (GDK_DRAWABLE (*pixmap_return), colormap);
|
2008-02-06 23:08:07 +00:00
|
|
|
|
2010-07-12 21:09:53 +00:00
|
|
|
/* If the pixbuf has an alpha channel, using gdk_cairo_set_source_pixbuf()
|
|
|
|
* would give
|
2008-02-06 23:08:07 +00:00
|
|
|
* random pixel values in the area that are within the mask, but semi-
|
|
|
|
* transparent. So we treat the pixbuf like a pixbuf without alpha channel;
|
|
|
|
* see bug #487865.
|
|
|
|
*/
|
|
|
|
if (gdk_pixbuf_get_has_alpha (pixbuf))
|
2010-07-12 11:27:41 +00:00
|
|
|
{
|
2010-07-12 21:09:53 +00:00
|
|
|
int width, height;
|
|
|
|
|
|
|
|
width = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
height = gdk_pixbuf_get_height (pixbuf);
|
|
|
|
tmp_pixbuf = gdk_pixbuf_copy (pixbuf);
|
|
|
|
remove_alpha_channel (tmp_pixbuf);
|
2010-07-12 11:27:41 +00:00
|
|
|
}
|
2008-02-06 23:08:07 +00:00
|
|
|
else
|
2010-07-12 21:09:53 +00:00
|
|
|
tmp_pixbuf = g_object_ref (pixbuf);
|
|
|
|
|
|
|
|
cr = gdk_cairo_create (*pixmap_return);
|
|
|
|
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
|
|
|
|
cairo_paint (cr);
|
|
|
|
|
|
|
|
cairo_destroy (cr);
|
|
|
|
g_object_unref (tmp_pixbuf);
|
2000-06-21 23:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mask_return)
|
|
|
|
{
|
2001-09-07 22:33:09 +00:00
|
|
|
if (gdk_pixbuf_get_has_alpha (pixbuf))
|
2000-06-21 23:29:51 +00:00
|
|
|
{
|
Changes multihead reorganizing code for win32 support, mostly from a patch
Wed Jun 5 18:34:47 2002 Owen Taylor <otaylor@redhat.com>
Changes multihead reorganizing code for win32 support,
mostly from a patch by Hans Breuer.
* gdk/gdkcolor.c gdk/x11/gdkcolor-x11.c gdk/gdkcursor.c
gdk/x11/gdkcursor-x11.c gdk/gdkevents.c gdk/x11/gdkevents-x11.c
gdk/gdkfont.c gdk/x11/gdkfont-x11.c gdk/gdkkeys.c
gdk/x11/gdkkeys-x11.c gdk/gdkimage.c gdk/x11/gdkimage-x11.c
gdk/gdkscreen.c gdk/x11/gdkmain-x11.c
gdk/gdkdisplay.c gdk/gdkevents-x11.c gdk/gdkpango.c
gdk/x11/gdkpango-x11.c gdk/gdkselection.c
gdk/x11/gdkselection-x11.c gdk/gdkwindow.c
gdk/x11/gdkwindow-x11.c gdk/gdkvisual.c gdk/x11/gdkvisual-x11.c:
Move port-independent singlehead wrapper functions into
port-independent part of GDK. (#80009)
* gdk/win32/gdkcolor-win32.c gdk/win32/gdkcursor-win32.c
gdk/win32/gdkevents-win32.c gdk/win32/gdkfont-win32.c
gdk/win32/gdkimage-win32.c gdk/win32/gdkkeys-win32.c
gdk/win32/gdkmain-win32.c gdk/win32/gdkproperty-win32.c
gdk/win32/gdkselection-win32.c gdk/win32/gkwindow-win32.c:
Turn singlehead functions into "multihead" functions that ignore
their GdkDisplay or GdkScreen arguments.
* gdk/win32/gdkdrawable-win32.c gdk/win32/gdkevents-win32.c
gdk/win32/gdkinput-win32.c gdk/win32/gdkprivate-win32.h:
Misc multihead-compatibility changes.
* gtk/gtk.def gdk/gdk.def: Update for multihead functions.
* gdk/gdkcolormap.h gdk/gdkvisual.h gdk/x11/gdkcolormap-x11.c
gdk/x11/gdkvisual-x11.c: Remove the screen fields
from the public parts of the colormap/visual structures, add accessors
instead.
* gdk/gdkpixbuf-render.c gdk/gdkpixmap.c gdk/gdkrgb.c
gdk/x11/gdkcolormap-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkimage-x11.c gdk/x11/gdkprivate-x11.h gtk/gtkgc.c
gtk/gtkstyle.c gtk/gtkwidget.c: Use accessors to get the screen
for colormaps, visuals; move the fields into the private
structures for the x11 backend.
* gdk/gdkdisplay.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/gdkscreen.[ch] gdk/x11/gdkscreen-x11.c:
Remove virtualization of screen and display functions.
(#79990, patch from Erwann Chenede)
* gdk/win32/gdkdisplay-x11.c gdk/win32/gdkscreen-win32.c
gdk/win32/{Makefile.am, makefile.msc, makefile.mingw}:
New files containing stub implementations of Display,
Screen functions.
* gdk/x11/gdkscreen-x11.[ch] gdk/x11/gdkdisplay-x11.[ch]
gdk/x11/gdkx.h: Clean up function exports and what
headers they are in. (#79954)
* gdk/x11/gdkx.h: Fix macro that was referring to a non-existant
screen->screen_num. (In the patch for #79972, Erwann Chenede)
* gdk/gdkscreen.c gdk/gdkwindow.c gdk/x11/gdkinternals.h
gdk/x11/gdkscreen-x11.c: Fix gdk_screen_get_window_at_pointer()
to use window hooks. (#79972, patch partly from Erwann Chenede)
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkevents-x11.c: Fix
some warnings.
2002-06-06 00:26:42 +00:00
|
|
|
*mask_return = gdk_pixmap_new (gdk_screen_get_root_window (screen),
|
2002-04-25 22:29:14 +00:00
|
|
|
gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), 1);
|
|
|
|
|
2000-06-21 23:29:51 +00:00
|
|
|
gdk_pixbuf_render_threshold_alpha (pixbuf, *mask_return,
|
|
|
|
0, 0, 0, 0,
|
2001-09-07 22:33:09 +00:00
|
|
|
gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
|
2000-06-21 23:29:51 +00:00
|
|
|
alpha_threshold);
|
2000-01-17 01:48:21 +00:00
|
|
|
}
|
2000-06-21 23:29:51 +00:00
|
|
|
else
|
|
|
|
*mask_return = NULL;
|
|
|
|
}
|
2000-01-14 20:59:18 +00:00
|
|
|
}
|