More problems with gdk-pixbuf
- From: Loban Rahman <loban enigma caltech edu>
- To: gnome-devel-list gnome org
- Subject: More problems with gdk-pixbuf
- Date: Fri, 21 Apr 2000 03:37:52 -0700
First, thanx James for your previous help. (I must admit that was an
awefully shameful error of mine). ;-)
Now I've got this test code. What it ought to output is a window with
a 4 by 4 grid of the xpm in title_xpm. Instead, the resulting image
is somewhat garbled. If someone could compile it with
gcc `gdk-pixbuf-config --cflags` test.c -o test `gdk-pixbuf-config --libs`
and tell me why the output looks garbled, I'd really appreciate it.
Thanx.
= L
---------------------------------------------------------------------
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
static char * blank_xpm[] = {
"32 32 3 1",
" c None",
". c #000000",
"+ c #FFFFFF",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++",
"++++++++++++++++++++++++++++++++"};
static char * title_xpm[] = {
"8 8 3 1",
" c None",
". c #000000",
"+ c #FFFFFF",
"++++++++",
"++++++++",
"++++++++",
"+++.....",
"+++.....",
"+++..+++",
"+++..+++",
"+++..+++"};
GtkWidget *window, *area;
GdkPixbuf *display, *title;
int refresh_display() {
gdk_pixbuf_render_to_drawable(display, area->window,
area->style->fg_gc[GTK_STATE_NORMAL],
0, 0, 0, 0,
gdk_pixbuf_get_width(display),
gdk_pixbuf_get_height(display),
GDK_RGB_DITHER_NONE,
0, 0);
return 1;
}
int main(int argc, char *argv[]) {
int i, j;
gtk_init (&argc, &argv);
gdk_rgb_init();
gtk_widget_set_default_colormap (gdk_rgb_get_cmap());
gtk_widget_set_default_visual (gdk_rgb_get_visual());
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
area = gtk_drawing_area_new();
display = gdk_pixbuf_new_from_xpm_data(blank_xpm);
gtk_drawing_area_size(GTK_DRAWING_AREA (area),
gdk_pixbuf_get_width(display),
gdk_pixbuf_get_height(display));
gtk_container_add(GTK_CONTAINER (window), area);
gtk_widget_show_all(window);
gtk_signal_connect(GTK_OBJECT(window), "delete_event",
gtk_main_quit, NULL);
gtk_timeout_add(50, refresh_display, NULL);
title = gdk_pixbuf_new_from_xpm_data(title_xpm);
for(i = 0; i < 4; i++) {
for(j = 0; j < 4; j++) {
gdk_pixbuf_copy_area(title, 0, 0,
gdk_pixbuf_get_width(title),
gdk_pixbuf_get_height(title),
display, i * 8, j * 8);
}
}
gtk_main();
}
---------------------------------------------------------------------
/-------------------------------------------------------------------\
| LOBAN AMAAN RAHMAN <-- anagram of --> AHA! AN ABNORMAL MAN! |
| MSC #763, Caltech, Pasadena, CA 91126, USA. Tel: 1-626-395-1407 |
| loban@earthling.net, loban@caltech.edu, http://i.am/loban |
\-------------------------------------------------------------------/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]