newbie/foolish question: gdk-pixbuf and gtk
- From: "Richard L" <rklaird hotmail com>
- To: gtk-list redhat com
- Subject: newbie/foolish question: gdk-pixbuf and gtk
- Date: Wed, 23 Feb 2000 22:06:59 GMT
I am trying to make part of a program that displays a jpg image. My program
compiles, but i get the following error when i exec it:
** CRITICAL **: file gdk-pixbuf-render.c: line 211
(gdk_pixbuf_render_to_drawable): assertion 'src_y >= 0 && src_y + height <=
apb->height' failed.
this error prints whenever the window needs to redraw, for example, when i
drag another window in front of my app. besides this error, the drawing
area does not seem to show up, so i sincerely doubt that i am doing this
correctly. please don't berate me for posting here; i know that this is a
newbie problem. nevertheless, i would greatly appreciate help on this one
(maybe if i figure this out, you'll never hear from me again!).
to help you help me, here is the fubar source:
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
//the widgets and stuff
GtkWidget *window;
GtkWidget *drawing_area;
GdkPixbuf *pixbuf;
gint exposure(GtkWidget *widget,GdkEventExpose *event)
{
gdk_pixbuf_render_to_drawable(pixbuf,
drawing_area->window,
drawing_area->style->white_gc,
0, 0,
0, 0,
200, 200,
GDK_RGB_DITHER_NORMAL,
0, 0);
return FALSE;
}
int main(int argc, char *argv[])
{
//init gtk
gtk_init(&argc, &argv);
//init gdkrgb
gdk_rgb_init();
//make the window
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
//the window housekeeping
gtk_window_set_title(GTK_WINDOW(window), "pixbuf?");
gtk_widget_set_usize(window, 300, 300);
//connect the destroy handler
gtk_signal_connect(GTK_OBJECT(window), "destroy",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
/* ok, finished with the window */
//make the drawing area with the grkrgb visual and cmap things
gtk_widget_push_visual(gdk_rgb_get_visual());
gtk_widget_push_colormap(gdk_rgb_get_cmap());
drawing_area = gtk_drawing_area_new();
gtk_widget_pop_visual();
gtk_widget_pop_colormap();
gtk_drawing_area_size(GTK_DRAWING_AREA(drawing_area), 200, 200);
gtk_container_add(GTK_CONTAINER(window), drawing_area);
gtk_widget_set_events(GTK_WIDGET(drawing_area),GDK_EXPOSURE_MASK);
gtk_signal_connect(GTK_OBJECT(drawing_area),"expose_event",GTK_SIGNAL_FUNC(exposure),NULL);
gtk_widget_realize(drawing_area);
//the pixbuf
pixbuf = gdk_pixbuf_new_from_file("file");
gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
//show it
gtk_widget_show_all(window);
gtk_main();
return(0);
}
thanks again,
-rklaird
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]