Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-image.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Authors:
6 * Lauris Kaplinski <lauris@kaplinski.com>
7 * Edward Flick (EAF)
8 *
9 * Copyright (C) 1999-2005 Authors
10 * Copyright (C) 2000-2001 Ximian, Inc.
11 *
12 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
13 */
14
15#ifndef SEEN_INKSCAPE_SP_IMAGE_H
16#define SEEN_INKSCAPE_SP_IMAGE_H
17
18#include "sp-item.h"
19
20#include <memory>
21
22#include <glibmm/ustring.h>
23#include <2geom/pathvector.h>
24
25#include "sp-dimensions.h"
26#include "viewbox.h"
27
28#define SP_IMAGE_HREF_MODIFIED_FLAG SP_OBJECT_USER_MODIFIED_FLAG_A
29
30namespace Inkscape { class Pixbuf; class URI; }
31class SPImage final : public SPItem, public SPViewBox, public SPDimensions {
32public:
33 SPImage();
34 ~SPImage() override;
35 int tag() const override { return tag_of<decltype(*this)>; }
36
38 double sx, sy;
39 double ox, oy;
40 double dpi;
42
43 std::optional<Geom::PathVector> curve; // This curve is at the image's boundary for snapping
44
45 char *href;
47
48 std::shared_ptr<Inkscape::Pixbuf const> pixbuf;
49 bool missing = true;
50
52 void release() override;
53 void set(SPAttr key, char const* value) override;
54 void update(SPCtx *ctx, unsigned int flags) override;
56 void modified(unsigned int flags) override;
57
58 Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const override;
59 void print(SPPrintContext *ctx) override;
60 const char* typeName() const override;
61 const char* displayName() const override;
62 char* description() const override;
63 Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override;
64 void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const override;
66
68
69 Geom::PathVector const *get_curve() const;
71 bool cropToArea(Geom::Rect area);
72 bool cropToArea(const Geom::IntRect &area);
73
74 Inkscape::URI getURI() const;
75private:
76 static Inkscape::Pixbuf *readImage(gchar const *href, gchar const *absref, gchar const *base, double svgdpi = 0);
77 static Inkscape::Pixbuf *getBrokenImage(double width, double height);
78};
79
80/* Return duplicate of curve or NULL */
82void sp_embed_svg(Inkscape::XML::Node *image_node, std::string const &fn);
83
84#endif
SPAttr
Definition attributes.h:27
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis aligned, non-empty, generic rectangle.
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Sequence of subpaths.
Definition pathvector.h:122
Axis aligned, non-empty rectangle.
Definition rect.h:92
SVG drawing item for display.
Class to hold image data for raster images.
Definition cairo-utils.h:31
Storing of snapping preferences.
Represents an URI as per RFC 2396.
Definition uri.h:36
Interface for refcounted XML nodes.
Definition node.h:80
SVGLength height
SVGLength width
SVGLength x
Typed SVG document implementation.
Definition document.h:101
static Inkscape::Pixbuf * readImage(gchar const *href, gchar const *absref, gchar const *base, double svgdpi=0)
Definition sp-image.cpp:514
double prev_height
Definition sp-image.h:41
std::optional< Geom::PathVector > curve
Definition sp-image.h:43
double sy
Definition sp-image.h:38
Inkscape::DrawingItem * show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) override
Definition sp-image.cpp:505
double dpi
Definition sp-image.h:40
Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const override
Definition sp-image.cpp:412
static Inkscape::Pixbuf * getBrokenImage(double width, double height)
Load a standard broken image svg, used if we fail to load pixbufs from the href.
Definition sp-image.cpp:582
void release() override
Definition sp-image.cpp:138
double oy
Definition sp-image.h:39
const char * displayName() const override
The item's type name as a translated human string.
Definition sp-image.cpp:448
std::shared_ptr< Inkscape::Pixbuf const > pixbuf
Definition sp-image.h:48
double prev_width
Definition sp-image.h:41
char * color_profile
Definition sp-image.h:46
bool cropToArea(Geom::Rect area)
Crop the image (remove pixels) based on the area rectangle and translate image to componsate for move...
Definition sp-image.cpp:841
char * href
Definition sp-image.h:45
Geom::Rect clipbox
Definition sp-image.h:37
double sx
Definition sp-image.h:38
void print(SPPrintContext *ctx) override
Definition sp-image.cpp:423
void update(SPCtx *ctx, unsigned int flags) override
Definition sp-image.cpp:241
const char * typeName() const override
The item's type name, not node tag name.
Definition sp-image.cpp:444
void apply_profile(Inkscape::Pixbuf *pixbuf)
void modified(unsigned int flags) override
Definition sp-image.cpp:365
~SPImage() override
char * description() const override
Definition sp-image.cpp:460
Geom::Affine set_transform(Geom::Affine const &transform) override
Definition sp-image.cpp:658
double ox
Definition sp-image.h:39
void snappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs) const override
Definition sp-image.cpp:625
int tag() const override
Definition sp-image.h:35
bool missing
Definition sp-image.h:49
Geom::PathVector const * get_curve() const
Return a borrowed pointer to curve (if any exists) or NULL if there is no curve.
Definition sp-image.cpp:711
Inkscape::URI getURI() const
Return this image's href as a URI object.
Definition sp-image.cpp:455
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
Definition sp-image.cpp:376
void build(SPDocument *document, Inkscape::XML::Node *repr) override
Definition sp-image.cpp:122
void refresh_if_outdated()
Definition sp-image.cpp:813
Base class for visual SVG elements.
Definition sp-item.h:109
Geom::Affine transform
Definition sp-item.h:138
Inkscape::XML::Node * repr
Definition sp-object.h:193
SPDocument * document
Definition sp-object.h:188
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
PathVector - a sequence of subpaths.
void sp_embed_svg(Inkscape::XML::Node *image_node, std::string const &fn)
Definition sp-image.cpp:759
void sp_embed_image(Inkscape::XML::Node *imgnode, Inkscape::Pixbuf *pb)
Definition sp-image.cpp:716
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
Interface for XML documents.
Definition document.h:43
Unused.
Definition sp-object.h:94