diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2013-06-17 22:38:48 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2013-06-18 17:37:13 +0200 |
commit | 34ed3770863899755ff688cc86c29aacaf924a5d (patch) | |
tree | fe2b6e3b80bb6c39323dd1bf8fec77755710f648 | |
parent | 923ab857eed6cd29b539910bf74be2aa26d71f39 (diff) | |
download | mupdf-34ed3770863899755ff688cc86c29aacaf924a5d.tar.xz |
Move fz_write_pixmap wrapper into pdfextract (its only user).
-rw-r--r-- | apps/pdfextract.c | 40 | ||||
-rw-r--r-- | fitz/image_save.c | 33 | ||||
-rw-r--r-- | include/mupdf/fitz/output-pnm.h | 11 | ||||
-rw-r--r-- | win32/libmupdf.vcproj | 4 | ||||
-rw-r--r-- | winrt/libmupdf_winRT.vcxproj | 3 | ||||
-rw-r--r-- | winrt/libmupdf_winRT.vcxproj.filters | 5 |
6 files changed, 38 insertions, 58 deletions
diff --git a/apps/pdfextract.c b/apps/pdfextract.c index e30b8268..78a61f14 100644 --- a/apps/pdfextract.c +++ b/apps/pdfextract.c @@ -28,10 +28,42 @@ static int isfontdesc(pdf_obj *obj) return pdf_is_name(type) && !strcmp(pdf_to_name(type), "FontDescriptor"); } +static void writepixmap(fz_context *ctx, fz_pixmap *pix, char *file, int rgb) +{ + char name[1024]; + fz_pixmap *converted = NULL; + + if (!pix) + return; + + if (rgb && pix->colorspace && pix->colorspace != fz_device_rgb(ctx)) + { + fz_irect bbox; + converted = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), fz_pixmap_bbox(ctx, pix, &bbox)); + fz_convert_pixmap(ctx, converted, pix); + pix = converted; + } + + if (pix->n <= 4) + { + sprintf(name, "%s.png", file); + printf("extracting image %s\n", name); + fz_write_png(ctx, pix, name, 0); + } + else + { + sprintf(name, "%s.pam", file); + printf("extracting image %s\n", name); + fz_write_pam(ctx, pix, name, 0); + } + + fz_drop_pixmap(ctx, converted); +} + static void saveimage(int num) { fz_image *image; - fz_pixmap *img; + fz_pixmap *pix; pdf_obj *ref; char name[32]; @@ -40,13 +72,13 @@ static void saveimage(int num) /* TODO: detect DCTD and save as jpeg */ image = pdf_load_image(doc, ref); - img = fz_image_to_pixmap(ctx, image, 0, 0); + pix = fz_image_to_pixmap(ctx, image, 0, 0); fz_drop_image(ctx, image); sprintf(name, "img-%04d", num); - fz_write_pixmap(ctx, img, name, dorgb); + writepixmap(ctx, pix, name, dorgb); - fz_drop_pixmap(ctx, img); + fz_drop_pixmap(ctx, pix); pdf_drop_obj(ref); } diff --git a/fitz/image_save.c b/fitz/image_save.c deleted file mode 100644 index 0a564ed1..00000000 --- a/fitz/image_save.c +++ /dev/null @@ -1,33 +0,0 @@ -#include "mupdf/fitz.h" - -void fz_write_pixmap(fz_context *ctx, fz_pixmap *img, char *file, int rgb) -{ - char name[1024]; - fz_pixmap *converted = NULL; - - if (!img) - return; - - if (rgb && img->colorspace && img->colorspace != fz_device_rgb(ctx)) - { - fz_irect bbox; - converted = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), fz_pixmap_bbox(ctx, img, &bbox)); - fz_convert_pixmap(ctx, converted, img); - img = converted; - } - - if (img->n <= 4) - { - sprintf(name, "%s.png", file); - printf("extracting image %s\n", name); - fz_write_png(ctx, img, name, 0); - } - else - { - sprintf(name, "%s.pam", file); - printf("extracting image %s\n", name); - fz_write_pam(ctx, img, name, 0); - } - - fz_drop_pixmap(ctx, converted); -} diff --git a/include/mupdf/fitz/output-pnm.h b/include/mupdf/fitz/output-pnm.h index f4cc6735..8094aedb 100644 --- a/include/mupdf/fitz/output-pnm.h +++ b/include/mupdf/fitz/output-pnm.h @@ -8,17 +8,6 @@ #include "mupdf/fitz/bitmap.h" /* - fz_write_pixmap: Save a pixmap out. - - name: The prefix for the name of the pixmap. The pixmap will be saved - as "name.png" if the pixmap is RGB or Greyscale, "name.pam" otherwise. - - rgb: If non zero, the pixmap is converted to rgb (if possible) before - saving. -*/ -void fz_write_pixmap(fz_context *ctx, fz_pixmap *img, char *name, int rgb); - -/* fz_write_pnm: Save a pixmap as a pnm filename: The filename to save as (including extension). diff --git a/win32/libmupdf.vcproj b/win32/libmupdf.vcproj index ba55e7c4..61fea92a 100644 --- a/win32/libmupdf.vcproj +++ b/win32/libmupdf.vcproj @@ -509,10 +509,6 @@ > </File> <File - RelativePath="..\fitz\image_save.c" - > - </File> - <File RelativePath="..\fitz\image_tiff.c" > </File> diff --git a/winrt/libmupdf_winRT.vcxproj b/winrt/libmupdf_winRT.vcxproj index 02147b9f..ec98e347 100644 --- a/winrt/libmupdf_winRT.vcxproj +++ b/winrt/libmupdf_winRT.vcxproj @@ -82,7 +82,6 @@ <ClCompile Include="..\fitz\image_jpx.c" /> <ClCompile Include="..\fitz\image_md5.c" /> <ClCompile Include="..\fitz\image_png.c" /> - <ClCompile Include="..\fitz\image_save.c" /> <ClCompile Include="..\fitz\image_tiff.c" /> <ClCompile Include="..\fitz\memento.c" /> <ClCompile Include="..\fitz\res_bitmap.c" /> @@ -429,4 +428,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project>
\ No newline at end of file +</Project> diff --git a/winrt/libmupdf_winRT.vcxproj.filters b/winrt/libmupdf_winRT.vcxproj.filters index 109c2c0c..74df3789 100644 --- a/winrt/libmupdf_winRT.vcxproj.filters +++ b/winrt/libmupdf_winRT.vcxproj.filters @@ -153,9 +153,6 @@ <ClCompile Include="..\fitz\image_png.c"> <Filter>fitz</Filter> </ClCompile> - <ClCompile Include="..\fitz\image_save.c"> - <Filter>fitz</Filter> - </ClCompile> <ClCompile Include="..\fitz\image_tiff.c"> <Filter>fitz</Filter> </ClCompile> @@ -402,4 +399,4 @@ <Filter>image</Filter> </ClInclude> </ItemGroup> -</Project>
\ No newline at end of file +</Project> |