Re: Saving images

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



Ignacio Vico wrote:
>  Hi,
>  
>  I'm programing an application for getting images, I've set the acquisition 
>  but my trouble now is to save the images i have acquired. I must save them 
>  in JPEG with low resolution (for a web application) and a format that 
>  haven't loss of information (such TIFF, GIF, PNG, BMP etc)
> 
>  I would like to know were can I find libraries for do this.

libjpeg, libpng?  Both libraries come with docs and sample code.  Both
are standard for every linux disttibution.  Writing out RGB data as jpeg
using libjpeg is pretty easy:

------------------- cut here --------------------
static int
write_file(int fd, char *data, int width, int height)
{
    struct jpeg_compress_struct cinfo;
    struct jpeg_error_mgr jerr;
    FILE *fp;
    int i;
    unsigned char *line;

    fp = fdopen(fd,"w");
    cinfo.err = jpeg_std_error(&jerr);
    jpeg_create_compress(&cinfo);
    jpeg_stdio_dest(&cinfo, fp);
    cinfo.image_width = width;
    cinfo.image_height = height;
    cinfo.input_components = 3;
    cinfo.in_color_space = JCS_RGB;
    jpeg_set_defaults(&cinfo);
    jpeg_set_quality(&cinfo, grab_quality, TRUE);
    jpeg_start_compress(&cinfo, TRUE);

    for (i = 0, line = data; i < height; i++, line += width*3)
        jpeg_write_scanlines(&cinfo, &line, 1);

    jpeg_finish_compress(&(cinfo));
    jpeg_destroy_compress(&(cinfo));
    fclose(fp);

    return 0;
}
------------------- cut here --------------------

  Gerd

-- 
#define	ENOCLUE 125 /* userland programmer induced race condition */





[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux