summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e4a45ca)
raw | patch | inline | side by side (parent: e4a45ca)
author | jucablues <jucablues@users.sourceforge.net> | |
Thu, 26 Jul 2007 03:08:18 +0000 (03:08 +0000) | ||
committer | jucablues <jucablues@users.sourceforge.net> | |
Thu, 26 Jul 2007 03:08:18 +0000 (03:08 +0000) |
src/display/Makefile_insert | patch | blob | history | |
src/display/nr-filter-image.cpp | [new file with mode: 0644] | patch | blob |
src/display/nr-filter-image.h | [new file with mode: 0644] | patch | blob |
src/display/nr-filter.cpp | patch | blob | history | |
src/sp-feimage.cpp | patch | blob | history | |
src/sp-feimage.h | patch | blob | history |
index f31236674327889c27b25000b1732c7e750a4cdf..baeaaec620ad8b63b3be8b97dc3db0640aaac8b1 100644 (file)
display/nr-filter-convolve-matrix.h \
display/nr-filter-displacement-map.cpp \
display/nr-filter-displacement-map.h \
+ display/nr-filter-image.cpp \
+ display/nr-filter-image.h \
display/nr-filter-slot.cpp \
display/nr-filter-slot.h \
display/nr-filter-getalpha.cpp \
diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * feImage filter primitive renderer
+ *
+ * Authors:
+ * Felipe Corrêa da Silva Sanches <felipe.sanches@gmail.com>
+ *
+ * Copyright (C) 2007 authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "display/nr-filter-image.h"
+// #include <string.h>
+// #include <gtkmm.h>
+
+namespace NR {
+
+FilterImage::FilterImage()
+{
+/* Testing with hardcoded xlink:href :
+ image = Gdk::Pixbuf::create_from_file("/home/felipe/images/image1.jpg");
+ //TODO: handle errors
+ width = image->get_width()+1;
+ height = image->get_height()+1;
+ image_pixbuf = image->get_pixels();*/
+}
+
+FilterPrimitive * FilterImage::create() {
+ return new FilterImage();
+}
+
+FilterImage::~FilterImage()
+{}
+
+int FilterImage::render(FilterSlot &slot, Matrix const &trans) {
+/* TODO: Implement this renderer method.
+Specification: http://www.w3.org/TR/SVG11/filters.html#feImage
+
+ It would be good to findout how to reuse sp-image.cpp code
+
+After implementing it, add a reference to FilterImage::create
+ on Filter::_create_constructor_table() (nr-filter.cpp file)
+*/
+
+/* int w,x,y;
+ NRPixBlock *in = slot.get(_input);
+ NRPixBlock *out = new NRPixBlock;
+
+ int x0 = in->area.x0, y0 = in->area.y0;
+ int x1 = in->area.x1, y1 = in->area.y1;
+ if (x0<0) x0 = 0;
+ if (x1>width-1) x1 = width-1;
+
+ if (y0<0) y0 = 0;
+ if (y1>height-1) y1 = height-1;
+
+ nr_pixblock_setup_fast(out, in->mode, x0, y0, x1, y1, true);
+
+ w = x1 - x0;
+ unsigned char *out_data = NR_PIXBLOCK_PX(out);
+ for (x=x0; x < x1; x++){
+ for (y=y0; y < y1; y++){
+ out_data[4*((x - x0)+w*(y - y0))] = (unsigned char) image_pixbuf[3*(x+width*y)]; //Red
+ out_data[4*((x - x0)+w*(y - y0)) + 1] = (unsigned char) image_pixbuf[3*(x+width*y) + 1]; //Green
+ out_data[4*((x - x0)+w*(y - y0)) + 2] = (unsigned char) image_pixbuf[3*(x+width*y) + 2]; //Blue
+ out_data[4*((x - x0)+w*(y - y0)) + 3] = 255; //Alpha
+ }
+ }
+
+ out->empty = FALSE;
+ slot.set(_output, out);
+ return 0;*/
+}
+
+} /* namespace NR */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/display/nr-filter-image.h b/src/display/nr-filter-image.h
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef __NR_FILTER_IMAGE_H__
+#define __NR_FILTER_IMAGE_H__
+
+/*
+ * feImage filter primitive renderer
+ *
+ * Authors:
+ * Niko Kiirala <niko@kiirala.com>
+ *
+ * Copyright (C) 2007 authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "display/nr-filter-primitive.h"
+#include "display/nr-filter-slot.h"
+#include <gtkmm.h>
+
+namespace NR {
+
+class FilterImage : public FilterPrimitive {
+public:
+ FilterImage();
+ static FilterPrimitive *create();
+ virtual ~FilterImage();
+
+ virtual int render(FilterSlot &slot, Matrix const &trans);
+
+private:
+ guint8* image_pixbuf;
+ Glib::RefPtr<Gdk::Pixbuf> image;
+ int width, height;
+};
+
+} /* namespace NR */
+
+#endif /* __NR_FILTER_IMAGE_H__ */
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
index 2491fba35aa0d35d5c168f7bcf927299b8641a11..eb6a48e6c97dc606bcf5b39ef14c3c1fa6720dd5 100644 (file)
#include "display/nr-filter-composite.h"
#include "display/nr-filter-diffuselighting.h"
#include "display/nr-filter-specularlighting.h"
+#include "display/nr-filter-image.h"
#include "display/nr-arena-item.h"
#include "libnr/nr-pixblock.h"
diff --git a/src/sp-feimage.cpp b/src/sp-feimage.cpp
index 6c0aa9e4f424c7c9c58e1d93d287b3b33d07bcb2..810e4b5d77453aee8b25c965c110a62dc9ce4324 100644 (file)
--- a/src/sp-feimage.cpp
+++ b/src/sp-feimage.cpp
*/
/*
* Authors:
+ * Felipe Corrêa da Silva Sanches <felipe.sanches@gmail.com>
* hugo Rodrigues <haa.rodrigues@gmail.com>
*
+ * Copyright (C) 2007 Felipe Sanches
* Copyright (C) 2006 Hugo Rodrigues
*
* Released under GNU GPL, read the file 'COPYING' for more information
#include "svg/svg.h"
#include "sp-feimage.h"
#include "xml/repr.h"
+#include <string.h>
+#include "display/nr-filter.h"
+#include "display/nr-filter-image.h"
/* FeImage base class */
static void sp_feImage_set(SPObject *object, unsigned int key, gchar const *value);
static void sp_feImage_update(SPObject *object, SPCtx *ctx, guint flags);
static Inkscape::XML::Node *sp_feImage_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static void sp_feImage_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter);
static SPFilterPrimitiveClass *feImage_parent_class;
sp_feImage_class_init(SPFeImageClass *klass)
{
SPObjectClass *sp_object_class = (SPObjectClass *)klass;
+ SPFilterPrimitiveClass * sp_primitive_class = (SPFilterPrimitiveClass *)klass;
feImage_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass);
sp_object_class->write = sp_feImage_write;
sp_object_class->set = sp_feImage_set;
sp_object_class->update = sp_feImage_update;
+
+ sp_primitive_class->build_renderer = sp_feImage_build_renderer;
}
static void
}
/*LOAD ATTRIBUTES FROM REPR HERE*/
+/* apparently there's no attribute to load here
+since 'in' and 'xlink:href' are common filter attributes.
+--Juca
+*/
+
}
/**
return repr;
}
+static void sp_feImage_build_renderer(SPFilterPrimitive *primitive, NR::Filter *filter) {
+ g_assert(primitive != NULL);
+ g_assert(filter != NULL);
+
+ SPFeImage *sp_image = SP_FEIMAGE(primitive);
+
+ int primitive_n = filter->add_primitive(NR::NR_FILTER_IMAGE);
+ NR::FilterPrimitive *nr_primitive = filter->get_primitive(primitive_n);
+ NR::FilterImage *nr_image = dynamic_cast<NR::FilterImage*>(nr_primitive);
+ g_assert(nr_image != NULL);
+
+ sp_filter_primitive_renderer_common(primitive, nr_primitive);
+
+}
/*
Local Variables:
diff --git a/src/sp-feimage.h b/src/sp-feimage.h
index cb6f48f40f8981a8299c3349607a41ae54eadd63..819eac20e5c9b3b99caf09a516a9fc86f2f4145f 100644 (file)
--- a/src/sp-feimage.h
+++ b/src/sp-feimage.h
*/
/*
* Authors:
+ * Felipe Corrêa da Silva Sanches <felipe.sanches@gmail.com>
* Hugo Rodrigues <haa.rodrigues@gmail.com>
*
* Copyright (C) 2006 Hugo Rodrigues
struct SPFeImage : public SPFilterPrimitive {
/** IMAGE ATTRIBUTES HERE */
-
+ /*
+ Apparently there's no attribute to keep here
+ since 'in' and 'xlink:href' are common filter attributes.
+ --Juca
+ */
};
struct SPFeImageClass {