diff options
| author | Felipe Corr??a da Silva Sanches <juca@members.fsf.org> | 2007-08-14 04:39:37 +0000 |
|---|---|---|
| committer | jucablues <jucablues@users.sourceforge.net> | 2007-08-14 04:39:37 +0000 |
| commit | 53e2573939d10365f9839ec4256f1faa8019a249 (patch) | |
| tree | 111b2a9c7a27818720f32453499d55372475b15c /src/display | |
| parent | typo (diff) | |
| download | inkscape-53e2573939d10365f9839ec4256f1faa8019a249.tar.gz inkscape-53e2573939d10365f9839ec4256f1faa8019a249.zip | |
* incomplete feImage implementation.
* contains a hardcoded href parameter. TODO: fix it.
* added a getter method to access arenaitem from FilterSlot.
(bzr r3461)
Diffstat (limited to 'src/display')
| -rw-r--r-- | src/display/nr-filter-image.cpp | 55 | ||||
| -rw-r--r-- | src/display/nr-filter-image.h | 3 | ||||
| -rw-r--r-- | src/display/nr-filter-slot.cpp | 5 | ||||
| -rw-r--r-- | src/display/nr-filter-slot.h | 3 | ||||
| -rw-r--r-- | src/display/nr-filter.h | 2 |
5 files changed, 40 insertions, 28 deletions
diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index b1a5b4d7a..8e89cdc81 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -8,22 +8,20 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ - +#include "display/nr-arena-item.h" +#include "display/nr-filter.h" #include "display/nr-filter-image.h" -// #include <string.h> -// #include <gtkmm.h> namespace NR { FilterImage::FilterImage() { - g_warning("FilterImage::render not implemented."); -/* Testing with hardcoded xlink:href : - image = Gdk::Pixbuf::create_from_file("/home/felipe/images/image1.jpg"); +// 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();*/ + image_pixbuf = image->get_pixels(); } FilterPrimitive * FilterImage::create() { @@ -34,43 +32,48 @@ FilterImage::~FilterImage() {} int FilterImage::render(FilterSlot &slot, Matrix const &trans) { - return 0; -/* 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 -*/ - -/* int w,x,y; + 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; + int bbox_x0 = (int) slot.get_arenaitem()->bbox.x0; + int bbox_y0 = (int) slot.get_arenaitem()->bbox.y0; nr_pixblock_setup_fast(out, in->mode, x0, y0, x1, y1, true); w = x1 - x0; + double scaleX = width/feImageWidth; + double scaleY = height/feImageHeight; + int coordx,coordy; 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 + //TODO: use interpolation + coordx = int((x - feImageX - bbox_x0)*scaleX); + 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)) + 3] = 255; //Alpha + } } } out->empty = FALSE; slot.set(_output, out); - return 0;*/ + return 0; } - +void FilterImage::set_region(SVGLength x, SVGLength y, SVGLength width, SVGLength height){ + feImageX=x.computed; + feImageY=y.computed; + feImageWidth=width.computed; + feImageHeight=height.computed; +} + } /* namespace NR */ /* diff --git a/src/display/nr-filter-image.h b/src/display/nr-filter-image.h index cad5d4ee1..5841ad86a 100644 --- a/src/display/nr-filter-image.h +++ b/src/display/nr-filter-image.h @@ -25,11 +25,12 @@ public: virtual ~FilterImage(); virtual int render(FilterSlot &slot, Matrix const &trans); - + void set_region(SVGLength x, SVGLength y, SVGLength width, SVGLength height); private: guint8* image_pixbuf; Glib::RefPtr<Gdk::Pixbuf> image; int width, height; + float feImageX,feImageY,feImageWidth,feImageHeight; }; } /* namespace NR */ diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 3cdc20ede..9775a99a7 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -133,6 +133,11 @@ int FilterSlot::get_slot_count() return seek + 1; } +NRArenaItem const* FilterSlot::get_arenaitem() +{ + return _arena_item; +} + int FilterSlot::_get_index(int slot_nr) { assert(slot_nr >= 0 || diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index 09190a9b0..8c24a3641 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -57,6 +57,9 @@ public: /** Returns the number of slots in use. */ int get_slot_count(); + /** arenaitem getter method*/ + NRArenaItem const* get_arenaitem(); + private: NRPixBlock **_slot; int *_slot_number; diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 835266e73..9f26a1f3b 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -77,7 +77,7 @@ public: */ void set_output(int slot); - void set_x(SVGLength const &lenght); + void set_x(SVGLength const &length); void set_y(SVGLength const &length); void set_width(SVGLength const &length); void set_height(SVGLength const &length); |
