diff options
-rw-r--r-- | apps/mudraw.c | 2 | ||||
-rw-r--r-- | fitz/dev_list.c | 20 | ||||
-rw-r--r-- | fitz/dev_text.c | 12 | ||||
-rw-r--r-- | fitz/fitz-internal.h | 4 | ||||
-rw-r--r-- | fitz/fitz.h | 31 |
5 files changed, 58 insertions, 11 deletions
diff --git a/apps/mudraw.c b/apps/mudraw.c index 0d595759..ae6ccbd7 100644 --- a/apps/mudraw.c +++ b/apps/mudraw.c @@ -364,6 +364,8 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) fz_rect bounds; text = fz_new_text_page(ctx, fz_bound_page(doc, page, &bounds)); dev = fz_new_text_device(ctx, sheet, text); + if (showtext == TEXT_HTML) + fz_disable_device_hints(dev, FZ_IGNORE_IMAGE); if (list) fz_run_display_list(list, dev, &fz_identity, &fz_infinite_rect, &cookie); else diff --git a/fitz/dev_list.c b/fitz/dev_list.c index 69542677..bd96381d 100644 --- a/fitz/dev_list.c +++ b/fitz/dev_list.c @@ -744,20 +744,26 @@ visible: fz_ignore_text(dev, node->item.text, &ctm); break; case FZ_CMD_FILL_SHADE: - fz_fill_shade(dev, node->item.shade, &ctm, node->alpha); + if ((dev->hints & FZ_IGNORE_SHADE) == 0) + fz_fill_shade(dev, node->item.shade, &ctm, node->alpha); break; case FZ_CMD_FILL_IMAGE: - fz_fill_image(dev, node->item.image, &ctm, node->alpha); + if ((dev->hints & FZ_IGNORE_IMAGE) == 0) + fz_fill_image(dev, node->item.image, &ctm, node->alpha); break; case FZ_CMD_FILL_IMAGE_MASK: - fz_fill_image_mask(dev, node->item.image, &ctm, - node->colorspace, node->color, node->alpha); + if ((dev->hints & FZ_IGNORE_IMAGE) == 0) + fz_fill_image_mask(dev, node->item.image, &ctm, + node->colorspace, node->color, node->alpha); break; case FZ_CMD_CLIP_IMAGE_MASK: { - fz_rect rect = node->rect; - fz_transform_rect(&rect, top_ctm); - fz_clip_image_mask(dev, node->item.image, &rect, &ctm); + if ((dev->hints & FZ_IGNORE_IMAGE) == 0) + { + fz_rect rect = node->rect; + fz_transform_rect(&rect, top_ctm); + fz_clip_image_mask(dev, node->item.image, &rect, &ctm); + } break; } case FZ_CMD_POP_CLIP: diff --git a/fitz/dev_text.c b/fitz/dev_text.c index baa8f78b..2df5ad38 100644 --- a/fitz/dev_text.c +++ b/fitz/dev_text.c @@ -912,6 +912,18 @@ fz_new_text_device(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page) return dev; } +void +fz_enable_device_hints(fz_device *dev, int hints) +{ + dev->hints |= hints; +} + +void +fz_disable_device_hints(fz_device *dev, int hints) +{ + dev->hints &= ~hints; +} + /* XML, HTML and plain-text output */ static int font_is_bold(fz_font *font) diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h index e5f3c0fa..60407b88 100644 --- a/fitz/fitz-internal.h +++ b/fitz/fitz-internal.h @@ -1468,10 +1468,6 @@ fz_device *fz_new_draw_device_type3(fz_context *ctx, fz_pixmap *dest); enum { - /* Hints */ - FZ_IGNORE_IMAGE = 1, - FZ_IGNORE_SHADE = 2, - /* Flags */ FZ_DEVFLAG_MASK = 1, FZ_DEVFLAG_COLOR = 2, diff --git a/fitz/fitz.h b/fitz/fitz.h index d3a554f4..b298877a 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -1839,6 +1839,37 @@ fz_device *fz_new_draw_device(fz_context *ctx, fz_pixmap *dest); fz_device *fz_new_draw_device_with_bbox(fz_context *ctx, fz_pixmap *dest, const fz_irect *clip); /* + fz_enable_device_hints : Enable hints in a device. + + hints: mask of hints to enable. + + For example: By default the draw device renders shadings. For some + purposes (perhaps rendering fast low quality thumbnails) you may want + to tell it to ignore shadings. For this you would enable the + FZ_IGNORE_SHADE hint. +*/ +void fz_enable_device_hints(fz_device *dev, int hints); + +/* + fz_disable_device_hints : Disable hints in a device. + + hints: mask of hints to disable. + + For example: By default the text extraction device ignores images. + For some purposes however (such as extracting HTML) you may want to + enable the capturing of image data too. For this you would disable + the FZ_IGNORE_IMAGE hint. +*/ +void fz_disable_device_hints(fz_device *dev, int hints); + +enum +{ + /* Hints */ + FZ_IGNORE_IMAGE = 1, + FZ_IGNORE_SHADE = 2, +}; + +/* Text extraction device: Used for searching, format conversion etc. (In development - Subject to change in future versions) |