1 #include "../gfxdevice.h"
2 #include "../gfxsource.h"
3 #include "../gfxtools.h"
9 typedef struct _image_page_internal
11 } image_page_internal_t;
13 typedef struct _image_doc_internal
15 } image_doc_internal_t;
17 void imagepage_destroy(gfxpage_t*image_page)
19 image_page_internal_t*i= (image_page_internal_t*)image_page->internal;
20 free(image_page->internal);image_page->internal = 0;
21 free(image_page);image_page=0;
24 void imagepage_render(gfxpage_t*page, gfxdevice_t*output)
26 image_page_internal_t*i = (image_page_internal_t*)page->internal;
27 image_doc_internal_t*pi = (image_doc_internal_t*)page->parent->internal;
30 void imagepage_rendersection(gfxpage_t*page, gfxdevice_t*output, gfxcoord_t x, gfxcoord_t y, gfxcoord_t _x1, gfxcoord_t _y1, gfxcoord_t _x2, gfxcoord_t _y2)
32 image_doc_internal_t*pi = (image_doc_internal_t*)page->parent->internal;
35 void image_doc_destroy(gfxdocument_t*gfx)
37 image_doc_internal_t*i= (image_doc_internal_t*)gfx->internal;
39 free(gfx->internal);gfx->internal=0;
43 void image_doc_set_parameter(gfxdocument_t*gfx, char*name, char*value)
45 image_doc_internal_t*i= (image_doc_internal_t*)gfx->internal;
48 gfxpage_t* image_doc_getpage(gfxdocument_t*doc, int page)
50 image_doc_internal_t*di= (image_doc_internal_t*)doc->internal;
54 gfxpage_t* image_page = (gfxpage_t*)malloc(sizeof(gfxpage_t));
55 image_page_internal_t*pi= (image_page_internal_t*)malloc(sizeof(image_page_internal_t));
56 memset(pi, 0, sizeof(image_page_internal_t));
58 image_page->internal = pi;
59 image_page->destroy = imagepage_destroy;
60 image_page->render = imagepage_render;
61 image_page->rendersection = imagepage_rendersection;
62 image_page->width = di->width;
63 image_page->height = di->height;
64 image_page->parent = doc;
65 image_page->nr = page;
69 static void image_set_parameter(gfxsource_t*src, char*name, char*value)
71 msg("<verbose> (gfxsource_image) setting parameter %s to \"%s\"", name, value);
74 static gfxdocument_t*image_open(gfxsource_t*src, char*filename)
76 gfxdocument_t*image_doc = (gfxdocument_t*)malloc(sizeof(gfxdocument_t));
77 memset(image_doc, 0, sizeof(gfxdocument_t));
78 image_doc_internal_t*i= (image_doc_internal_t*)malloc(sizeof(image_doc_internal_t));
79 memset(i, 0, sizeof(image_doc_internal_t));
85 if(!getPNG(filename, &width, &height, &data)) {
88 image_doc->num_pages = i->image.frameCount;
89 image_doc->internal = i;
91 image_doc->destroy = image_doc_destroy;
92 image_doc->set_parameter = image_doc_set_parameter;
93 image_doc->getpage = image_doc_getpage;
98 gfxsource_t*gfxsource_image_create()
100 gfxsource_t*src = (gfxsource_t*)malloc(sizeof(gfxsource_t));
101 memset(src, 0, sizeof(gfxsource_t));
102 src->set_parameter = image_set_parameter;
103 src->open = image_open;