1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
28 /* Note: these #includes differ slightly from the testrgb.c file included
29 in the GdkRgb release. */
31 /* For gettimeofday */
37 #include "gdk-pixbuf.h"
40 quit_func (GtkWidget *widget, gpointer dummy)
45 expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
47 GdkPixBuf *pixbuf = (GdkPixBuf *)data;
50 if (pixbuf->art_pixbuf->has_alpha){
51 gdk_draw_rgb_32_image (drawing_area->window,
52 drawing_area->style->black_gc,
53 event->area.x, event->area.y,
57 pixbuf->art_pixbuf->pixels
58 + (event->area.y * pixbuf->art_pixbuf->rowstride)
59 + (event->area.x * pixbuf->art_pixbuf->n_channels),
60 pixbuf->art_pixbuf->rowstride);
62 gdk_draw_rgb_image (drawing_area->window,
63 drawing_area->style->white_gc,
64 event->area.x, event->area.y,
67 GDK_RGB_DITHER_NORMAL,
68 pixbuf->art_pixbuf->pixels
69 + (event->area.y * pixbuf->art_pixbuf->rowstride)
70 + (event->area.x * pixbuf->art_pixbuf->n_channels),
71 pixbuf->art_pixbuf->rowstride);
76 new_testrgb_window (GdkPixBuf *pixbuf)
81 GtkWidget *drawing_area;
84 w = pixbuf->art_pixbuf->width;
85 h = pixbuf->art_pixbuf->height;
87 window = gtk_widget_new (gtk_window_get_type (),
88 "GtkObject::user_data", NULL,
89 "GtkWindow::type", GTK_WINDOW_TOPLEVEL,
90 "GtkWindow::title", "testrgb",
91 "GtkWindow::allow_shrink", FALSE,
93 gtk_signal_connect (GTK_OBJECT (window), "destroy",
94 (GtkSignalFunc) quit_func, NULL);
96 vbox = gtk_vbox_new (FALSE, 0);
98 drawing_area = gtk_drawing_area_new ();
100 gtk_widget_set_usize (drawing_area, w, h);
101 gtk_box_pack_start (GTK_BOX (vbox), drawing_area, FALSE, FALSE, 0);
103 gtk_signal_connect (GTK_OBJECT(drawing_area), "expose_event",
104 GTK_SIGNAL_FUNC (expose_func), pixbuf);
106 gtk_widget_show (drawing_area);
108 button = gtk_button_new_with_label ("Quit");
109 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
110 gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
111 (GtkSignalFunc) gtk_widget_destroy,
112 GTK_OBJECT (window));
114 gtk_widget_show (button);
116 gtk_container_add (GTK_CONTAINER (window), vbox);
117 gtk_widget_show (vbox);
119 gtk_widget_show (window);
123 main (int argc, char **argv)
127 gtk_init (&argc, &argv);
129 gdk_rgb_set_verbose (TRUE);
133 gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
134 gtk_widget_set_default_visual (gdk_rgb_get_visual ());
135 pixbuf = gdk_pixbuf_load_image ("test.gif");
137 new_testrgb_window (pixbuf);