Re: help on plotting the image from a webcam!!!
- From: Chris Nystrom <ccn olenska hn org>
- To: simith nambiar <simithn yahoo com>
- Cc: gtk-list gnome org
- Subject: Re: help on plotting the image from a webcam!!!
- Date: Thu, 23 May 2002 03:11:18 -0500 (CDT)
On Thu, 23 May 2002, simith nambiar wrote:
> iam newbie for linux as well as gtk, and i
> wanted to develop an application (VOIP) for my
> project.
> I have a webcam from which i would be grabbing frames
> ,so can i plot the data on a drawing board or any
> componenet of gtk, In case it is possible could u plz
> tell me what to use and how to do it.
Here is a small demo of how to display an image using Gtk+ 1.x and Imlib.
I ended up using gdk-pixbuf instead, but do not have a handy demo program
of that.
Chris
--
/*
*
* show-it.c
*
*/
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk_imlib.h>
gint
delete_window(GtkWidget *widget)
{
return(FALSE);
}
gint
destroy_window(GtkWidget *window, gpointer data)
{
gtk_main_quit();
return(FALSE);
}
int main(int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *event_box;
GtkWidget *gtk_pixmap;
GdkPixmap *pixmap;
GdkImlibImage *image;
gint width, height;
if (argc<=1)
{
printf("Usage:\n %s image_file\n",argv[0]);
exit(1);
}
gtk_init(&argc, &argv);
gdk_imlib_init();
gtk_widget_push_visual(gdk_imlib_get_visual());
gtk_widget_push_colormap(gdk_imlib_get_colormap());
image = gdk_imlib_load_image(argv[1]);
width = image->rgb_width;
height = image -> rgb_height;
gdk_imlib_render(image, width, height);
pixmap = gdk_imlib_move_image(image);
event_box = gtk_event_box_new();
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_pixmap = gtk_pixmap_new(pixmap, NULL);
gtk_window_set_default_size(GTK_WINDOW(window), 700, 700);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (delete_window), NULL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC (destroy_window), NULL);
gtk_container_add (GTK_CONTAINER(event_box), gtk_pixmap);
gtk_container_add (GTK_CONTAINER(window), event_box);
gtk_widget_show (gtk_pixmap);
gtk_widget_show (event_box);
gtk_widget_show(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]