forked from enlightenment/enlightenment
img_export.. for peoel to list possible exportable imaged from dbs and export
them to png's SVN revision: 5730
This commit is contained in:
parent
fdadaabb1b
commit
f576dfb703
|
@ -4,13 +4,18 @@ INCLUDES = \
|
|||
-I$(top_srcdir)/intl \
|
||||
@evas_cflags@ @edb_cflags@ @ebits_cflags@ @ecore_cflags@ @efsd_cflags@ @ferite_cflags@
|
||||
|
||||
bin_PROGRAMS = e_img_import e_setup
|
||||
bin_PROGRAMS = e_img_import e_img_export e_setup
|
||||
|
||||
e_img_import_SOURCES = \
|
||||
e_img_import.c
|
||||
|
||||
e_img_import_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @ferite_libs@ -lm -lc $(INTLLIBS)
|
||||
|
||||
e_img_export_SOURCES = \
|
||||
e_img_export.c
|
||||
|
||||
e_img_export_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @ferite_libs@ -lm -lc $(INTLLIBS)
|
||||
|
||||
e_setup_SOURCES = \
|
||||
e_setup.c
|
||||
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <Imlib2.h>
|
||||
#include <Edb.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int sort_compare(const void *v1, const void *v2);
|
||||
|
||||
static int
|
||||
sort_compare(const void *v1, const void *v2)
|
||||
{
|
||||
return strcmp(*(char **)v1, *(char **)v2);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Imlib_Image im;
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
printf("usage:\n\t%s src.db:/key/in/db dest_image\n", argv[0]);
|
||||
printf("usage:\n\t%s src.db\n", argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
if (argc == 2)
|
||||
{
|
||||
E_DB_File *db;
|
||||
char **keys;
|
||||
int keys_num;
|
||||
int i;
|
||||
|
||||
db = e_db_open_read(argv[1]);
|
||||
if (!db)
|
||||
{
|
||||
printf("Cannot load db:\n");
|
||||
printf(" %s\n", argv[1]);
|
||||
exit(0);
|
||||
}
|
||||
keys_num = 0;
|
||||
keys = e_db_dump_key_list(argv[1], &keys_num);
|
||||
qsort(keys, keys_num, sizeof(char *), sort_compare);
|
||||
printf("Possible images in db file:\n");
|
||||
printf(" %s\n", argv[1]);
|
||||
printf("Possible entries: %i\n", keys_num);
|
||||
printf(" filtering out known non-image entries...\n");
|
||||
printf("---\n");
|
||||
for (i = 0; i < keys_num; i++)
|
||||
{
|
||||
char *t;
|
||||
char *type;
|
||||
|
||||
type = e_db_type_get(db, keys[i]);
|
||||
if (
|
||||
(!type) ||
|
||||
(
|
||||
(!(!strcmp(type, "int"))) &&
|
||||
(!(!strcmp(type, "float"))) &&
|
||||
(!(!strcmp(type, "str")))
|
||||
)
|
||||
)
|
||||
printf("%s:%s\n", argv[1], keys[i]);
|
||||
if (type) free(type);
|
||||
}
|
||||
e_db_close(db);
|
||||
e_db_flush();
|
||||
exit(0);
|
||||
}
|
||||
im = imlib_load_image(argv[1]);
|
||||
if (im)
|
||||
{
|
||||
imlib_context_set_image(im);
|
||||
imlib_image_attach_data_value("compression", NULL, 9, NULL);
|
||||
imlib_image_set_format("png");
|
||||
imlib_save_image(argv[2]);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue