79f1b1ce37952d01b95c07e1b6940ecda4cedad4
9 fz_glyph_cache
*glyphcache
;
13 int doc_draw(struct doc
*doc
, fbval_t
*bitmap
, int p
, int rows
, int cols
, int zoom
, int rotate
)
19 fz_display_list
*list
;
23 if (pdf_load_page(&page
, doc
->xref
, p
- 1))
25 list
= fz_new_display_list();
26 dev
= fz_new_list_device(list
);
27 if (pdf_run_page(doc
->xref
, page
, dev
, fz_identity
))
31 ctm
= fz_translate(0, -page
->mediabox
.y1
);
32 ctm
= fz_concat(ctm
, fz_scale((float) zoom
/ 10, (float) -zoom
/ 10));
34 ctm
= fz_concat(ctm
, fz_rotate(rotate
));
35 bbox
= fz_round_rect(fz_transform_rect(ctm
, page
->mediabox
));
37 pix
= fz_new_pixmap_with_rect(fz_device_rgb
, bbox
);
38 fz_clear_pixmap_with_color(pix
, 0xff);
40 dev
= fz_new_draw_device(doc
->glyphcache
, pix
);
41 fz_execute_display_list(list
, dev
, ctm
, bbox
);
44 for (y
= 0; y
< MIN(pix
->h
, rows
); y
++) {
45 for (x
= 0; x
< MIN(pix
->w
, cols
); x
++) {
46 unsigned char *s
= pix
->samples
+ y
* pix
->w
* 4 + x
* 4;
47 bitmap
[y
* cols
+ x
] = FB_VAL(s
[0], s
[1], s
[2]);
52 fz_free_display_list(list
);
54 pdf_age_store(doc
->xref
->store
, 3);
58 int doc_pages(struct doc
*doc
)
60 return pdf_count_pages(doc
->xref
);
63 struct doc
*doc_open(char *path
)
65 struct doc
*doc
= malloc(sizeof(*doc
));
67 doc
->glyphcache
= fz_new_glyph_cache();
68 if (pdf_open_xref(&doc
->xref
, path
, NULL
)) {
72 if (pdf_load_page_tree(doc
->xref
)) {
79 void doc_close(struct doc
*doc
)
81 pdf_free_xref(doc
->xref
);
82 fz_free_glyph_cache(doc
->glyphcache
);