37#include "Configuration.h"
40#include <wx/zipstrm.h>
41#include <wx/wfstream.h>
42#define NANOSVG_ALL_COLOR_KEYWORDS
43#include "nanosvg_private.h"
44#include "nanosvgrast_private.h"
95 const wxString &wxmxFile,
bool remove =
true);
104 const int &width,
const int &height);
107 if(m_loadImageTask.joinable())
108 m_loadImageTask.join();
109 m_configuration = config; }
112 if(m_loadImageTask.joinable())
113 m_loadImageTask.join();
117 if(m_loadImageTask.joinable())
118 m_loadImageTask.join();
130 void GnuplotSource(wxString gnuplotFilename, wxString dataFilename,
131 const wxString &wxmxFile = wxEmptyString);
137 const wxString &wxmxFile = wxEmptyString);
162 const wxMemoryBuffer GetCompressedGnuplotSource();
165 const wxMemoryBuffer GetCompressedGnuplotData();
173 if(m_loadImageTask.joinable())
174 m_loadImageTask.join();
175 if ((m_scaledBitmap.GetWidth() > 1) || (m_scaledBitmap.GetHeight() > 1))
176 m_scaledBitmap.Create(1, 1);
183 if(m_loadImageTask.joinable())
184 m_loadImageTask.join();
188 if(m_loadImageTask.joinable())
189 m_loadImageTask.join();
193 if(m_loadImageTask.joinable())
194 m_loadImageTask.join();
199 if(m_loadImageTask.joinable())
200 m_loadImageTask.join();
201 m_maxHeight = height;
240 if(m_loadImageTask.joinable())
241 m_loadImageTask.join();
242 return m_svgRast !=
nullptr;}
250 WxmxStream(wxInputStream &wxmxFile,
const wxString &fileInWxmx);
253 bool HasGnuplotSource()
const {
return m_gnuplotSource_Compressed.GetDataLen() > 20;}
255 bool m_fromWxFS =
false;
257 wxMemoryBuffer m_gnuplotSource_Compressed;
259 wxMemoryBuffer m_gnuplotData_Compressed;
261 std::size_t m_originalWidth = 640;
263 std::size_t m_originalHeight = 480;
265 wxBitmap m_scaledBitmap;
267 wxString m_extension;
269 wxString m_gnuplotSource;
271 wxString m_gnuplotData;
272 mutable jthread m_loadImageTask;
273 void LoadImage_Backgroundtask(std::unique_ptr<ThreadNumberLimiter> limiter,
274 wxString image, wxString wxmxFile,
276 jthread m_loadGnuplotSourceTask;
277 void LoadGnuplotSource_Backgroundtask(
278 std::unique_ptr<ThreadNumberLimiter> limiter,
279 wxString gnuplotFile, wxString dataFile, wxString wxmxFile);
280 void LoadGnuplotSource(wxInputStream *source);
281 void LoadGnuplotData(wxInputStream *data);
282 void LoadGnuplotSource_Backgroundtask_internal(
283 wxInputStream *source,
284 wxInputStream *data);
287 void LoadCompressedGnuplotSource_Backgroundtask(std::unique_ptr<ThreadNumberLimiter> limiter,
293 void LoadImage(wxString image,
const wxString &wxmxFile,
bool remove =
true);
295 static wxMemoryBuffer ReadCompressedImage(wxInputStream *data);
299 wxCoord m_maxWidth = -1;
301 wxCoord m_maxHeight = -1;
303 wxString m_imageName;
306 struct free_deleter {
void operator()(
void *p)
const { std::free(p); } };
307 wxm_NSVGimage* m_svgImage = {};
308 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:84
Manages an auto-scaling image.
Definition: Image.h:71
void SetMaxWidth(double width)
Set the maximum width this image shall be displayed with.
Definition: Image.h:192
double GetHeightList() const
The maximum height this image shall be displayed with.
Definition: Image.h:187
void LoadImage(const wxBitmap &bitmap)
"Loads" an image from a bitmap
Definition: Image.cpp:732
void Recalculate(double scale=1.0)
Can be called to specify a specific scale.
Definition: Image.cpp:909
int GetPPI() const
Return the image's resolution.
Definition: Image.h:111
wxString GnuplotSource()
Returns the gnuplot source file name of this image.
Definition: Image.cpp:511
const wxMemoryBuffer GetGnuplotSource()
Returns the gnuplot source of this image.
Definition: Image.cpp:401
std::size_t GetOriginalWidth() const
Returns the original width.
Definition: Image.cpp:184
std::size_t GetOriginalHeight() const
Returns the original height.
Definition: Image.cpp:191
static const wxString GetBadImageToolTip()
The tooltip to use wherever an image that's not Ok is shown.
Definition: Image.cpp:982
long m_height
The height of the scaled image.
Definition: Image.h:222
const wxMemoryBuffer GetGnuplotData()
Returns the gnuplot data of this image.
Definition: Image.cpp:446
long m_width
The width of the scaled image.
Definition: Image.h:220
wxString GetExtension() const
Returns the file name extension of the current image.
Definition: Image.cpp:751
void InvalidBitmap(const wxString &message=wxEmptyString)
Creates a bitmap showing an error message.
Definition: Image.cpp:680
static wxBitmap RGBA2wxBitmap(const unsigned char imgdata[], const int &width, const int &height)
Converts rgba data to a wxBitmap.
Definition: Image.cpp:992
const wxMemoryBuffer GetCompressedImage() const
Returns the original image in its compressed form.
Definition: Image.cpp:178
bool CanExportSVG() const
Can this image be exported in SVG format?
Definition: Image.h:239
void SetPPI(int ppi)
Set the image's resolution.
Definition: Image.h:116
wxMemoryBuffer m_compressedImage
The image in its original compressed form.
Definition: Image.h:236
void SetMaxHeight(double height)
Set the maximum height this image shall be displayed with.
Definition: Image.h:198
wxSize ToImageFile(wxString filename)
Saves the image in its original form, or as .png if it originates in a bitmap.
Definition: Image.cpp:552
double GetMaxWidth() const
The maximum width this image shall be displayed with.
Definition: Image.h:182
wxBitmap GetBitmap(double scale=1.0)
Returns the bitmap being displayed with custom scale.
Definition: Image.cpp:622
wxString GnuplotData()
Returns the gnuplot data file name of this image.
Definition: Image.cpp:476
wxBitmap GetUnscaledBitmap()
Returns the image in its unscaled form.
Definition: Image.cpp:157
void CompressedGnuplotSource(wxString gnuplotFilename, wxString dataFilename, const wxString &wxmxFile=wxEmptyString)
Loads the compressed gnuplot source and data file for this image.
Definition: Image.cpp:247
void ClearCache()
Temporarily forget the scaled image in order to save memory.
Definition: Image.h:171