38#include "Configuration.h"
41#include <wx/zipstrm.h>
42#include <wx/wfstream.h>
43#define NANOSVG_ALL_COLOR_KEYWORDS
44#include "nanosvg_private.h"
45#include "nanosvgrast_private.h"
96 const wxString &wxmxFile,
bool remove =
true);
105 const int &width,
const int &height);
108 if(m_loadImageTask.joinable())
109 m_loadImageTask.join();
110 m_configuration = config; }
113 if(m_loadImageTask.joinable())
114 m_loadImageTask.join();
118 if(m_loadImageTask.joinable())
119 m_loadImageTask.join();
124 void GenerateInvalidBitmap();
126 wxString m_invalidBitmapMessage;
127 bool m_isInvalid =
false;
135 void GnuplotSource(wxString gnuplotFilename, wxString dataFilename,
136 const wxString &wxmxFile = wxEmptyString);
142 const wxString &wxmxFile = wxEmptyString);
167 const wxMemoryBuffer GetCompressedGnuplotSource();
170 const wxMemoryBuffer GetCompressedGnuplotData();
178 if(m_loadImageTask.joinable())
179 m_loadImageTask.join();
180 if ((m_scaledBitmap.GetWidth() > 1) || (m_scaledBitmap.GetHeight() > 1))
181 m_scaledBitmap.Create(1, 1);
188 if(m_loadImageTask.joinable())
189 m_loadImageTask.join();
193 if(m_loadImageTask.joinable())
194 m_loadImageTask.join();
198 if(m_loadImageTask.joinable())
199 m_loadImageTask.join();
204 if(m_loadImageTask.joinable())
205 m_loadImageTask.join();
206 m_maxHeight = height;
245 if(m_loadImageTask.joinable())
246 m_loadImageTask.join();
247 return m_svgRast !=
nullptr;}
258 WxmxStream(wxInputStream &wxmxFile,
const wxString &fileInWxmx);
261 bool HasGnuplotSource()
const {
return m_gnuplotSource_Compressed.GetDataLen() > 20;}
263 bool m_fromWxFS =
false;
265 wxMemoryBuffer m_gnuplotSource_Compressed;
267 wxMemoryBuffer m_gnuplotData_Compressed;
269 std::size_t m_originalWidth = 640;
271 std::size_t m_originalHeight = 480;
273 wxBitmap m_scaledBitmap;
275 wxString m_extension;
277 wxString m_gnuplotSource;
279 wxString m_gnuplotData;
280 mutable jthread m_loadImageTask;
281 void LoadImage_Backgroundtask(stop_token stopToken,
282 std::unique_ptr<ThreadNumberLimiter> limiter,
283 wxString image, wxString wxmxFile,
285 jthread m_loadGnuplotSourceTask;
286 void LoadGnuplotSource_Backgroundtask(
287 stop_token stopToken,
288 std::unique_ptr<ThreadNumberLimiter> limiter,
289 wxString gnuplotFile, wxString dataFile, wxString wxmxFile);
290 void LoadGnuplotSource(wxInputStream *source);
291 void LoadGnuplotData(wxInputStream *data);
292 void LoadGnuplotSource_Backgroundtask_internal(
293 wxInputStream *source,
294 wxInputStream *data);
297 void LoadCompressedGnuplotSource_Backgroundtask(stop_token stopToken,
298 std::unique_ptr<ThreadNumberLimiter> limiter,
304 void LoadImage(wxString image,
const wxString &wxmxFile,
bool remove =
true);
306 wxMemoryBuffer ReadCompressedImage(stop_token stopToken, wxInputStream *data);
310 wxCoord m_maxWidth = -1;
312 wxCoord m_maxHeight = -1;
314 wxString m_imageName;
317 struct free_deleter {
void operator()(
void *p)
const { std::free(p); } };
318 wxm_NSVGimage* m_svgImage = {};
319 std::unique_ptr<struct wxm_NSVGrasterizer, free_deleter> m_svgRast{
nullptr};
A mutex that locks if we have too many background threads.
The configuration storage for the current worksheet.
Definition: Configuration.h:86
Manages an auto-scaling image.
Definition: Image.h:72
void SetMaxWidth(double width)
Set the maximum width this image shall be displayed with.
Definition: Image.h:197
double GetHeightList() const
The maximum height this image shall be displayed with.
Definition: Image.h:192
void LoadImage(const wxBitmap &bitmap)
"Loads" an image from a bitmap
Definition: Image.cpp:793
void Recalculate(double scale=1.0)
Can be called to specify a specific scale.
Definition: Image.cpp:978
int GetPPI() const
Return the image's resolution.
Definition: Image.h:112
wxString GnuplotSource()
Returns the gnuplot source file name of this image.
Definition: Image.cpp:559
const wxMemoryBuffer GetGnuplotSource()
Returns the gnuplot source of this image.
Definition: Image.cpp:449
std::size_t GetOriginalWidth() const
Returns the original width.
Definition: Image.cpp:216
std::size_t GetOriginalHeight() const
Returns the original height.
Definition: Image.cpp:223
static const wxString GetBadImageToolTip()
The tooltip to use wherever an image that's not Ok is shown.
Definition: Image.cpp:1072
long m_height
The height of the scaled image.
Definition: Image.h:227
const wxMemoryBuffer GetGnuplotData()
Returns the gnuplot data of this image.
Definition: Image.cpp:494
long m_width
The width of the scaled image.
Definition: Image.h:225
wxString GetExtension() const
Returns the file name extension of the current image.
Definition: Image.cpp:812
void InvalidBitmap(const wxString &message=wxEmptyString)
Creates a bitmap showing an error message.
Definition: Image.cpp:731
static wxBitmap RGBA2wxBitmap(const unsigned char imgdata[], const int &width, const int &height)
Converts rgba data to a wxBitmap.
Definition: Image.cpp:1082
const wxMemoryBuffer GetCompressedImage() const
Returns the original image in its compressed form.
Definition: Image.cpp:210
bool CanExportSVG() const
Can this image be exported in SVG format?
Definition: Image.h:244
static bool IsSafePath(const wxString &path)
Returns true if the path is in a safe (temporary) directory for deletion.
Definition: Image.cpp:1053
void SetPPI(int ppi)
Set the image's resolution.
Definition: Image.h:117
wxMemoryBuffer m_compressedImage
The image in its original compressed form.
Definition: Image.h:241
void SetMaxHeight(double height)
Set the maximum height this image shall be displayed with.
Definition: Image.h:203
wxSize ToImageFile(wxString filename)
Saves the image in its original form, or as .png if it originates in a bitmap.
Definition: Image.cpp:600
double GetMaxWidth() const
The maximum width this image shall be displayed with.
Definition: Image.h:187
wxBitmap GetBitmap(double scale=1.0)
Returns the bitmap being displayed with custom scale.
Definition: Image.cpp:670
wxString GnuplotData()
Returns the gnuplot data file name of this image.
Definition: Image.cpp:524
wxBitmap GetUnscaledBitmap()
Returns the image in its unscaled form.
Definition: Image.cpp:186
void CompressedGnuplotSource(wxString gnuplotFilename, wxString dataFilename, const wxString &wxmxFile=wxEmptyString)
Loads the compressed gnuplot source and data file for this image.
Definition: Image.cpp:289
void ClearCache()
Temporarily forget the scaled image in order to save memory.
Definition: Image.h:176