gdk: Remove data consructors for GdkPixmap

That is all of the gdk_pixmap/bitmap_create_from_* constructors.
This commit is contained in:
Benjamin Otte 2010-08-06 23:27:09 +02:00
parent 4f37e6833c
commit c9d08d02e5
12 changed files with 1 additions and 793 deletions

View File

@ -245,12 +245,6 @@ gdk_screen_get_type
<FILE>pixmaps</FILE>
GdkPixmap
gdk_pixmap_new
gdk_bitmap_create_from_data
gdk_pixmap_create_from_data
gdk_pixmap_create_from_xpm
gdk_pixmap_colormap_create_from_xpm
gdk_pixmap_create_from_xpm_d
gdk_pixmap_colormap_create_from_xpm_d
GdkBitmap
<SUBSECTION Standard>

View File

@ -49,78 +49,6 @@ for the new pixmap. Can be %NULL if @depth is specified,
@Returns: the #GdkPixmap
<!-- ##### FUNCTION gdk_bitmap_create_from_data ##### -->
<para>
Creates a new bitmap from data in XBM format.
</para>
@drawable: a #GdkDrawable, used to determine default values
for the new pixmap. Can be %NULL, in which case the root
window is used.
@data: a pointer to the XBM data.
@width: the width of the new pixmap in pixels.
@height: the height of the new pixmap in pixels.
@Returns: the #GdkBitmap
<!-- ##### FUNCTION gdk_pixmap_create_from_data ##### -->
<para>
Create a two-color pixmap from data in XBM data.
</para>
@drawable: a #GdkDrawable, used to determine default values
for the new pixmap. Can be %NULL, if the depth is given.
@data: a pointer to the data.
@width: the width of the new pixmap in pixels.
@height: the height of the new pixmap in pixels.
@depth: the depth (number of bits per pixel) of the new pixmap.
@fg: the foreground color.
@bg: the background color.
@Returns: the #GdkPixmap
<!-- ##### FUNCTION gdk_pixmap_create_from_xpm ##### -->
@drawable:
@mask:
@transparent_color:
@filename:
@Returns:
<!-- ##### FUNCTION gdk_pixmap_colormap_create_from_xpm ##### -->
@drawable:
@colormap:
@mask:
@transparent_color:
@filename:
@Returns:
<!-- ##### FUNCTION gdk_pixmap_create_from_xpm_d ##### -->
@drawable:
@mask:
@transparent_color:
@data:
@Returns:
<!-- ##### FUNCTION gdk_pixmap_colormap_create_from_xpm_d ##### -->
@drawable:
@colormap:
@mask:
@transparent_color:
@data:
@Returns:
<!-- ##### TYPEDEF GdkBitmap ##### -->
<para>
An opaque structure representing an offscreen drawable of depth

View File

@ -194,111 +194,6 @@ _gdk_pixmap_new (GdkDrawable *drawable,
return pixmap;
}
GdkPixmap *
_gdk_bitmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height)
{
GdkPixmap *pixmap;
g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (width > 0 && height > 0, NULL);
GDK_NOTE (MISC, g_print ("gdk_bitmap_create_from_data: %dx%d\n",
width, height));
pixmap = gdk_pixmap_new (drawable, width, height, 1);
#define GET_PIXEL(data,pixel) \
((data[(pixel / 8)] & (0x1 << ((pixel) % 8))) >> ((pixel) % 8))
if (pixmap)
{
guchar *dst;
gint pitch;
IDirectFBSurface *surface;
surface = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_PIXMAP_OBJECT (pixmap)->impl)->surface;
if (surface->Lock( surface, DSLF_WRITE, (void**)(&dst), &pitch ) == DFB_OK)
{
gint i, j;
for (i = 0; i < height; i++)
{
for (j = 0; j < width; j++)
{
dst[j] = GET_PIXEL (data, j) * 255;
}
data += (width + 7) / 8;
dst += pitch;
}
surface->Unlock( surface );
}
}
#undef GET_PIXEL
return pixmap;
}
GdkPixmap*
_gdk_pixmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height,
gint depth,
const GdkColor *fg,
const GdkColor *bg)
{
GdkPixmap *pixmap;
g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (drawable != NULL || depth > 0, NULL);
g_return_val_if_fail (width > 0 && height > 0, NULL);
GDK_NOTE (MISC, g_print ("gdk_pixmap_create_from_data: %dx%dx%d\n",
width, height, depth));
pixmap = gdk_pixmap_new (drawable, width, height, depth);
if (pixmap)
{
IDirectFBSurface *surface;
gchar *dst;
gint pitch;
gint src_pitch;
depth = gdk_drawable_get_depth (pixmap);
src_pitch = width * ((depth + 7) / 8);
surface = GDK_DRAWABLE_IMPL_DIRECTFB (GDK_PIXMAP_OBJECT (pixmap)->impl)->surface;
if (surface->Lock( surface,
DSLF_WRITE, (void**)(&dst), &pitch ) == DFB_OK)
{
gint i;
for (i = 0; i < height; i++)
{
memcpy (dst, data, src_pitch);
dst += pitch;
data += src_pitch;
}
surface->Unlock( surface );
}
}
return pixmap;
}
GdkPixmap*
gdk_pixmap_foreign_new (GdkNativeWindow anid)
{

View File

@ -851,12 +851,6 @@ gdk_pixbuf_render_threshold_alpha
#if IN_HEADER(__GDK_PIXMAP_H__)
#if IN_FILE(__GDK_PIXMAP_C__)
gdk_bitmap_create_from_data
gdk_pixmap_colormap_create_from_xpm
gdk_pixmap_create_from_data
gdk_pixmap_create_from_xpm
gdk_pixmap_colormap_create_from_xpm_d
gdk_pixmap_create_from_xpm_d
gdk_pixmap_get_type G_GNUC_CONST
gdk_pixmap_new
#endif

View File

@ -332,17 +332,6 @@ GdkPixmap *_gdk_pixmap_new (GdkDrawable *drawable,
gint width,
gint height,
gint depth);
GdkPixmap *_gdk_pixmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height,
gint depth,
const GdkColor *fg,
const GdkColor *bg);
GdkPixmap *_gdk_bitmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height);
void _gdk_window_impl_new (GdkWindow *window,
GdkWindow *real_parent,

View File

@ -123,38 +123,6 @@ gdk_pixmap_new (GdkDrawable *drawable,
return _gdk_pixmap_new (source_drawable, width, height, depth);
}
GdkPixmap *
gdk_bitmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height)
{
GdkDrawable *source_drawable;
if (drawable)
source_drawable = _gdk_drawable_get_source_drawable (drawable);
else
source_drawable = NULL;
return _gdk_bitmap_create_from_data (source_drawable, data, width, height);
}
GdkPixmap*
gdk_pixmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height,
gint depth,
const GdkColor *fg,
const GdkColor *bg)
{
GdkDrawable *source_drawable;
source_drawable = _gdk_drawable_get_source_drawable (drawable);
return _gdk_pixmap_create_from_data (source_drawable,
data, width, height,
depth, fg,bg);
}
static void
gdk_pixmap_real_get_size (GdkDrawable *drawable,
gint *width,
@ -221,221 +189,6 @@ gdk_pixmap_create_cairo_surface (GdkDrawable *drawable,
width, height);
}
static GdkBitmap *
make_solid_mask (GdkScreen *screen, gint width, gint height)
{
GdkBitmap *bitmap;
cairo_t *cr;
bitmap = gdk_pixmap_new (gdk_screen_get_root_window (screen),
width, height, 1);
cr = gdk_cairo_create (bitmap);
cairo_paint (cr);
cairo_destroy (cr);
return bitmap;
}
#define PACKED_COLOR(c) ((((c)->red & 0xff00) << 8) | \
((c)->green & 0xff00) | \
((c)->blue >> 8))
static GdkPixmap *
gdk_pixmap_colormap_new_from_pixbuf (GdkColormap *colormap,
GdkBitmap **mask,
const GdkColor *transparent_color,
GdkPixbuf *pixbuf)
{
GdkPixmap *pixmap;
GdkPixbuf *render_pixbuf;
cairo_t *cr;
GdkScreen *screen = gdk_colormap_get_screen (colormap);
pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen),
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
gdk_colormap_get_visual (colormap)->depth);
gdk_drawable_set_colormap (pixmap, colormap);
if (transparent_color)
{
guint32 packed_color = PACKED_COLOR (transparent_color);
render_pixbuf = gdk_pixbuf_composite_color_simple (pixbuf,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf),
GDK_INTERP_NEAREST,
255, 16, packed_color, packed_color);
}
else
render_pixbuf = pixbuf;
cr = gdk_cairo_create (pixmap);
gdk_cairo_set_source_pixbuf (cr, render_pixbuf, 0, 0);
cairo_paint (cr);
cairo_destroy (cr);
if (render_pixbuf != pixbuf)
g_object_unref (render_pixbuf);
if (mask)
gdk_pixbuf_render_pixmap_and_mask_for_colormap (pixbuf, colormap, NULL, mask, 128);
if (mask && !*mask)
*mask = make_solid_mask (screen,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
return pixmap;
}
/**
* gdk_pixmap_colormap_create_from_xpm:
* @drawable: a #GdkDrawable, used to determine default values
* for the new pixmap. Can be %NULL if @colormap is given.
* @colormap: the #GdkColormap that the new pixmap will be use.
* If omitted, the colormap for @window will be used.
* @mask: a pointer to a place to store a bitmap representing
* the transparency mask of the XPM file. Can be %NULL,
* in which case transparency will be ignored.
* @transparent_color: the color to be used for the pixels
* that are transparent in the input file. Can be %NULL,
* in which case a default color will be used.
* @filename: the filename of a file containing XPM data.
*
* Create a pixmap from a XPM file using a particular colormap.
*
* Returns: (transfer none): the #GdkPixmap.
*/
GdkPixmap*
gdk_pixmap_colormap_create_from_xpm (GdkDrawable *drawable,
GdkColormap *colormap,
GdkBitmap **mask,
const GdkColor *transparent_color,
const gchar *filename)
{
GdkPixbuf *pixbuf;
GdkPixmap *pixmap;
g_return_val_if_fail (drawable != NULL || colormap != NULL, NULL);
g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (colormap == NULL || GDK_IS_COLORMAP (colormap), NULL);
if (colormap == NULL)
colormap = gdk_drawable_get_colormap (drawable);
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
if (!pixbuf)
return NULL;
pixmap = gdk_pixmap_colormap_new_from_pixbuf (colormap, mask, transparent_color, pixbuf);
g_object_unref (pixbuf);
return pixmap;
}
/**
* gdk_pixmap_create_from_xpm:
* @drawable: a #GdkDrawable, used to determine default values
* for the new pixmap.
* @mask: (out) a pointer to a place to store a bitmap representing
* the transparency mask of the XPM file. Can be %NULL,
* in which case transparency will be ignored.
* @transparent_color: the color to be used for the pixels
* that are transparent in the input file. Can be %NULL,
* in which case a default color will be used.
* @filename: the filename of a file containing XPM data.
*
* Create a pixmap from a XPM file.
*
* Returns: (transfer none): the #GdkPixmap
*/
GdkPixmap*
gdk_pixmap_create_from_xpm (GdkDrawable *drawable,
GdkBitmap **mask,
const GdkColor *transparent_color,
const gchar *filename)
{
return gdk_pixmap_colormap_create_from_xpm (drawable, NULL, mask,
transparent_color, filename);
}
/**
* gdk_pixmap_colormap_create_from_xpm_d:
* @drawable: a #GdkDrawable, used to determine default values
* for the new pixmap. Can be %NULL if @colormap is given.
* @colormap: the #GdkColormap that the new pixmap will be use.
* If omitted, the colormap for @window will be used.
* @mask: a pointer to a place to store a bitmap representing
* the transparency mask of the XPM file. Can be %NULL,
* in which case transparency will be ignored.
* @transparent_color: the color to be used for the pixels
* that are transparent in the input file. Can be %NULL,
* in which case a default color will be used.
* @data: Pointer to a string containing the XPM data.
*
* Create a pixmap from data in XPM format using a particular
* colormap.
*
* Returns: (transfer none): the #GdkPixmap.
*/
GdkPixmap*
gdk_pixmap_colormap_create_from_xpm_d (GdkDrawable *drawable,
GdkColormap *colormap,
GdkBitmap **mask,
const GdkColor *transparent_color,
gchar **data)
{
GdkPixbuf *pixbuf;
GdkPixmap *pixmap;
g_return_val_if_fail (drawable != NULL || colormap != NULL, NULL);
g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (colormap == NULL || GDK_IS_COLORMAP (colormap), NULL);
if (colormap == NULL)
colormap = gdk_drawable_get_colormap (drawable);
pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)data);
if (!pixbuf)
return NULL;
pixmap = gdk_pixmap_colormap_new_from_pixbuf (colormap, mask, transparent_color, pixbuf);
g_object_unref (pixbuf);
return pixmap;
}
/**
* gdk_pixmap_create_from_xpm_d:
* @drawable: a #GdkDrawable, used to determine default values
* for the new pixmap.
* @mask: (out): Pointer to a place to store a bitmap representing
* the transparency mask of the XPM file. Can be %NULL,
* in which case transparency will be ignored.
* @transparent_color: This color will be used for the pixels
* that are transparent in the input file. Can be %NULL
* in which case a default color will be used.
* @data: Pointer to a string containing the XPM data.
*
* Create a pixmap from data in XPM format.
*
* Returns: (transfer none): the #GdkPixmap.
*/
GdkPixmap*
gdk_pixmap_create_from_xpm_d (GdkDrawable *drawable,
GdkBitmap **mask,
const GdkColor *transparent_color,
gchar **data)
{
return gdk_pixmap_colormap_create_from_xpm_d (drawable, NULL, mask,
transparent_color, data);
}
static GdkScreen*
gdk_pixmap_real_get_screen (GdkDrawable *drawable)
{

View File

@ -70,36 +70,6 @@ GdkPixmap* gdk_pixmap_new (GdkDrawable *drawable,
gint width,
gint height,
gint depth);
GdkBitmap* gdk_bitmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height);
GdkPixmap* gdk_pixmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height,
gint depth,
const GdkColor *fg,
const GdkColor *bg);
GdkPixmap* gdk_pixmap_create_from_xpm (GdkDrawable *drawable,
GdkBitmap **mask,
const GdkColor *transparent_color,
const gchar *filename);
GdkPixmap* gdk_pixmap_colormap_create_from_xpm (GdkDrawable *drawable,
GdkColormap *colormap,
GdkBitmap **mask,
const GdkColor *transparent_color,
const gchar *filename);
GdkPixmap* gdk_pixmap_create_from_xpm_d (GdkDrawable *drawable,
GdkBitmap **mask,
const GdkColor *transparent_color,
gchar **data);
GdkPixmap* gdk_pixmap_colormap_create_from_xpm_d (GdkDrawable *drawable,
GdkColormap *colormap,
GdkBitmap **mask,
const GdkColor *transparent_color,
gchar **data);
/* Functions to create/lookup pixmaps from their native equivalents
*/

View File

@ -576,8 +576,6 @@ gboolean gdk_window_ensure_native (GdkWindow *window);
/*
* This allows for making shaped (partially transparent) windows
* - cool feature, needed for Drag and Drag for example.
* The shape_mask can be the mask
* from gdk_pixmap_create_from_xpm. Stefan Wille
*/
void gdk_window_shape_combine_mask (GdkWindow *window,
GdkBitmap *mask,

View File

@ -223,59 +223,6 @@ _gdk_pixmap_new (GdkDrawable *drawable,
return pixmap;
}
GdkPixmap *
_gdk_bitmap_create_from_data (GdkDrawable *window,
const gchar *data,
gint width,
gint height)
{
GdkPixmap *pixmap;
GdkPixmapImplQuartz *impl;
int x, y, bpl;
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
g_return_val_if_fail (window == NULL || GDK_IS_DRAWABLE (window), NULL);
pixmap = gdk_pixmap_new (window, width, height, 1);
impl = GDK_PIXMAP_IMPL_QUARTZ (GDK_PIXMAP_OBJECT (pixmap)->impl);
g_assert (CGImageGetBytesPerRow (impl->image) == width);
/* Bytes per line: Each line consumes an integer number of bytes, possibly
* ignoring any excess bits. */
bpl = (width + 7) / 8;
for (y = 0; y < height; y++)
{
guchar *dst = impl->data + y * width;
const gchar *src = data + (y * bpl);
for (x = 0; x < width; x++)
{
if ((src[x / 8] >> x % 8) & 1)
*dst = 0xff;
else
*dst = 0;
dst++;
}
}
return pixmap;
}
GdkPixmap*
_gdk_pixmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height,
gint depth,
const GdkColor *fg,
const GdkColor *bg)
{
/* FIXME: Implement */
return NULL;
}
GdkPixmap *
gdk_pixmap_foreign_new_for_display (GdkDisplay *display,
GdkNativeWindow anid)

View File

@ -312,131 +312,6 @@ _gdk_pixmap_new (GdkDrawable *drawable,
return pixmap;
}
static const unsigned char mirror[256] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
GdkPixmap *
_gdk_bitmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height)
{
GdkPixmap *pixmap;
GdkPixmapImplWin32 *pixmap_impl;
gint i, j, data_bpl, pixmap_bpl;
guchar *bits;
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
if (!drawable)
drawable = _gdk_root;
else if (GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable))
return NULL;
pixmap = gdk_pixmap_new (drawable, width, height, 1);
if (pixmap == NULL)
return NULL;
pixmap_impl = GDK_PIXMAP_IMPL_WIN32 (GDK_PIXMAP_OBJECT (pixmap)->impl);
bits = pixmap_impl->bits;
data_bpl = ((width - 1) / 8 + 1);
pixmap_bpl = ((width - 1)/32 + 1)*4;
for (i = 0; i < height; i++)
for (j = 0; j < data_bpl; j++)
bits[i*pixmap_bpl + j] = mirror[(guchar) data[i*data_bpl + j]];
GDK_NOTE (PIXMAP, g_print ("gdk_bitmap_create_from_data: %dx%d=%p\n",
width, height, GDK_PIXMAP_HBITMAP (pixmap)));
return pixmap;
}
GdkPixmap*
_gdk_pixmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height,
gint depth,
const GdkColor *fg,
const GdkColor *bg)
{
/* Oh wow. I struggled with dozens of lines of code trying to get
* this right using a monochrome Win32 bitmap created from data, and
* a colour DIB section as the result, trying setting pens,
* background colors, whatnot and BitBlt:ing. Nope. Then finally I
* realized it's much easier to do it using gdk...:
*/
GdkPixmap *result;
GdkPixmap *source;
GdkGC *gc;
g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (fg != NULL, NULL);
g_return_val_if_fail (bg != NULL, NULL);
g_return_val_if_fail ((drawable != NULL) || (depth != -1), NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
if (GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable))
return NULL;
result = gdk_pixmap_new (drawable, width, height, depth);
source = gdk_bitmap_create_from_data (drawable, data, width, height);
gc = gdk_gc_new (result);
gdk_gc_set_foreground (gc, fg);
gdk_gc_set_background (gc, bg);
_gdk_win32_blit
(TRUE,
GDK_DRAWABLE_IMPL_WIN32 (GDK_PIXMAP_OBJECT (result)->impl),
gc, source, 0, 0, 0, 0, width, height);
g_object_unref (source);
g_object_unref (gc);
GDK_NOTE (PIXMAP, g_print ("gdk_pixmap_create_from_data: %dx%dx%d=%p\n",
width, height, depth,
GDK_PIXMAP_HBITMAP (result)));
return result;
}
GdkPixmap *
gdk_pixmap_foreign_new_for_display (GdkDisplay *display,
GdkNativeWindow anid)

View File

@ -320,44 +320,7 @@ gdk_cursor_new_for_display (GdkDisplay *display,
*
* Creates a new cursor from a given pixmap and mask. Both the pixmap and mask
* must have a depth of 1 (i.e. each pixel has only 2 values - on or off).
* The standard cursor size is 16 by 16 pixels. You can create a bitmap
* from inline data as in the below example.
*
* <example><title>Creating a custom cursor</title>
* <programlisting>
* /<!-- -->* This data is in X bitmap format, and can be created with the 'bitmap'
* utility. *<!-- -->/
* &num;define cursor1_width 16
* &num;define cursor1_height 16
* static unsigned char cursor1_bits[] = {
* 0x80, 0x01, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x08, 0x10, 0x04, 0x20,
* 0x82, 0x41, 0x41, 0x82, 0x41, 0x82, 0x82, 0x41, 0x04, 0x20, 0x08, 0x10,
* 0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0x80, 0x01};
*
* static unsigned char cursor1mask_bits[] = {
* 0x80, 0x01, 0xc0, 0x03, 0x60, 0x06, 0x30, 0x0c, 0x18, 0x18, 0x8c, 0x31,
* 0xc6, 0x63, 0x63, 0xc6, 0x63, 0xc6, 0xc6, 0x63, 0x8c, 0x31, 0x18, 0x18,
* 0x30, 0x0c, 0x60, 0x06, 0xc0, 0x03, 0x80, 0x01};
*
*
* GdkCursor *cursor;
* GdkPixmap *source, *mask;
* GdkColor fg = { 0, 65535, 0, 0 }; /<!-- -->* Red. *<!-- -->/
* GdkColor bg = { 0, 0, 0, 65535 }; /<!-- -->* Blue. *<!-- -->/
*
*
* source = gdk_bitmap_create_from_data (NULL, cursor1_bits,
* cursor1_width, cursor1_height);
* mask = gdk_bitmap_create_from_data (NULL, cursor1mask_bits,
* cursor1_width, cursor1_height);
* cursor = gdk_cursor_new_from_pixmap (source, mask, &amp;fg, &amp;bg, 8, 8);
* g_object_unref (source);
* g_object_unref (mask);
*
*
* gdk_window_set_cursor (widget->window, cursor);
* </programlisting>
* </example>
* The standard cursor size is 16 by 16 pixels.
*
* Return value: a new #GdkCursor.
**/

View File

@ -193,104 +193,6 @@ _gdk_pixmap_new (GdkDrawable *drawable,
return pixmap;
}
GdkPixmap *
_gdk_bitmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height)
{
GdkPixmap *pixmap;
GdkDrawableImplX11 *draw_impl;
GdkPixmapImplX11 *pix_impl;
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
if (!drawable)
{
GDK_NOTE (MULTIHEAD, g_message ("need to specify the screen parent window "
"for gdk_bitmap_create_from_data() to be multihead safe"));
drawable = gdk_screen_get_root_window (gdk_screen_get_default ());
}
if (GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable))
return NULL;
pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
draw_impl = GDK_DRAWABLE_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl);
pix_impl = GDK_PIXMAP_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl);
draw_impl->wrapper = GDK_DRAWABLE (pixmap);
pix_impl->is_foreign = FALSE;
pix_impl->width = width;
pix_impl->height = height;
GDK_PIXMAP_OBJECT (pixmap)->depth = 1;
draw_impl->screen = GDK_WINDOW_SCREEN (drawable);
draw_impl->xid = XCreateBitmapFromData (GDK_WINDOW_XDISPLAY (drawable),
GDK_WINDOW_XID (drawable),
(char *)data, width, height);
_gdk_xid_table_insert (GDK_WINDOW_DISPLAY (drawable),
&GDK_PIXMAP_XID (pixmap), pixmap);
return pixmap;
}
GdkPixmap*
_gdk_pixmap_create_from_data (GdkDrawable *drawable,
const gchar *data,
gint width,
gint height,
gint depth,
const GdkColor *fg,
const GdkColor *bg)
{
GdkPixmap *pixmap;
GdkDrawableImplX11 *draw_impl;
GdkPixmapImplX11 *pix_impl;
g_return_val_if_fail (drawable == NULL || GDK_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (fg != NULL, NULL);
g_return_val_if_fail (bg != NULL, NULL);
g_return_val_if_fail ((drawable != NULL) || (depth != -1), NULL);
g_return_val_if_fail ((width != 0) && (height != 0), NULL);
if (!drawable)
{
GDK_NOTE (MULTIHEAD, g_message ("need to specify the screen parent window"
"for gdk_pixmap_create_from_data() to be multihead safe"));
drawable = gdk_screen_get_root_window (gdk_screen_get_default ());
}
if (GDK_IS_WINDOW (drawable) && GDK_WINDOW_DESTROYED (drawable))
return NULL;
if (depth == -1)
depth = gdk_drawable_get_visual (drawable)->depth;
pixmap = g_object_new (gdk_pixmap_get_type (), NULL);
draw_impl = GDK_DRAWABLE_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl);
pix_impl = GDK_PIXMAP_IMPL_X11 (GDK_PIXMAP_OBJECT (pixmap)->impl);
draw_impl->wrapper = GDK_DRAWABLE (pixmap);
pix_impl->is_foreign = FALSE;
pix_impl->width = width;
pix_impl->height = height;
GDK_PIXMAP_OBJECT (pixmap)->depth = depth;
draw_impl->screen = GDK_DRAWABLE_SCREEN (drawable);
draw_impl->xid = XCreatePixmapFromBitmapData (GDK_WINDOW_XDISPLAY (drawable),
GDK_WINDOW_XID (drawable),
(char *)data, width, height,
fg->pixel, bg->pixel, depth);
_gdk_xid_table_insert (GDK_WINDOW_DISPLAY (drawable),
&GDK_PIXMAP_XID (pixmap), pixmap);
return pixmap;
}
/**
* gdk_pixmap_foreign_new_for_display:
* @display: The #GdkDisplay where @anid is located.