// Colors
class color_spec {
- double rgb[3];
public:
+ double rgb[3];
+ color_spec()
+ {
+ rgb[0] = rgb[1] = rgb[2] = 0;
+ }
color_spec(string s)
{
if (s.length() != 6)
// Cropmarks
class cropmark_spec {
+public:
enum mark_type {
MARK_NONE,
MARK_BOX,
double pen_width;
double arm_length;
double offset;
- string crop_cross(double x, double y, uint mask);
- QPDFObjectHandle egstate;
color_spec color;
-public:
+ cropmark_spec()
+ {
+ type = MARK_NONE;
+ pen_width = 0.2;
+ arm_length = 5*mm;
+ offset = 0;
+ egstate = QPDFObjectHandle::newNull();
+ }
cropmark_spec(cmd *c, const string prefix="", const string def_type="cross") : color(c->arg(prefix + "color")->as_string("000000"))
{
string t = c->arg(prefix + "mark")->as_string(def_type);
}
bool is_bg() { return (type == MARK_BG); }
string pdf_stream(out_context *out, BBox &box, pdf_matrix &xform);
+private:
+ string crop_cross(double x, double y, uint mask);
+ QPDFObjectHandle egstate;
};
string cropmark_spec::crop_cross(double x, double y, uint mask)
{ NULL, 0 }
};
-/*** draw-bbox ***/
+/*** debug ***/
-class draw_bbox_page : public page {
+class debug_page : public page {
page *orig_page;
+ cropmark_spec *page_cm, *image_cm;
public:
- void render(out_context *out, pdf_matrix xform) override;
- draw_bbox_page(page *p) : page(p) { orig_page = p; }
+ debug_page(page *p, cropmark_spec *page_cms, cropmark_spec *image_cms) : page(p), orig_page(p), page_cm(page_cms), image_cm(image_cms) { }
+ void render(out_context *out, pdf_matrix xform) override
+ {
+ orig_page->render(out, xform);
+ BBox page_bbox = BBox(0, 0, width, height);
+ out->contents += page_cm->pdf_stream(out, page_bbox, xform);
+ out->contents += image_cm->pdf_stream(out, image_box, xform);
+ }
};
-class draw_bbox_cmd : public cmd_exec_simple {
+class debug_cmd : public cmd_exec_simple {
+ cropmark_spec page_cmarks;
+ cropmark_spec image_cmarks;
public:
- draw_bbox_cmd(cmd *c UNUSED) { }
+ debug_cmd(cmd *c UNUSED)
+ {
+ page_cmarks.type = cropmark_spec::MARK_BOX;
+ page_cmarks.color.rgb[0] = 1;
+ page_cmarks.color.rgb[1] = 0;
+ page_cmarks.color.rgb[2] = 0;
+ image_cmarks.type = cropmark_spec::MARK_BOX;
+ image_cmarks.color.rgb[0] = 0;
+ image_cmarks.color.rgb[1] = 1;
+ image_cmarks.color.rgb[2] = 0;
+ }
page *process_page(page *p) override
{
- return new draw_bbox_page(p);
+ return new debug_page(p, &page_cmarks, &image_cmarks);
}
};
-void draw_bbox_page::render(out_context *out, pdf_matrix xform)
-{
- orig_page->render(out, xform);
- out->contents +=
- "q " +
- xform.to_string() + " cm " +
- "0 1 0 RG " +
- image_box.to_rect() + " re S " +
- "Q ";
-}
-
/*** merge ***/
class merge_cmd : public cmd_exec {
{ "select", no_args, 1, &ctor<select_cmd> },
{ "apply", no_args, 1, &ctor<apply_cmd> },
{ "modulo", modulo_args, 1, &ctor<modulo_cmd> },
- { "draw-bbox",no_args, 0, &ctor<draw_bbox_cmd> },
+ { "debug", no_args, 0, &ctor<debug_cmd> },
{ "merge", no_args, 0, &ctor<merge_cmd> },
{ "paper", paper_args, 0, &ctor<paper_cmd> },
{ "scaleto", scaleto_args, 0, &ctor<scaleto_cmd> },