index 76beb12f5065b53a5a2a88f08300779acdce01d0..dc4de5bd33203449d60edb0cd1c8518b81908ce3 100644 (file)
-#define __NR_FILTER_SLOT_CPP__
-
/*
* A container class for filter slots. Allows for simple getting and
* setting images in filter slots without having to bother with
return (int)round(a);
}
-namespace NR {
+namespace Inkscape {
+namespace Filters {
FilterSlot::FilterSlot(int slots, NRArenaItem const *item)
+ : _last_out(-1),
+ filterquality(FILTER_QUALITY_BEST),
+ _arena_item(item)
{
_slot_count = ((slots > 0) ? slots : 2);
_slot = new NRPixBlock*[_slot_count];
_slot[i] = NULL;
_slot_number[i] = NR_FILTER_SLOT_NOT_SET;
}
-
- _last_out = -1;
-
- _arena_item = item;
}
FilterSlot::~FilterSlot()
void FilterSlot::get_final(int slot_nr, NRPixBlock *result) {
NRPixBlock *final_usr = get(slot_nr);
- Matrix trans = units.get_matrix_pb2display();
+ Geom::Matrix trans = units.get_matrix_pb2display();
int size = (result->area.x1 - result->area.x0)
* (result->area.y1 - result->area.y0)
memset(NR_PIXBLOCK_PX(result), 0, size);
if (fabs(trans[1]) > 1e-6 || fabs(trans[2]) > 1e-6) {
- transform_bicubic(result, final_usr, trans);
+ if (filterquality == FILTER_QUALITY_BEST) {
+ NR::transform_bicubic(result, final_usr, trans);
+ } else {
+ NR::transform_nearest(result, final_usr, trans);
+ }
} else if (fabs(trans[0] - 1) > 1e-6 || fabs(trans[3] - 1) > 1e-6) {
- scale_bicubic(result, final_usr);
+ NR::scale_bicubic(result, final_usr);
} else {
nr_blit_pixblock_pixblock(result, final_usr);
}
? _get_index(slot_nr)
: _get_index(NR_FILTER_UNNAMED_SLOT));
assert(index >= 0);
- // Unnamed slot is only for NR::FilterSlot internal use.
+ // Unnamed slot is only for Inkscape::Filters::FilterSlot internal use.
assert(slot_nr != NR_FILTER_UNNAMED_SLOT);
assert(slot_nr == NR_FILTER_SLOT_NOT_SET ||_slot_number[index] == slot_nr);
if (slot_nr == NR_FILTER_SOURCEGRAPHIC || slot_nr == NR_FILTER_BACKGROUNDIMAGE) {
- Matrix trans = units.get_matrix_display2pb();
+ Geom::Matrix trans = units.get_matrix_display2pb();
if (fabs(trans[1]) > 1e-6 || fabs(trans[2]) > 1e-6) {
NRPixBlock *trans_pb = new NRPixBlock;
int x0 = pb->area.x0;
trans[1] * x0 + trans[3] * y1 + trans[5],
trans[1] * x1 + trans[3] * y0 + trans[5],
trans[1] * x1 + trans[3] * y1 + trans[5]);
-
+
nr_pixblock_setup_fast(trans_pb, pb->mode,
min_x, min_y,
max_x, max_y, true);
* images are exported in horizontal stripes. One stripe
* is not too high, but can get thousands of pixels wide.
* Rotate this 45 degrees -> _huge_ image */
- g_warning("Memory allocation failed in NR::FilterSlot::set (transform)");
+ g_warning("Memory allocation failed in Inkscape::Filters::FilterSlot::set (transform)");
return;
}
- transform_bicubic(trans_pb, pb, trans);
+ if (filterquality == FILTER_QUALITY_BEST) {
+ NR::transform_bicubic(trans_pb, pb, trans);
+ } else {
+ NR::transform_nearest(trans_pb, pb, trans);
+ }
nr_pixblock_release(pb);
delete pb;
pb = trans_pb;
nr_pixblock_setup_fast(trans_pb, pb->mode,
min_x, min_y, max_x, max_y, true);
if (trans_pb->size != NR_PIXBLOCK_SIZE_TINY && trans_pb->data.px == NULL) {
- g_warning("Memory allocation failed in NR::FilterSlot::set (scaling)");
+ g_warning("Memory allocation failed in Inkscape::Filters::FilterSlot::set (scaling)");
return;
}
- scale_bicubic(trans_pb, pb);
+ NR::scale_bicubic(trans_pb, pb);
nr_pixblock_release(pb);
delete pb;
pb = trans_pb;
int seek = _slot_count;
do {
seek--;
- } while (_slot_number[seek] == NR_FILTER_SLOT_NOT_SET && seek >= 0);
+ } while ((seek >= 0) && (_slot_number[seek] == NR_FILTER_SLOT_NOT_SET));
/* If there is no space for more slots, create more space */
if (seek == _slot_count - 1) {
NRPixBlock **new_slot = new NRPixBlock*[_slot_count * 2];
this->units = units;
}
+void FilterSlot::set_quality(FilterQuality const q) {
+ filterquality = q;
}
+} /* namespace Filters */
+} /* namespace Inkscape */
+
/*
Local Variables:
mode:c++