資源簡介
開源項目mupdf的源代碼,支持各種運行環(huán)境的,包括android,為節(jié)省空間,卻除了git部分
代碼片段和文件信息
//?Rendering?a?page?of?a?PDF?document?to?a?PNG?image?in?less?than?100?lines.
//?Compile?a?debug?build?of?mupdf?then?compile?and?run?this?example:
//
//?gcc?-g?-o?build/debug/example?-Iinclude?docs/example.c?\
// build/debug/libmupdf.a?\
// build/debug/libfreetype.a?build/debug/libjbig2dec.a?\
// build/debug/libjpeg.a?build/debug/libopenjpeg.a?\
// build/debug/libmujs.a?\
// build/debug/libz.a?-lm
//
//?build/debug/example?/path/to/document.pdf?1?200?25
//?Include?the?MuPDF?header?file.
#include?
void
render(char?*filename?int?pagenumber?int?zoom?int?rotation)
{
fz_context?*ctx;
fz_document?*doc;
int?pagecount;
fz_page?*page;
fz_matrix?transform;
fz_rect?bounds;
fz_irect?bbox;
fz_pixmap?*pix;
fz_device?*dev;
//?Create?a?context?to?hold?the?exception?stack?and?various?caches.
ctx?=?fz_new_context(NULL?NULL?FZ_STORE_UNLIMITED);
//?Register?the?default?file?types.
fz_register_document_handlers(ctx);
//?Open?the?PDF?XPS?or?CBZ?document.
doc?=?fz_open_document(ctx?filename);
//?Retrieve?the?number?of?pages?(not?used?in?this?example).
pagecount?=?fz_count_pages(ctx?doc);
//?Load?the?page?we?want.?Page?numbering?starts?from?zero.
page?=?fz_load_page(ctx?doc?pagenumber?-?1);
//?Calculate?a?transform?to?use?when?rendering.?This?transform
//?contains?the?scale?and?rotation.?Convert?zoom?percentage?to?a
//?scaling?factor.?Without?scaling?the?resolution?is?72?dpi.
fz_rotate(&transform?rotation);
fz_pre_scale(&transform?zoom?/?100.0f?zoom?/?100.0f);
//?Take?the?page?bounds?and?transform?them?by?the?same?matrix?that
//?we?will?use?to?render?the?page.
fz_bound_page(ctx?page?&bounds);
fz_transform_rect(&bounds?&transform);
//?Create?a?blank?pixmap?to?hold?the?result?of?rendering.?The
//?pixmap?bounds?used?here?are?the?same?as?the?transformed?page
//?bounds?so?it?will?contain?the?entire?page.?The?page?coordinate
//?space?has?the?origin?at?the?top?left?corner?and?the?x?axis
//?extends?to?the?right?and?the?y?axis?extends?down.
fz_round_rect(&bbox?&bounds);
pix?=?fz_new_pixmap_with_bbox(ctx?fz_device_rgb(ctx)?&bbox);
fz_clear_pixmap_with_value(ctx?pix?0xff);
//?A?page?consists?of?a?series?of?objects?(text?line?art?images
//?gradients).?These?objects?are?passed?to?a?device?when?the
//?interpreter?runs?the?page.?There?are?several?devices?used?for
//?different?purposes:
//
// draw?device?--?renders?objects?to?a?target?pixmap.
//
// text?device?--?extracts?the?text?in?reading?order?with?styling
// information.?This?text?can?be?used?to?provide?text?search.
//
// list?device?--?records?the?graphic?objects?in?a?list?that?can
// be?played?back?through?another?device.?This?is?useful?if?you
// need?to?run?the?same?page?through?multiple?devices?without
// the?overhead?of?parsing?the?page?each?time.
//?Create?a?draw?device?with?the?pixmap?as?its?target.
//?Run?the?page?with?the?transform.
dev?=?fz_new_draw_device(ctx?pix);
fz_run_page(ctx?page?dev?&transform
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????8338??2015-05-02?09:18??CHANGES
?????文件????????482??2015-05-02?09:18??CONTRIBUTORS
?????文件??????34520??2015-05-02?09:18??COPYING
?????文件??????10911??2015-05-02?09:18??Makefile
?????文件???????5197??2015-05-02?09:18??Makerules
?????文件???????9166??2015-05-02?09:18??Makethird
?????文件???????3275??2015-05-02?09:18??README
?????文件???????3509??2015-05-02?09:18??docs\example.c
?????文件???????2760??2015-05-02?09:18??docs\man\mudraw.1
?????文件???????3090??2015-05-02?09:18??docs\man\mupdf.1
?????文件???????4794??2015-05-02?09:18??docs\man\mutool.1
?????文件???????8481??2015-05-02?09:18??docs\multi-threaded.c
?????文件????????954??2015-05-02?09:18??docs\naming.txt
?????文件??????10186??2015-05-02?09:18??docs\overview.txt
?????文件??????13272??2015-05-02?09:18??docs\progressive.txt
?????文件????????838??2015-05-02?09:18??docs\refcount.txt
?????文件????????637??2015-05-02?09:18??docs\thirdparty.txt
?????文件???????1353??2015-05-02?09:18??include\mupdf\fitz\annotation.h
?????文件???????2259??2015-05-02?09:18??include\mupdf\fitz\bitmap.h
?????文件???????3519??2015-05-02?09:18??include\mupdf\fitz\buffer.h
?????文件???????3648??2015-05-02?09:18??include\mupdf\fitz\colorspace.h
?????文件???????1765??2015-05-02?09:18??include\mupdf\fitz\compressed-buffer.h
?????文件??????14167??2015-05-02?09:18??include\mupdf\fitz\context.h
?????文件???????2437??2015-05-02?09:18??include\mupdf\fitz\crypt.h
?????文件??????13029??2015-05-02?09:18??include\mupdf\fitz\device.h
?????文件???????3208??2015-05-02?09:18??include\mupdf\fitz\display-list.h
?????文件??????11948??2015-05-02?09:18??include\mupdf\fitz\document.h
?????文件???????1767??2015-05-02?09:18??include\mupdf\fitz\filter.h
?????文件???????3901??2015-05-02?09:18??include\mupdf\fitz\font.h
?????文件???????1048??2015-05-02?09:18??include\mupdf\fitz\function.h
............此處省略3954個文件信息
評論
共有 條評論