Code

Mnemonics in fill and stroke dialog and menu
[inkscape.git] / src / display / nr-filter-flood.cpp
index 5bd3466370c5dd78033ff508a928b26b43078188..3f4951dd65cf8237af468994ecf54293ad2b2063 100644 (file)
@@ -2,20 +2,27 @@
  * feFlood filter primitive renderer
  *
  * Authors:
- *   Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
+ *   Felipe CorrĂȘa da Silva Sanches <juca@members.fsf.org>
  *
  * Copyright (C) 2007 authors
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include "display/nr-filter-flood.h"
-namespace NR {
+#include "display/nr-filter-utils.h"
+#include "svg/svg-icc-color.h"
+#include "svg/svg-color.h"
+
+namespace Inkscape {
+namespace Filters {
 
 FilterFlood::FilterFlood()
-{
-    g_warning("FilterFlood::render not implemented.");
-}
+{}
 
 FilterPrimitive * FilterFlood::create() {
     return new FilterFlood();
@@ -24,29 +31,68 @@ FilterPrimitive * FilterFlood::create() {
 FilterFlood::~FilterFlood()
 {}
 
-int FilterFlood::render(FilterSlot &slot, Matrix const &trans) {
+int FilterFlood::render(FilterSlot &slot, FilterUnits const &/*units*/) {
+//g_message("rendering feflood");
     NRPixBlock *in = slot.get(_input);
+    if (!in) {
+        g_warning("Missing source image for feFlood (in=%d)", _input);
+        return 1;
+    }
+
+    int i;
+    int in_w = in->area.x1 - in->area.x0;
+    int in_h = in->area.y1 - in->area.y0;
     NRPixBlock *out = new NRPixBlock;
 
-    nr_pixblock_setup_fast(out, in->mode,
+    nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N,
                            in->area.x0, in->area.y0, in->area.x1, in->area.y1,
                            true);
 
-    unsigned char *in_data = NR_PIXBLOCK_PX(in);
     unsigned char *out_data = NR_PIXBLOCK_PX(out);
+    unsigned char r,g,b,a;
+
+
+        r = CLAMP_D_TO_U8((color >> 24) % 256);
+        g = CLAMP_D_TO_U8((color >> 16) % 256);
+        b = CLAMP_D_TO_U8((color >>  8) % 256);
+        a = CLAMP_D_TO_U8(opacity*255);
+
+#if ENABLE_LCMS
+        icc_color_to_sRGB(icc, &r, &g, &b);
+//g_message("result: r:%d g:%d b:%d", r, g, b);
+#endif //ENABLE_LCMS
+
+    for(i=0; i < 4*in_h*in_w; i+=4){
+            out_data[i]=r;
+            out_data[i+1]=g;
+            out_data[i+2]=b;
+            out_data[i+3]=a;
+    }
 
-//IMPLEMENT ME!
-    
     out->empty = FALSE;
     slot.set(_output, out);
     return 0;
 }
 
-void FilterFlood::area_enlarge(NRRectL &area, Matrix const &trans)
+void FilterFlood::set_color(guint32 c) {
+    color = c;
+}
+
+void FilterFlood::set_opacity(double o) {
+    opacity = o;
+}
+
+void FilterFlood::set_icc(SVGICCColor *icc_color) {
+    icc = icc_color;
+}
+
+void FilterFlood::area_enlarge(NRRectL &/*area*/, Geom::Matrix const &/*trans*/)
 {
 }
 
-} /* namespace NR */
+} /* namespace Filters */
+} /* namespace Inkscape */
 
 /*
   Local Variables:
@@ -57,4 +103,4 @@ void FilterFlood::area_enlarge(NRRectL &area, Matrix const &trans)
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :