25Cairo::RefPtr<Cairo::ImageSurface>
35 if (ibox.
width() != width_in || ibox.
height() != height_in) {
37 sf = std::min((
double)(width_in - 1) / dboxIn.
width(),
38 (
double)(height_in - 1) / dboxIn.
height());
40 ibox = scaled_box.roundOutwards();
45 int dx = ((int)width_in - ibox.
width()) / 2;
46 int dy = ((int)height_in - ibox.
height()) / 2;
54 auto surface = Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32, ua->width(), ua->height());
56 auto on_error = [&] (
char const *err) {
57 std::cerr <<
"render_preview: " << err << std::endl;
58 surface = Cairo::ImageSurface::create(Cairo::Surface::Format::ARGB32, ua->width(), ua->height());
63 auto cr = Cairo::Context::create(
surface);
64 cr->rectangle(0, 0, ua->width(), ua->height());
69 auto background = Cairo::RefPtr<Cairo::Pattern>(
new Cairo::Pattern(pattern,
true));
70 cr->set_source(background);
86 item->render(dc, *ua);
89 drawing->render(dc, *ua);
93 }
catch (std::bad_alloc
const &e) {
95 }
catch (Cairo::logic_error
const &e) {
cairo_pattern_t * ink_cairo_pattern_create_checkerboard(guint32 rgba, bool use_alpha)
Cairo integration helpers.
Cairo::RefPtr< Cairo::ImageSurface > surface
Axis aligned, non-empty, generic rectangle.
static CRect from_xywh(C x, C y, C w, C h)
Create rectangle from origin and dimensions.
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
CPoint min() const
Get the corner of the rectangle with smallest coordinate values.
Two-dimensional point with integer coordinates.
Axis aligned, non-empty rectangle.
IntRect roundOutwards() const
Return the smallest integer rectangle which contains this one.
Minimal wrapper over Cairo.
SVG drawing item for display.
Typed SVG document implementation.
constexpr double SP_RGBA32_G_F(uint32_t v)
constexpr double SP_RGBA32_R_F(uint32_t v)
constexpr double SP_RGBA32_A_F(uint32_t v)
constexpr double SP_RGBA32_B_F(uint32_t v)
Cairo drawing context with Inkscape extensions.
std::vector< Point > intersect(const xAx &C1, const xAx &C2)
Cairo::RefPtr< Cairo::ImageSurface > render_preview(SPDocument *doc, std::shared_ptr< Inkscape::Drawing > drawing, uint32_t bg, Inkscape::DrawingItem *item, unsigned width_in, unsigned height_in, Geom::Rect const &dboxIn)
Launch a background task to render a drawing to a surface.
Helper class to stream background task notifications as a series of messages.
Utility functions for previewing icon representation.