index 96ea76cbef83f14dc6d97c96d437e43dacab1fac..d5a098c391d91ef390ea47a3aa8d32f65a241311 100644 (file)
#include "display/nr-filter.h"
#include <typeinfo>
#include <cairo.h>
+#include "preferences.h"
+#include "svg/svg-device-color.h"
#include <glib.h>
#include "svg/svg.h"
if (!shape->style) return item->state;
bool outline = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_OUTLINE);
+ bool print_colors = (NR_ARENA_ITEM(shape)->arena->rendermode == Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW);
if (outline) { // cairo outline rendering
@@ -873,7 +876,22 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock
}
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
SPStyle const *style = shape->style;
+ bool render_cyan = prefs->getBool("/options/printcolorspreview/cyan", true);
+ bool render_magenta = prefs->getBool("/options/printcolorspreview/magenta", true);
+ bool render_yellow = prefs->getBool("/options/printcolorspreview/yellow", true);
+ bool render_black = prefs->getBool("/options/printcolorspreview/black", true);
+
+ float rgb_v[3];
+ float cmyk_v[4];
+#define FLOAT_TO_UINT8(f) (int(f*255))
+#define RGBA_R(v) ((v) >> 24)
+#define RGBA_G(v) (((v) >> 16) & 0xff)
+#define RGBA_B(v) (((v) >> 8) & 0xff)
+#define RGBA_A(v) ((v) & 0xff)
+
if (shape->fill_shp) {
NRPixBlock m;
guint32 rgba;
@@ -893,12 +911,24 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock
if (shape->_fill.paint.type() == NRArenaShape::Paint::NONE) {
// do not render fill in any way
} else if (shape->_fill.paint.type() == NRArenaShape::Paint::COLOR) {
+
+ const SPColor* fill_color = &shape->_fill.paint.color();
if ( item->render_opacity ) {
- rgba = shape->_fill.paint.color().toRGBA32( shape->_fill.opacity *
- SP_SCALE24_TO_FLOAT(style->opacity.value) );
+ rgba = fill_color->toRGBA32( shape->_fill.opacity *
+ SP_SCALE24_TO_FLOAT(style->opacity.value) );
} else {
- rgba = shape->_fill.paint.color().toRGBA32( shape->_fill.opacity );
+ rgba = fill_color->toRGBA32( shape->_fill.opacity );
+ }
+
+ if (print_colors){
+ sp_color_rgb_to_cmyk_floatv (cmyk_v, RGBA_R(rgba)/256.0, RGBA_G(rgba)/256.0, RGBA_B(rgba)/256.0);
+ sp_color_cmyk_to_rgb_floatv (rgb_v, render_cyan ? cmyk_v[0] : 0,
+ render_magenta ? cmyk_v[1] : 0,
+ render_yellow ? cmyk_v[2] : 0,
+ render_black ? cmyk_v[3] : 0);
+ rgba = (FLOAT_TO_UINT8(rgb_v[0])<<24) + (FLOAT_TO_UINT8(rgb_v[1])<<16) + (FLOAT_TO_UINT8(rgb_v[2])<<8) + 0xff;
}
+
nr_blit_pixblock_mask_rgba32(pb, &m, rgba);
pb->empty = FALSE;
} else if (shape->_fill.paint.type() == NRArenaShape::Paint::SERVER) {
@@ -929,14 +959,25 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock
nr_pixblock_render_shape_mask_or(m, shape->stroke_shp);
m.empty = FALSE;
- if ( item->render_opacity ) {
- rgba = shape->_stroke.paint.color().toRGBA32( shape->_stroke.opacity *
- SP_SCALE24_TO_FLOAT(style->opacity.value) );
- } else {
- rgba = shape->_stroke.paint.color().toRGBA32( shape->_stroke.opacity );
- }
- nr_blit_pixblock_mask_rgba32(pb, &m, rgba);
- pb->empty = FALSE;
+ const SPColor* stroke_color = &shape->_stroke.paint.color();
+ if ( item->render_opacity ) {
+ rgba = stroke_color->toRGBA32( shape->_stroke.opacity *
+ SP_SCALE24_TO_FLOAT(style->opacity.value) );
+ } else {
+ rgba = stroke_color->toRGBA32( shape->_stroke.opacity );
+ }
+
+ if (print_colors){
+ sp_color_rgb_to_cmyk_floatv (cmyk_v, RGBA_R(rgba)/256.0, RGBA_G(rgba)/256.0, RGBA_B(rgba)/256.0);
+ sp_color_cmyk_to_rgb_floatv (rgb_v, render_cyan ? cmyk_v[0] : 0,
+ render_magenta ? cmyk_v[1] : 0,
+ render_yellow ? cmyk_v[2] : 0,
+ render_black ? cmyk_v[3] : 0);
+ rgba = (FLOAT_TO_UINT8(rgb_v[0])<<24) + (FLOAT_TO_UINT8(rgb_v[1])<<16) + (FLOAT_TO_UINT8(rgb_v[2])<<8) + 0xff;
+ }
+
+ nr_blit_pixblock_mask_rgba32(pb, &m, rgba);
+ pb->empty = FALSE;
nr_pixblock_release(&m);