2009-04-21 16:03:50 -07:00
|
|
|
#include "Ethumb.h"
|
2009-04-21 16:06:57 -07:00
|
|
|
#include "ethumb_private.h"
|
2009-04-21 16:03:50 -07:00
|
|
|
#include "Ethumb_Plugin.h"
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2009-04-25 14:48:49 -07:00
|
|
|
#include <Eina.h>
|
2009-04-21 16:03:50 -07:00
|
|
|
#include <Evas.h>
|
|
|
|
#include <Epdf.h>
|
|
|
|
|
|
|
|
static int
|
2009-04-21 16:08:17 -07:00
|
|
|
_generate_thumb(Ethumb *e)
|
2009-04-21 16:03:50 -07:00
|
|
|
{
|
|
|
|
Epdf_Document *document;
|
|
|
|
Epdf_Page *page;
|
|
|
|
Evas_Object *o;
|
|
|
|
int w, h, ww, hh;
|
|
|
|
int fx, fy, fw, fh;
|
|
|
|
int npages;
|
|
|
|
|
2009-04-21 16:08:17 -07:00
|
|
|
document = epdf_document_new(e->src_path);
|
2009-04-21 16:03:50 -07:00
|
|
|
if (!document)
|
|
|
|
{
|
2009-04-21 16:08:17 -07:00
|
|
|
fprintf(stderr, "ERROR: could not read document: %s\n", e->src_path);
|
2009-04-21 16:03:50 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
page = epdf_page_new(document);
|
|
|
|
if (!page)
|
|
|
|
{
|
2009-04-21 16:08:17 -07:00
|
|
|
fprintf(stderr, "ERROR: could not read document: %s\n", e->src_path);
|
2009-04-21 16:03:50 -07:00
|
|
|
epdf_document_delete(document);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
npages = epdf_document_page_count_get(document);
|
|
|
|
if (e->document.page < npages)
|
|
|
|
epdf_page_page_set(page, e->document.page);
|
|
|
|
epdf_page_size_get(page, &w, &h);
|
|
|
|
ethumb_calculate_aspect(e, w, h, &ww, &hh);
|
2009-04-21 16:08:17 -07:00
|
|
|
ethumb_plugin_image_resize(e, ww, hh);
|
2009-04-21 16:03:50 -07:00
|
|
|
|
|
|
|
o = evas_object_image_add(e->sub_e);
|
|
|
|
epdf_page_render(page, o);
|
|
|
|
evas_object_resize(o, ww, hh);
|
|
|
|
evas_object_move(o, 0, 0);
|
|
|
|
|
|
|
|
ethumb_calculate_fill(e, w, h, &fx, &fy, &fw, &fh);
|
|
|
|
evas_object_image_fill_set(o, fx, fy, fw, fh);
|
|
|
|
|
|
|
|
evas_object_show(o);
|
2009-04-21 16:08:17 -07:00
|
|
|
ethumb_image_save(e);
|
2009-04-21 16:03:50 -07:00
|
|
|
|
|
|
|
evas_object_del(o);
|
|
|
|
epdf_page_delete(page);
|
|
|
|
epdf_document_delete(document);
|
|
|
|
|
2009-04-21 16:08:17 -07:00
|
|
|
ethumb_finished_callback_call(e);
|
2009-04-21 16:03:50 -07:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ethumb_Plugin *
|
2009-04-25 14:48:49 -07:00
|
|
|
ethumb_plugin_get(void)
|
2009-04-21 16:03:50 -07:00
|
|
|
{
|
|
|
|
static const char *extensions[] = { "pdf", NULL };
|
|
|
|
static Ethumb_Plugin plugin =
|
|
|
|
{
|
|
|
|
extensions,
|
|
|
|
_generate_thumb,
|
|
|
|
};
|
|
|
|
|
2009-04-25 14:48:49 -07:00
|
|
|
return &plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eina_Bool
|
|
|
|
_module_init(void)
|
|
|
|
{
|
2009-04-21 16:03:50 -07:00
|
|
|
epdf_init();
|
|
|
|
|
2009-04-25 14:48:49 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_module_shutdown(void)
|
|
|
|
{
|
|
|
|
epdf_shutdown();
|
2009-04-21 16:03:50 -07:00
|
|
|
}
|
2009-04-25 14:48:49 -07:00
|
|
|
|
|
|
|
EINA_MODULE_INIT(_module_init);
|
|
|
|
EINA_MODULE_SHUTDOWN(_module_shutdown);
|