Re: pixmap loading slowness
- From: Owen Taylor <owt1 cornell edu>
- To: ALT2376 ritvax isc rit edu
- Cc: gtk-list redhat com
- Subject: Re: pixmap loading slowness
- Date: 07 Feb 1998 11:10:23 -0500
ALT2376@ritvax.isc.rit.edu writes:
> has anyone noticed that gdk_create_pixmap_from_xpm_d() is very slow?.
> Its like 10 times slower than gdk_create_pixmap_from_xpm(). Gimp doesnt even
> use this routine to embed pixmap. Does anyone else have an alternative
> way(shorter) other than what gimp does?.
If you told me that gdk_create_pixmap_from_xpm() was slow, I wouldn't
be suprised (that's a known problem). But I'm suprised that
gdk_create_pixmap_from_xpm_d() is any slower - it appears to be
simply the code in the former with the file operations taken out.
I have some patches sitting around that I wrote but never tested,
that should help from_xpm() - they change a lot of fscanf(...,"%c"...)
to getc() - more than 10x faster. But if _xpm_d() is equally slow,
than there isn't much point in putting them in.
The problem with the gdk_create_pixmap... functions is actually
pretty obvious. They use XPutPixel for _each_ pixel in the image!
(talk about lots of server traffic). It wouldn't be that hard
to write something better (using code from GdkPreview)
but it feels a lot like re-creating the wheel.
Right now I'm thinking it might be best just to go back to using
libXpm - though it would be good to investigate just why we
switched from it in the first place. I think there might have
been problems with broken versions of libXpm... Also, there would
be problems with libXpm allocating colors outside of GDK's
control
As for your immediate problem, if you're willing to link with
libXpm, and you're desperate you could try the following:
It's code from the original gdk_create_pixmap, modified to
do special things for gsumi (substitute colors), and re-modified
not to do that. (I haven't tried out the code after that last step...)
You could also look at using gdk_imlib, though I'm not sure
that can deal with embedded data.
Regards,
Owen
----
#include "gdk/gdk.h"
#include "gdk/gdkprivate.h"
GdkPixmap*
create_icon_pixmap (GdkWindow *window, gchar **pixmap_data)
{
GdkPixmap *pixmap;
GdkWindowPrivate *private;
GdkWindowPrivate *window_private;
GdkColormap *colormap;
GdkVisual *visual;
Pixmap shapemask;
XpmAttributes attributes;
int depth;
int status;
int i;
if (!window)
window = (GdkWindow*) &gdk_root_parent;
private = g_new (GdkWindowPrivate, 1);
pixmap = (GdkPixmap*) private;
window_private = (GdkWindowPrivate*) window;
private->parent = NULL;
private->xdisplay = window_private->xdisplay;
private->window_type = GDK_WINDOW_PIXMAP;
private->x = 0;
private->y = 0;
private->resize_count = 0;
private->ref_count = 1;
private->destroyed = FALSE;
private->parent = NULL;
colormap = gdk_window_get_colormap (window);
visual = gdk_window_get_visual (window);
gdk_window_get_geometry (window, NULL, NULL, NULL, NULL, &depth);
attributes.valuemask = (XpmSize |
XpmColormap |
XpmDepth |
XpmVisual |
XpmCloseness);
attributes.colormap = ((GdkColormapPrivate*) colormap)->xcolormap;
attributes.visual = ((GdkVisualPrivate*) visual)->xvisual;
attributes.depth = depth;
attributes.closeness = 65535;
status = XpmCreatePixmapFromData(private->xdisplay,
window_private->xwindow,
pixmap_data,
&private->xwindow,
&shapemask,
&attributes);
if (status != XpmSuccess)
{
g_free (private);
return NULL;
}
private->width = attributes.width;
private->height = attributes.height;
gdk_xid_table_insert (&private->xwindow, pixmap);
return pixmap;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]