summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1512d64)
raw | patch | inline | side by side (parent: 1512d64)
author | jucablues <jucablues@users.sourceforge.net> | |
Mon, 5 Nov 2007 07:00:34 +0000 (07:00 +0000) | ||
committer | jucablues <jucablues@users.sourceforge.net> | |
Mon, 5 Nov 2007 07:00:34 +0000 (07:00 +0000) |
works for filenames.) Removed a hardcoded string.
This part of the code must be improved in order to reference other
pieces of SVG. I need somebody to help me on working with proper URI
handling!
Also fixed gdk pixbuf handling.
This part of the code must be improved in order to reference other
pieces of SVG. I need somebody to help me on working with proper URI
handling!
Also fixed gdk pixbuf handling.
src/display/nr-filter-image.cpp | patch | blob | history | |
src/display/nr-filter-image.h | patch | blob | history | |
src/sp-feimage.cpp | patch | blob | history | |
src/sp-feimage.h | patch | blob | history |
index b8abb0317f0eefead705016fd88437c3d39cf2b7..d96d2013b9dce6160fe3d8efac4570d160b85c56 100644 (file)
FilterImage::FilterImage()
{
-// Testing with hardcoded xlink:href :
- image = Gdk::Pixbuf::create_from_file("../images/image1.jpg");
- //TODO: handle errors
- width = image->get_width()+1;
- height = image->get_height()+1;
- image_pixbuf = image->get_pixels();
+ feImageHref=NULL;
+ image_pixbuf=NULL;
}
FilterPrimitive * FilterImage::create() {
}
FilterImage::~FilterImage()
-{}
+{
+ if (feImageHref) g_free(feImageHref);
+ if (image_pixbuf) g_free(image_pixbuf);
+}
int FilterImage::render(FilterSlot &slot, FilterUnits const &units) {
+ if (!feImageHref) return 0;
+
+ if (!image_pixbuf){
+ if ( (image = Gdk::Pixbuf::create_from_file(feImageHref)) < 0 ) return 0;
+ width = image->get_width();
+ height = image->get_height();
+ rowstride = image->get_rowstride();
+ image_pixbuf = image->get_pixels();
+ }
int w,x,y;
NRPixBlock *in = slot.get(_input);
NRPixBlock *out = new NRPixBlock;
coordy = int((y - feImageY - bbox_y0)*scaleY);
if (coordx > 0 && coordx < width && coordy > 0 && coordy < height){
- out_data[4*((x - x0)+w*(y - y0))] = (unsigned char) image_pixbuf[3*(coordx + width*coordy)]; //Red
- out_data[4*((x - x0)+w*(y - y0)) + 1] = (unsigned char) image_pixbuf[3*(coordx + width*coordy) + 1]; //Green
- out_data[4*((x - x0)+w*(y - y0)) + 2] = (unsigned char) image_pixbuf[3*(coordx + width*coordy) + 2]; //Blue
+ out_data[4*((x - x0)+w*(y - y0))] = (unsigned char) image_pixbuf[3*coordx + rowstride*coordy]; //Red
+ out_data[4*((x - x0)+w*(y - y0)) + 1] = (unsigned char) image_pixbuf[3*coordx + rowstride*coordy + 1]; //Green
+ out_data[4*((x - x0)+w*(y - y0)) + 2] = (unsigned char) image_pixbuf[3*coordx + rowstride*coordy + 2]; //Blue
out_data[4*((x - x0)+w*(y - y0)) + 3] = 255; //Alpha
}
}
slot.set(_output, out);
return 0;
}
+
+void FilterImage::set_href(const gchar *href){
+ if (feImageHref) g_free (feImageHref);
+ feImageHref = (href) ? g_strdup (href) : NULL;
+}
+
void FilterImage::set_region(SVGLength x, SVGLength y, SVGLength width, SVGLength height){
feImageX=x.computed;
feImageY=y.computed;
index 9d4057826de38f04f17b8154233017e8300624ef..47bfe157b8f4acce6f8540858f22623c17e96a2c 100644 (file)
virtual int render(FilterSlot &slot, FilterUnits const &units);
virtual FilterTraits get_input_traits();
+ void set_href(const gchar *href);
void set_region(SVGLength x, SVGLength y, SVGLength width, SVGLength height);
private:
+ gchar *feImageHref;
guint8* image_pixbuf;
Glib::RefPtr<Gdk::Pixbuf> image;
- int width, height;
+ int width, height, rowstride;
float feImageX,feImageY,feImageWidth,feImageHeight;
};
diff --git a/src/sp-feimage.cpp b/src/sp-feimage.cpp
index a360151803d7cbbec92b8e6e938a4318b31afea9..9456b5966928a5c9fe752b281e7ce7c9b41bdb73 100644 (file)
--- a/src/sp-feimage.cpp
+++ b/src/sp-feimage.cpp
@@ -98,14 +98,12 @@ sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *re
}
/*LOAD ATTRIBUTES FROM REPR HERE*/
-/* apparently there's no attribute to load here
-since 'in' and 'xlink:href' are common filter attributes.
---Juca
-*/
+
sp_object_read_attr(object, "x");
sp_object_read_attr(object, "y");
sp_object_read_attr(object, "width");
sp_object_read_attr(object, "height");
+ sp_object_read_attr(object, "xlink:href");
}
switch(key) {
/*DEAL WITH SETTING ATTRIBUTES HERE*/
+ case SP_ATTR_XLINK_HREF:
+ if (feImage->href) g_free(feImage->href);
+ feImage->href = (value) ? g_strdup (value) : NULL;
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ break;
case SP_ATTR_X:
feImage->x.readOrUnset(value);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
@@ -209,6 +212,7 @@ static void sp_feImage_build_renderer(SPFilterPrimitive *primitive, NR::Filter *
sp_filter_primitive_renderer_common(primitive, nr_primitive);
nr_image->set_region(sp_image->x, sp_image->y, sp_image->width, sp_image->height);
+ nr_image->set_href(sp_image->href);
}
/*
diff --git a/src/sp-feimage.h b/src/sp-feimage.h
index 6786471ad14fa19e14acfb6c7c1418a28459c9e4..0c0289d6e5196da77f2639d421ee3b8bc380a975 100644 (file)
--- a/src/sp-feimage.h
+++ b/src/sp-feimage.h
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
- */
+ gchar *href;
SVGLength x, y, height, width;
};