wxMaxima
Loading...
Searching...
No Matches
SvgBitmap.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2019 Gunter Königsmann <wxMaxima@physikbuch.de>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
28#ifndef SVGBITMAP_H
29#define SVGBITMAP_H
30
31#include <memory>
32#include "precomp.h"
33#include <wx/bitmap.h>
34#include "nanosvg_private.h"
35#include "nanosvgrast_private.h"
36#include "cells/Cell.h"
37#define NANOSVG_ALL_COLOR_KEYWORDS
38
41class SvgBitmap: public wxBitmap
42{
43public:
45 SvgBitmap(wxWindow *window, const unsigned char *data, const size_t len, int width = 640, int height = 480);
46 SvgBitmap(wxWindow *window, const unsigned char *data, const std::size_t len, wxSize siz);
47 SvgBitmap(wxWindow *window, const wxString &data, wxSize siz);
48 virtual ~SvgBitmap() override;
49 SvgBitmap(SvgBitmap &&) = delete;
50 SvgBitmap &operator=(SvgBitmap &&o) noexcept;
51
53 const SvgBitmap& SetSize(int width, int height);
55 const SvgBitmap& SetSize(wxSize siz){return SetSize(siz.x, siz.y);}
57 wxSize GetOriginalSize() const
58 { return m_svgImage ? wxSize(m_svgImage->width, m_svgImage->height) : wxDefaultSize; }
60 wxBitmap GetInvalidBitmap(int targetSize);
61private:
63 static struct wxm_NSVGrasterizer* m_svgRast;
65 std::unique_ptr<wxm_NSVGimage, decltype(std::free)*> m_svgImage{nullptr, std::free};
67 wxWindow *m_window = NULL;
68};
69
70#endif // SVGBITMAP_H
The definition of the base class of all cells the worksheet consists of.
A wxBitmap with a constructor that generates the image from SVG.
Definition: SvgBitmap.h:42
wxBitmap GetInvalidBitmap(int targetSize)
An "invalid bitmap" sign.
Definition: SvgBitmap.cpp:143
const SvgBitmap & SetSize(wxSize siz)
Sets the bitmap to a new size and renders the svg image at this size.
Definition: SvgBitmap.h:55
wxSize GetOriginalSize() const
Gets the original size of the svg image.
Definition: SvgBitmap.h:57
SvgBitmap(wxWindow *window, const unsigned char *data, const size_t len, int width=640, int height=480)
A constructor that loads the data into a wxBitmap.
const SvgBitmap & SetSize(int width, int height)
Sets the bitmap to a new size and renders the svg image at this size.
Definition: SvgBitmap.cpp:82