From: Kouhei Sutou Date: 2006-11-11T12:58:41+09:00 Subject: Re: Linux Cairo, webcam displaying images Hi, In <45551ebe_5@news.peopletelecom.com.au> "Linux Cairo, webcam displaying images" on Sat, 11 Nov 2006 09:00:08 +0900, Mike Durham wrote: > Can anyone please advise me on how to constantly display the output from > a webcam using Ruby & Cairo? Data from webcam (String) -> Gdk::Pixbuf -> Cairo::ImageSurface.new(data, format, width, height, stride) -> Cairo::Context.new(Cairo::XXXSurface.new) -> context.set_source(image_surface) -> context.paint > The data returned from V4l is a ruby 'string' but how do I display it? > At first I thought to display a blank Gdk::Pixbuf of correct size > (640x480) and constantly modify it's buffer but I think this might not > be possible from within Ruby??? Use Gdk::Pixbuf.new(data, colorspace, has_alpha, bit_per_sample, width, height, rowstride): Creates a new Gdk::Pixbuf out of in-memory image data. Currently only RGB images with 8 bits per sample are supported. Raises an Gdk::PixbufError if there was not enough memory. * data: Image data in 8-bit/sample packed format(String). * colorspace: Color space(GdkColorspace) for image data. * has_alpha: true if the data has an opacity channel or false. * bits_per_sample: Number of bits per color sample. * width: Width of image in pixels. * height: Height of image in pixels. * rowstride: Distance in bytes between row starts. * Returns: A newly-created Gdk::Pixbuf. Thanks, -- kou