Displaying video4linux grayscale captures in GTK?



Hi all,

I am experimenting with the video4linux API for self-training, using an
OV511+ based webcam as source. I have successfully displayed streaming
color images using:
.
vid_mmap.format = VIDEO_PALETTE_YUV420P;
.
ioctl(cam, VIDIOCMCAPTURE, &vid_mmap);
.
yuv420p_to_rgb24( &vid_out, &vid_in ); // Adapted from 'lib-ng' of xawtv
gdk_draw_rgb_image( GTK_WIDGET(darea)->window,
                    GTK_WIDGET(darea)->style->fg_gc[GTK_STATE_NORMAL],
                    0, 0, COLS, ROWS,
                    GDK_RGB_DITHER_MAX, vid_out.data, COLS*3);

I have also succeeded in displaying grayscale images using:
.
yuv42xp_to_gray( &vid_out, &vid_in ); // Adapted from 'lib-ng' of xawtv
gdk_draw_gray_image( GTK_WIDGET(darea)->window,
                     GTK_WIDGET(darea)->style->fg_gc[GTK_STATE_NORMAL],
                     0, 0, COLS, ROWS,
                     GDK_RGB_DITHER_MAX, vid_out.data, COLS);

I have failed, however, to display grayscale images when specifying
.
vid_mmap.format = VIDEO_PALETTE_GRAY;
.
gdk_draw_gray_image( GTK_WIDGET(darea)->window,
                     GTK_WIDGET(darea)->style->fg_gc[GTK_STATE_NORMAL],
                     0, 0, COLS, ROWS,
                     GDK_RGB_DITHER_MAX, buff, COLS);

where 'buff' is used as is filled by the capture ioctl and with no
colorspace convertion. The problem with this setup is that the images
displayed are stretched horizontally and have thin vertical bands. I
presume this is due to the VIDEO_PALETTE_GRAY image format being
incompatible with gdk_draw_gray_image() but failed to find a fix!

I am very greateful to any hints or tips on the subject.

My thanks in advance!

-- 
Regards

Neoklis    Ham Radio callsign: 5B4AZ  QTH Loc: KM64MR



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]