wxMaxima
Data Structures | Public Member Functions | Static Public Member Functions | Data Fields
Image Class Referencefinal

Manages an auto-scaling image. More...

#include <Image.h>

Data Structures

class  WxmxStream
 

Public Member Functions

 Image (Configuration *config)
 A constructor that generates an empty image. See LoadImage()
 
 Image (Configuration *config, const wxMemoryBuffer &image, const wxString &type)
 A constructor that loads the compressed file from a wxMemoryBuffer.
 
 Image (Configuration *config, const wxBitmap &bitmap)
 A constructor that loads a bitmap. More...
 
 Image (Configuration *config, const wxString &image, const wxString &wxmxFile, bool remove=true)
 A constructor that loads an image. More...
 
 Image (Configuration *config, const Image &image)
 
 Image (const Image &image)=delete
 
void SetConfiguration (Configuration *config)
 
int GetPPI () const
 Return the image's resolution.
 
void SetPPI (int ppi)
 Set the image's resolution.
 
void InvalidBitmap (const wxString &message=wxEmptyString)
 Creates a bitmap showing an error message.
 
void GnuplotSource (wxString gnuplotFilename, wxString dataFilename, const wxString &wxmxFile=wxEmptyString)
 Sets the name of the gnuplot source and data file of this image. More...
 
void CompressedGnuplotSource (wxString gnuplotFilename, wxString dataFilename, const wxString &wxmxFile=wxEmptyString)
 Loads the compressed gnuplot source and data file for this image.
 
wxString GnuplotSource ()
 Returns the gnuplot source file name of this image. More...
 
wxString GnuplotData ()
 Returns the gnuplot data file name of this image. More...
 
const wxMemoryBuffer GetGnuplotSource ()
 Returns the gnuplot source of this image.
 
const wxMemoryBuffer GetCompressedGnuplotSource ()
 
const wxMemoryBuffer GetGnuplotData ()
 Returns the gnuplot data of this image.
 
const wxMemoryBuffer GetCompressedGnuplotData ()
 
void ClearCache ()
 Temporarily forget the scaled image in order to save memory. More...
 
wxString GetExtension () const
 Returns the file name extension of the current image.
 
double GetMaxWidth () const
 The maximum width this image shall be displayed with.
 
double GetHeightList () const
 The maximum height this image shall be displayed with.
 
void SetMaxWidth (double width)
 Set the maximum width this image shall be displayed with.
 
void SetMaxHeight (double height)
 Set the maximum height this image shall be displayed with.
 
void LoadImage (const wxBitmap &bitmap)
 "Loads" an image from a bitmap
 
wxSize ToImageFile (wxString filename)
 Saves the image in its original form, or as .png if it originates in a bitmap.
 
wxBitmap GetBitmap (double scale=1.0)
 Returns the bitmap being displayed with custom scale.
 
wxBitmap GetUnscaledBitmap ()
 Returns the image in its unscaled form.
 
void Recalculate (double scale=1.0)
 Can be called to specify a specific scale.
 
const wxMemoryBuffer GetCompressedImage () const
 Returns the original image in its compressed form.
 
std::size_t GetOriginalWidth () const
 Returns the original width.
 
std::size_t GetOriginalHeight () const
 Returns the original height.
 
bool CanExportSVG () const
 Can this image be exported in SVG format?
 
bool HasGnuplotSource () const
 

Static Public Member Functions

static wxBitmap RGBA2wxBitmap (const unsigned char imgdata[], const int &width, const int &height, const int &scaleFactor=1)
 Converts rgba data to a wxBitmap.
 
static const wxString GetBadImageToolTip ()
 The tooltip to use wherever an image that's not Ok is shown.
 

Data Fields

long m_width = 1
 The width of the scaled image.
 
long m_height = 1
 The height of the scaled image.
 
wxMemoryBuffer m_compressedImage
 The image in its original compressed form.
 

Detailed Description

Manages an auto-scaling image.

This class keeps two versions of an image:

Storing images this way has many advantages:

Constructor & Destructor Documentation

◆ Image() [1/2]

Image::Image ( Configuration config,
const wxBitmap &  bitmap 
)

A constructor that loads a bitmap.

This constructor actually has to do some compression since we got the bitmap in an uncompressed form.

◆ Image() [2/2]

Image::Image ( Configuration config,
const wxString &  image,
const wxString &  wxmxFile,
bool  remove = true 
)

A constructor that loads an image.

Parameters
configThe pointer to the current configuration storage for the worksheet
imageThe name of the file
wxmxFileThe wxmx file to load it from. Empty when loading from a standalone file from the filesystem.
removetrue = Delete the file after loading it

Member Function Documentation

◆ ClearCache()

void Image::ClearCache ( )
inline

Temporarily forget the scaled image in order to save memory.

Will recreate the scaled image as soon as needed.

◆ GnuplotData()

wxString Image::GnuplotData ( )

Returns the gnuplot data file name of this image.

If maxima has deleted the temporary file in the meantime or if it comes from a .wxmx file and has never been created from maxima the file is created by this function.

If the file cannot be created (for example if no gnuplot source exists/ is known) this function returns wxEmptyString.

◆ GnuplotSource() [1/2]

wxString Image::GnuplotSource ( )

Returns the gnuplot source file name of this image.

If maxima has deleted the temporary file in the meantime or if it comes from a .wxmx file and has never been created from maxima the file is created by this function.

If the file cannot be created (for example if no gnuplot source exists/ is known) this function returns wxEmptyString.

◆ GnuplotSource() [2/2]

void Image::GnuplotSource ( wxString  gnuplotFilename,
wxString  dataFilename,
const wxString &  wxmxFile = wxEmptyString 
)

Sets the name of the gnuplot source and data file of this image.

Causes the files to be cached if they are not way too long; As the files are text-only they profit from being compressed and are stored in the memory in their compressed form.


The documentation for this class was generated from the following files: