--- vidcat.c.old Tue May 2 22:33:29 2000 +++ vidcat.c Thu May 4 23:30:59 2000 @@ -4,6 +4,10 @@ * Copyright (C) 1998 Rasca, Berlin * EMail: thron@gmx.de * + * Modified by Jeroen Vreeken pe1rxq@amsat.org + * + * Changes: Added correct size handling, early close. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -69,7 +73,7 @@ usage (char *pname) { fprintf (stderr, - "VidCat, Version %s\n" + "VidCat, Version %s.pe1rxq\n" "Usage: %s \n" " -s NxN define size of the output image (default:" " %dx%d)\n" @@ -96,6 +100,7 @@ struct video_mbuf vid_buf; struct video_mmap vid_mmap; struct video_channel vid_chnl; + struct video_window vid_win; char *map; int len; @@ -116,6 +121,16 @@ } } } + /* Set the device to the correct size + * (added by J. Vreeken pe1rxq@amsat.org) + */ + if (ioctl (dev, VIDIOCGWIN, &vid_win) == -1) + return (NULL); + vid_win.width=width; + vid_win.height=height; + if (ioctl (dev, VIDIOCSWIN, &vid_win) == -1) + return (NULL); + if (ioctl (dev, VIDIOCGMBUF, &vid_buf) == -1) { /* to do a normal read() */ @@ -350,6 +365,9 @@ } } image = get_image (dev, width, height, input, norm, palette, &size); + /* Close the device now, no need to keep it open while converting. + * (Jeroen Vreeken pe1rxq@amsat.org) */ + close (dev); if (image) { switch (format) { case FMT_PPM: @@ -374,7 +392,6 @@ } else { fprintf (stderr, "Error: Can't get image\n"); } - close (dev); return (0); }