summaryrefslogtreecommitdiff
path: root/src/player/SVG.h
blob: 73f0d5516b2009d8342fc6a22d055434c8b694c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
//  libavg - Media Playback Engine. 
//  Copyright (C) 2003-2014 Ulrich von Zadow
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
//  Current versions can be found at www.libavg.de
//

#ifndef _SVG_H_
#define _SVG_H_

#include "WrapPython.h"

#include "../api.h"

#include "../base/UTF8String.h"
#include "../graphics/Bitmap.h"
#include "BoostPython.h"
#include "SVGElement.h"

#include <librsvg/rsvg.h>
#include <boost/shared_ptr.hpp>

#include <string>

namespace avg {

class Node;
typedef boost::shared_ptr<Node> NodePtr;

class SVG
{
public:
    SVG(const UTF8String& sFilename, bool bUnescapeIllustratorIDs=false);
    virtual ~SVG();

    BitmapPtr renderElement(const UTF8String& sElementID);
    BitmapPtr renderElement(const UTF8String& sElementID, const glm::vec2& size);
    BitmapPtr renderElement(const UTF8String& sElementID, float scale);
    NodePtr createImageNode(const UTF8String& sElementID,
            const py::dict& nodeAttrs);
    NodePtr createImageNode(const UTF8String& sElementID,
            const py::dict& nodeAttrs, const glm::vec2& renderSize);
    NodePtr createImageNode(const UTF8String& sElementID,
            const py::dict& nodeAttrs, float scale);
    glm::vec2 getElementPos(const UTF8String& sElementID);
    glm::vec2 getElementSize(const UTF8String& sElementID);

private:
    BitmapPtr internalRenderElement(const SVGElementPtr& pElement, 
        const glm::vec2& renderSize, const glm::vec2& size);
    NodePtr createImageNodeFromBitmap(BitmapPtr pBmp, 
            const py::dict& nodeAttrs);
    SVGElementPtr getElement(const UTF8String& sElementID);

    std::map<UTF8String, SVGElementPtr> m_ElementMap;
    UTF8String m_sFilename;
    bool m_bUnescapeIllustratorIDs;
    RsvgHandle* m_pRSVG;
};

}

#endif