@@ -659,6 +659,12 @@ RendererAgg::bbox_to_rect(const Py::Object& o) {
659659
660660void
661661RendererAgg::set_clip_from_bbox (const Py::Object& o) {
662+
663+ // do not puut this in the else below. We want to unconditionally
664+ // clear the clip
665+ theRasterizer->reset_clipping ();
666+ rendererBase->reset_clipping (true );
667+
662668 if (o.ptr () != Py_None) { // using clip
663669 // Bbox::check(args[0]) failing; something about cross module?
664670 // set the clip rectangle
@@ -670,9 +676,9 @@ RendererAgg::set_clip_from_bbox(const Py::Object& o) {
670676 double r = clipbox->ur_api ()->x_api ()->val () ;
671677 double t = clipbox->ur_api ()->y_api ()->val () ; ;
672678 theRasterizer->clip_box (l, height-t, r, height-b);
679+ rendererBase->clip_box ((int )l, (int )(height-t), (int )r, (int )(height-b));
673680 }
674681
675-
676682}
677683
678684
@@ -1591,150 +1597,18 @@ RendererAgg::draw_text(const Py::Tuple& args) {
15911597
15921598}
15931599
1594- /*
1595- Py::Object
1596- RendererAgg::draw_image(const Py::Tuple& args) {
1597- _VERBOSE("RendererAgg::draw_image");
1598- theRasterizer->reset_clipping();
1599- args.verify_length(5);
1600-
1601- float x = Py::Float(args[0]);
1602- float y = Py::Float(args[1]);
1603- Image *image = static_cast<Image*>(args[2].ptr());
1604- std::string origin = Py::String(args[3]);
1605-
1606- if (origin!="lower" && origin!="upper")
1607- throw Py::ValueError(Printf("origin must be upper|lower; found %s", origin.c_str()).str());
1608-
1609- bool isUpper = origin=="upper";
1610-
1611- size_t ind = 0;
1612- size_t thisx, thisy;
1613- float oy = isUpper ? y : height-y;
1614-
1615- float minx(0), maxx(width), miny(0), maxy(height);
1616-
1617- if (args[4].ptr() != Py_None) {
1618- Bbox* bbox = static_cast<Bbox*>(args[4].ptr());
1619- minx = bbox->ll_api()->x_api()->val();
1620- maxy = height-bbox->ll_api()->y_api()->val();
1621- maxx = bbox->ur_api()->x_api()->val();
1622- miny = height-bbox->ur_api()->y_api()->val();
1623- }
1624-
1625- //if (isUpper) oy -= image->rowsOut; //start at top
1626- for (size_t j=0; j<image->rowsOut; j++) {
1627- thisy = (size_t)(isUpper ? oy+j : oy-j-0.5);
1628- if (thisy<miny || thisy>=maxy) {
1629- ind += 4*image->colsOut;
1630- continue;
1631- }
1632- for (size_t i=0; i<image->colsOut; i++) {
1633- thisx = (size_t)(i+x);
1634- if (thisx<minx || thisx>=maxx) {
1635- ind += 4;
1636- continue;
1637- }
1638-
1639- pixfmt::color_type p;
1640-
1641- p.r = *(image->bufferOut+ind++);
1642- p.g = *(image->bufferOut+ind++);
1643- p.b = *(image->bufferOut+ind++);
1644- p.a = *(image->bufferOut+ind++);
1645-
1646- pixFmt->blend_pixel(thisx, thisy, p, p.a);
1647- }
1648- }
1649-
1650- return Py::Object();
1651-
1652- }
1653- */
1654-
1655- /*
1656- Py::Object
1657- RendererAgg::draw_image(const Py::Tuple& args) {
1658- _VERBOSE("RendererAgg::draw_image");
1659- theRasterizer->reset_clipping();
1660- args.verify_length(4);
1661-
1662- float x = Py::Float(args[0]);
1663- float y = Py::Float(args[1]);
1664- Image *image = static_cast<Image*>(args[2].ptr());
1665-
1666- size_t ind = 0;
1667- size_t thisx, thisy;
1668- float oy = height-y;
1669-
1670- float minx(0), maxx(width), miny(0), maxy(height);
1671-
1672- if (args[3].ptr() != Py_None) {
1673- Bbox* bbox = static_cast<Bbox*>(args[3].ptr());
1674- minx = bbox->ll_api()->x_api()->val();
1675- maxy = height-bbox->ll_api()->y_api()->val();
1676- maxx = bbox->ur_api()->x_api()->val();
1677- miny = height-bbox->ur_api()->y_api()->val();
1678- }
1679-
1680-
1681-
1682- //if (isUpper) oy -= image->rowsOut; //start at top
1683-
1684- for (size_t j=0; j<image->rowsOut; j++) {
1685- thisy = (size_t)(oy-j-0.5);
1686- if (thisy<miny || thisy>=maxy) {
1687- ind += 4*image->colsOut;
1688- continue;
1689- }
1690- for (size_t i=0; i<image->colsOut; i++) {
1691- thisx = (size_t)(i+x);
1692- if (thisx<minx || thisx>=maxx) {
1693- ind += 4;
1694- continue;
1695- }
1696-
1697- pixfmt::color_type p;
1698-
1699- p.r = *(image->bufferOut+ind++);
1700- p.g = *(image->bufferOut+ind++);
1701- p.b = *(image->bufferOut+ind++);
1702- p.a = *(image->bufferOut+ind++);
1703-
1704- pixFmt->blend_pixel(thisx, thisy, p, p.a);
1705- }
1706- }
1707-
1708- return Py::Object();
1709-
1710- }
1711-
1712- */
1713-
17141600
17151601Py::Object
17161602RendererAgg::draw_image (const Py::Tuple& args) {
17171603 _VERBOSE (" RendererAgg::draw_image" );
1718- theRasterizer->reset_clipping ();
17191604 args.verify_length (4 );
17201605
17211606 float x = Py::Float (args[0 ]);
17221607 float y = Py::Float (args[1 ]);
17231608 Image *image = static_cast <Image*>(args[2 ].ptr ());
17241609
1725-
1726- float minx (0 ), maxx (width), miny (0 ), maxy (height);
1727-
1728- if (args[3 ].ptr () != Py_None) {
1729- Bbox* bbox = static_cast <Bbox*>(args[3 ].ptr ());
1730- minx = bbox->ll_api ()->x_api ()->val ();
1731- maxy = height-bbox->ll_api ()->y_api ()->val ();
1732- maxx = bbox->ur_api ()->x_api ()->val ();
1733- miny = height-bbox->ur_api ()->y_api ()->val ();
1734- // theRasterizer->clip_box(minx, miny, maxx, maxy);
1735- }
1610+ set_clip_from_bbox (args[3 ]);
17361611
1737-
17381612 pixfmt pixf (*(image->rbufOut ));
17391613
17401614
0 commit comments