summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: af33014)
raw | patch | inline | side by side (parent: af33014)
author | jucablues <jucablues@users.sourceforge.net> | |
Wed, 16 Jan 2008 10:35:46 +0000 (10:35 +0000) | ||
committer | jucablues <jucablues@users.sourceforge.net> | |
Wed, 16 Jan 2008 10:35:46 +0000 (10:35 +0000) |
src/display/nr-filter-flood.cpp | patch | blob | history | |
src/display/nr-filter-flood.h | patch | blob | history | |
src/sp-feflood.cpp | patch | blob | history | |
src/sp-feflood.h | patch | blob | history |
index 7eade278957d171ed5e121d0b6f625e89747208b..951e5e460af6edb8266eb248395a1c341a9e70d5 100644 (file)
*/
#include "display/nr-filter-flood.h"
-#include "display/nr-filter-units.h"
+#include "display/nr-filter-utils.h"
namespace NR {
FilterFlood::FilterFlood()
-{
- g_warning("FilterFlood::render not implemented.");
-}
+{}
FilterPrimitive * FilterFlood::create() {
return new FilterFlood();
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,
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);
-//IMPLEMENT ME!
- (void)in_data;
- (void)out_data;
+ unsigned char r,g,b,a;
+ r = (unsigned char) (color >> 24) % 256;
+ g = (unsigned char) (color >> 16) % 256;
+ b = (unsigned char) (color >> 8) % 256;
+ a = CLAMP_D_TO_U8(opacity*256);
+
+ 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;
+ }
out->empty = FALSE;
slot.set(_output, out);
return 0;
}
+void FilterFlood::set_color(guint32 c) {
+ color = c;
+}
+
+void FilterFlood::set_opacity(double o) {
+ opacity = o;
+}
+
void FilterFlood::area_enlarge(NRRectL &/*area*/, Matrix const &/*trans*/)
{
}
index 34cde5a7867d01bdd7313ca719b59e2941bdc9f5..6f7779a73186ddc43e0e63c5f81969d53ef7d9d0 100644 (file)
FilterFlood();
static FilterPrimitive *create();
virtual ~FilterFlood();
-
+
+ virtual void set_opacity(double o);
+ virtual void set_color(guint32 c);
virtual int render(FilterSlot &slot, FilterUnits const &units);
virtual void area_enlarge(NRRectL &area, Matrix const &trans);
+private:
+ double opacity;
+ guint32 color;
};
} /* namespace NR */
diff --git a/src/sp-feflood.cpp b/src/sp-feflood.cpp
index b3b9ac1d50795ea04c1202e0e95b3c02891ea15b..685859c632f00e22abc3bda77bc2e8c761f3d7bf 100644 (file)
--- a/src/sp-feflood.cpp
+++ b/src/sp-feflood.cpp
#include "svg/svg.h"
#include "sp-feflood.h"
#include "xml/repr.h"
-
+#include "helper-fns.h"
+#include "svg/svg-color.h"
/* FeFlood base class */
}
/*LOAD ATTRIBUTES FROM REPR HERE*/
+ sp_object_read_attr(object, "flood-opacity");
+ sp_object_read_attr(object, "flood-color");
}
/**
{
SPFeFlood *feFlood = SP_FEFLOOD(object);
(void)feFlood;
-
+ gchar const *cend_ptr = NULL;
+ guint32 read_color;
+ double read_num;
+
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
+ case SP_PROP_FLOOD_COLOR:
+ cend_ptr = NULL;
+ read_color = sp_svg_read_color(value, &cend_ptr, 0xffffffff);
+ if (cend_ptr && read_color != feFlood->color){
+ feFlood->color = read_color;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
+ break;
+ case SP_PROP_FLOOD_OPACITY:
+ read_num = helperfns_read_number(value);
+ if (read_num != feFlood->opacity){
+ feFlood->opacity = read_num;
+ object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
+ break;
default:
if (((SPObjectClass *) feFlood_parent_class)->set)
((SPObjectClass *) feFlood_parent_class)->set(object, key, value);
@@ -177,6 +198,9 @@ static void sp_feFlood_build_renderer(SPFilterPrimitive *primitive, NR::Filter *
g_assert(nr_flood != NULL);
sp_filter_primitive_renderer_common(primitive, nr_primitive);
+
+ nr_flood->set_opacity(sp_flood->opacity);
+ nr_flood->set_color(sp_flood->color);
}
diff --git a/src/sp-feflood.h b/src/sp-feflood.h
index c0df0d31201742a542e6cdf9ddc98e16faca2b8e..4d17022584acd2702d2a9fbe565150da48c21438 100644 (file)
--- a/src/sp-feflood.h
+++ b/src/sp-feflood.h
struct SPFeFlood : public SPFilterPrimitive {
/** FLOOD ATTRIBUTES HERE */
-
+ guint32 color;
+ double opacity;
};
struct SPFeFloodClass {