diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2012-12-16 05:41:25 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2012-12-16 05:41:25 +0000 |
| commit | 7ec903c9898f872dbd9426ed7a62e1969fdb7be7 (patch) | |
| tree | a306139e829118a83516af02279c9eafd3440eaa /src/flood-context.cpp | |
| parent | Hershey Text: whitespace; py: docstring, modeline; inx: fix attribute value (diff) | |
| parent | Translations.Spanish translation update by Lucas Vieites. (diff) | |
| download | inkscape-7ec903c9898f872dbd9426ed7a62e1969fdb7be7.tar.gz inkscape-7ec903c9898f872dbd9426ed7a62e1969fdb7be7.zip | |
merge from trunk (r11955)
(bzr r11687.1.3)
Diffstat (limited to 'src/flood-context.cpp')
| -rw-r--r-- | src/flood-context.cpp | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/flood-context.cpp b/src/flood-context.cpp index f7c4ca365..3c656527e 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -167,7 +167,7 @@ static void sp_flood_context_dispose(GObject *object) * Callback that processes the "changed" signal on the selection; * destroys old and creates new knotholder. */ -void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer data) +static void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer data) { SPFloodContext *rc = SP_FLOOD_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(rc); @@ -205,6 +205,10 @@ static void sp_flood_context_setup(SPEventContext *ec) } } +// Changes from 0.48 -> 0.49 (Cairo) +// 0.49: Ignores alpha in background +// 0.48: RGBA, 0.49 ARGB +// 0.49: premultiplied alpha inline static guint32 compose_onto(guint32 px, guint32 bg) { guint ap = 0, rp = 0, gp = 0, bp = 0; @@ -212,10 +216,12 @@ inline static guint32 compose_onto(guint32 px, guint32 bg) ExtractARGB32(px, ap, rp, gp, bp); ExtractRGB32(bg, rb, gb, bb); - guint ao = 255*255 - (255-ap)*(255-bp); ao = (ao + 127) / 255; - guint ro = (255-ap)*rb + rp; ro = (ro + 127) / 255; - guint go = (255-ap)*gb + gp; go = (go + 127) / 255; - guint bo = (255-ap)*bb + bp; bo = (bo + 127) / 255; + // guint ao = 255*255 - (255-ap)*(255-bp); ao = (ao + 127) / 255; + // guint ao = (255-ap)*ab + 255*ap; ao = (ao + 127) / 255; + guint ao = 255; // Cairo version doesn't allow background to have alpha != 1. + guint ro = (255-ap)*rb + 255*rp; ro = (ro + 127) / 255; + guint go = (255-ap)*gb + 255*gp; go = (go + 127) / 255; + guint bo = (255-ap)*bb + 255*bp; bo = (bo + 127) / 255; guint pxout = AssembleARGB32(ao, ro, go, bo); return pxout; @@ -314,10 +320,12 @@ static bool compare_pixels(guint32 check, guint32 orig, guint32 merged_orig_pixe return abs(static_cast<int>(ac ? unpremul_alpha(bc, ac) : 0) - (ao ? unpremul_alpha(bo, ao) : 0)) <= threshold; case FLOOD_CHANNELS_RGB: guint32 amc, rmc, bmc, gmc; - amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255; - rmc = (255-ac)*rd + rc; rmc = (rmc + 127) / 255; - gmc = (255-ac)*gd + gc; gmc = (gmc + 127) / 255; - bmc = (255-ac)*bd + bc; bmc = (bmc + 127) / 255; + //amc = 255*255 - (255-ac)*(255-ad); amc = (amc + 127) / 255; + //amc = (255-ac)*ad + 255*ac; amc = (amc + 127) / 255; + amc = 255; // Why are we looking at desktop? Cairo version ignores destop alpha + rmc = (255-ac)*rd + 255*rc; rmc = (rmc + 127) / 255; + gmc = (255-ac)*gd + 255*gc; gmc = (gmc + 127) / 255; + bmc = (255-ac)*bd + 255*bc; bmc = (bmc + 127) / 255; diff += abs(static_cast<int>(amc ? unpremul_alpha(rmc, amc) : 0) - (amop ? unpremul_alpha(rmop, amop) : 0)); diff += abs(static_cast<int>(amc ? unpremul_alpha(gmc, amc) : 0) - (amop ? unpremul_alpha(gmop, amop) : 0)); @@ -826,6 +834,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even guchar *px = g_new(guchar, stride * height); guint32 bgcolor, dtc; + // Draw image into data block px { // this block limits the lifetime of Drawing and DrawingContext /* Create DrawingItems and set transform */ unsigned dkey = SPItem::display_key_new(1); @@ -854,6 +863,8 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even drawing.render(ct, final_bbox); + //cairo_surface_write_to_png( s, "cairo.png" ); + cairo_surface_flush(s); cairo_surface_destroy(s); @@ -861,6 +872,14 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even document->getRoot()->invoke_hide(dkey); } + // { + // // Dump data to png + // cairo_surface_t *s = cairo_image_surface_create_for_data( + // px, CAIRO_FORMAT_ARGB32, width, height, stride); + // cairo_surface_write_to_png( s, "cairo2.png" ); + // std::cout << " Wrote cairo2.png" << std::endl; + // } + guchar *trace_px = g_new(guchar, width * height); memset(trace_px, 0x00, width * height); |
