summaryrefslogtreecommitdiff
path: root/source/gprf
diff options
context:
space:
mode:
Diffstat (limited to 'source/gprf')
-rw-r--r--source/gprf/gprf-doc.c4
-rw-r--r--source/gprf/gprf-skeleton.c61
2 files changed, 63 insertions, 2 deletions
diff --git a/source/gprf/gprf-doc.c b/source/gprf/gprf-doc.c
index d9cd2938..bcd631ad 100644
--- a/source/gprf/gprf-doc.c
+++ b/source/gprf/gprf-doc.c
@@ -215,7 +215,7 @@ static inline unsigned char *cmyk_to_rgba(unsigned char *out, uint32_t c, uint32
g += (CONST16(0.2119) * x)>>16;
b += (CONST16(0.2235) * x)>>16;
#else
- k = 63356 - k;
+ k = 65536 - k;
r = k - c;
g = k - m;
b = k - y;
@@ -275,7 +275,7 @@ gprf_get_pixmap(fz_context *ctx, fz_image *image_, int w, int h, int *l2factor)
fz_try(ctx)
{
- /* First off, figure out of we are doing RGB or separations
+ /* First off, figure out if we are doing RGB or separations
* decoding. */
num_seps = 3 + fz_count_separations(ctx, image->separations);
if (fz_separations_all_enabled(ctx, image->separations))
diff --git a/source/gprf/gprf-skeleton.c b/source/gprf/gprf-skeleton.c
new file mode 100644
index 00000000..e17c3e21
--- /dev/null
+++ b/source/gprf/gprf-skeleton.c
@@ -0,0 +1,61 @@
+#include "mupdf/fitz.h"
+
+void
+fz_write_gproof_file(fz_context *ctx, const char *pdf_file, fz_document *doc, const char *filename, int res)
+{
+ int i;
+ int num_pages = fz_count_pages(ctx, doc);
+ fz_output *out;
+ fz_page *page = NULL;
+
+ fz_var(page);
+
+ if (num_pages <= 0)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot write a 0 page GProof skeleton file");
+
+ out = fz_new_output_to_filename(ctx, filename);
+
+ fz_try(ctx)
+ {
+ /* File Signature: GPRO */
+ fz_write_int32le(ctx, out, 0x4f525047);
+
+ /* Version = 1 */
+ fz_write_byte(ctx, out, 1);
+ fz_write_byte(ctx, out, 0);
+
+ /* Resolution */
+ fz_write_int32le(ctx, out, res);
+
+ /* Num Pages */
+ fz_write_int32le(ctx, out, num_pages);
+
+ for (i = 0; i < num_pages; i++)
+ {
+ fz_rect rect;
+ int w, h;
+
+ page = fz_load_page(ctx, doc, i);
+ fz_bound_page(ctx, page, &rect);
+ fz_drop_page(ctx, page);
+ page = NULL;
+
+ w = (int)((rect.x1 - rect.x0) * res / 72.0 + 0.5);
+ h = (int)((rect.y1 - rect.y0) * res / 72.0 + 0.5);
+ fz_write_int32le(ctx, out, w);
+ fz_write_int32le(ctx, out, h);
+ }
+
+ /* Filename */
+ fz_write(ctx, out, pdf_file, strlen(pdf_file)+1);
+ }
+ fz_always(ctx)
+ {
+ fz_drop_page(ctx, page);
+ fz_drop_output(ctx, out);
+ }
+ fz_catch(ctx)
+ {
+ fz_rethrow(ctx);
+ }
+}