test-mem.c

Go to the documentation of this file.
00001 /* test-mem.c
00002  *
00003  * Copyright (c) 2002 Lutz Mueller <lutz@users.sourceforge.net>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful, 
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details. 
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the
00017  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA  02110-1301  USA.
00019  */
00020 
00021 #include <config.h>
00022 
00023 #include <libexif/exif-data.h>
00024 #include <libexif/exif-ifd.h>
00025 #include <libexif/exif-loader.h>
00026 
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 
00030 int
00031 main ()
00032 {
00033         ExifData *ed;
00034         /* ExifEntry *e; */
00035         unsigned char *eb, size[2];
00036         unsigned int ebs;
00037         ExifLoader *loader;
00038         unsigned int i;
00039 
00040         printf ("Creating EXIF data...\n");
00041         ed = exif_data_new ();
00042         exif_data_set_data_type (ed, EXIF_DATA_TYPE_UNCOMPRESSED_CHUNKY);
00043 
00044         printf ("Fill EXIF data with all necessary entries to follow specs...\n");
00045         exif_data_fix (ed);
00046 
00047         exif_data_dump (ed);
00048 
00049         printf ("Saving EXIF data to memory...\n");
00050         exif_data_save_data (ed, &eb, &ebs);
00051         exif_data_unref (ed);
00052 
00053         printf ("Writing %i byte(s) EXIF data to loader...\n", ebs);
00054         loader = exif_loader_new ();
00055         size[0] = (unsigned char) ebs;
00056         size[1] = (unsigned char) (ebs >> 8);
00057         exif_loader_write (loader, size, 2);
00058         for (i = 0; i < ebs && exif_loader_write (loader, eb + i, 1); i++);
00059         printf ("Wrote %i byte(s).\n", i);
00060         free (eb);
00061         ed = exif_loader_get_data (loader);
00062         exif_loader_unref (loader);
00063         exif_data_dump (ed);
00064         exif_data_unref (ed);
00065 
00066         return 0;
00067 }

SourceForge.net Logo Generated by doxygen