nr-filter-image.cpp revision 06aecef405c4cf6f7551ab622c3040562cb62c78
/*
* feImage filter primitive renderer
*
* Authors:
* Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
* Tavmjong Bah <tavmjong@free.fr>
*
* Copyright (C) 2007 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "document.h"
#include "sp-item.h"
#include "display/nr-arena.h"
#include "display/nr-arena-item.h"
#include "display/nr-filter.h"
#include "display/nr-filter-image.h"
#include "display/nr-filter-units.h"
#include "libnr/nr-matrix.h"
#include "libnr/nr-rect-l.h"
namespace NR {
{
}
return new FilterImage();
}
{
}
if (!feImageHref) return 0;
bool free_pb_on_exit = false;
if(from_element){
if (!SVGElem) return 0;
// prep the document
if (!ai) {
g_warning("feImage renderer: error creating NRArenaItem for SVG Element");
return 0;
}
pb = new NRPixBlock;
free_pb_on_exit = true;
0.0, 1.0,
0.0, 0.0);
/* Update to renderable state */
double sf = 1.0;
}
if (!image_pixbuf){
try {
// Try to load from relative postion combined with document base
if( document ) {
}
}
// Should display Broken Image png.
}
}
{
return 0;
}
catch (const Gdk::PixbufError & e)
{
return 0;
}
if ( !image ) return 0;
// Native size of image
}
int w,x,y;
if (!in) {
return 1;
}
// This section needs to be fully tested!!
// Region being drawn on screen
// Get the object bounding box. Image is placed with respect to box.
// Array values: 0: width; 3: height; 4: -x; 5: -y.
// feImage is suppose to use the same parameters as a normal SVG image.
// If a width or height is set to zero, the image is not suppose to be displayed.
// This does not seem to be what Firefox or Opera does, nor does the W3C displacement
// the width and height of the object bounding box.
//TODO: use interpolation
// Temporarily add 0.5 so we sample center of "cell"
// coordx == 0 and coordy == 0 must be included, but we protect
// against negative numbers which round up to 0 with (int).
if (from_element){
out_data[4*((x - x0)+w*(y - y0)) + 1] = (unsigned char) image_pixbuf[4*(coordx + width*coordy) + 1]; //Green
out_data[4*((x - x0)+w*(y - y0)) + 2] = (unsigned char) image_pixbuf[4*(coordx + width*coordy) + 2]; //Blue
out_data[4*((x - x0)+w*(y - y0)) + 3] = (unsigned char) image_pixbuf[4*(coordx + width*coordy) + 3]; //Alpha
} else {
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
}
}
}
}
return 0;
}
}
}
}
return TRAIT_PARALLER;
}
} /* 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 :