diff options
| author | Felipe Corr??a da Silva Sanches <juca@members.fsf.org> | 2009-12-11 08:37:11 +0000 |
|---|---|---|
| committer | Felipe C. da S. Sanches <juca@members.fsf.org> | 2009-12-11 08:37:11 +0000 |
| commit | b13df173f8e6471ce720d45370447b9e52cd3925 (patch) | |
| tree | d1735aba3e3d2a25f96967272394922f07509635 /src/display/nr-arena-shape.cpp | |
| parent | French translation update (diff) | |
| download | inkscape-b13df173f8e6471ce720d45370447b9e52cd3925.tar.gz inkscape-b13df173f8e6471ce720d45370447b9e52cd3925.zip | |
- new: Print Colors Preview Dialog and rendermode
- works with shapes. I still need to make it work with gradients and imported images
(bzr r8881)
Diffstat (limited to 'src/display/nr-arena-shape.cpp')
| -rw-r--r-- | src/display/nr-arena-shape.cpp | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 96ea76cbe..d5a098c39 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -35,6 +35,8 @@ #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" @@ -844,6 +846,7 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock 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); |
