5.5.1 Export to file

These functions export current view to a graphic file. The filename fname should have appropriate extension. Parameter descr gives the short description of the picture. Just now the transparency is supported in PNG, SVG, OBJ and PRC files.

MGL command: write ['fname'='']
Method on mglGraph: void WriteFrame (const char *fname="", const char *descr="")
C function: void mgl_write_frame (HMGL gr, const char *fname, const char *descr)

Exports current frame to a file fname which type is determined by the extension. Parameter descr adds description to file (can be ""). If fname="" then the file ‘frame####.jpg’ is used, where ‘####’ is current frame id and name ‘frame’ is defined by plotid class property.

MGL command: bbox x1 y1 [x2=-1 y2=-1]
Method on mglGraph: void SetBBox (int x1=0, int y1=0, int x2=-1, int y2=-1)
C function: void mgl_set_bbox (HMGL gr, int x1, int y1, int x2, int y2)

Set boundary box for export graphics into 2D file formats. If x2<0 (y2<0) then original image width (height) will be used. If x1<0 or y1<0 or x1>=x2|Width or y1>=y2|Height then cropping will be disabled.

Method on mglGraph: void WritePNG (const char *fname, const char *descr="", int compr="", bool alpha=true)
C function: void mgl_write_png (HMGL gr, const char *fname, const char *descr)
C function: void mgl_write_png_solid (HMGL gr, const char *fname, const char *descr)

Exports current frame to PNG file. Parameter fname specifies the file name, descr adds description to file, alpha gives the transparency type. By default there are no description added and semitransparent image used. This function does nothing if HAVE_PNG isn’t defined during compilation of MathGL library.

Method on mglGraph: void WriteJPEG (const char *fname, const char *descr="")
C function: void mgl_write_jpg (HMGL gr, const char *fname, const char *descr)

Exports current frame to JPEG file. Parameter fname specifies the file name, descr adds description to file. By default there is no description added. This function does nothing if HAVE_JPEG isn’t defined during compilation of MathGL library.

Method on mglGraph: void WriteGIF (const char *fname, const char *descr="")
C function: void mgl_write_gif (HMGL gr, const char *fname, const char *descr)

Exports current frame to GIF file. Parameter fname specifies the file name, descr adds description to file. By default there is no description added. This function does nothing if HAVE_GIF isn’t defined during compilation of MathGL library.

Method on mglGraph: void WriteBMP (const char *fname, const char *descr="")
C function: void mgl_write_bmp (HMGL gr, const char *fname, const char *descr)

Exports current frame to BMP file. Parameter fname specifies the file name, descr adds description to file. There is no compression used.

Method on mglGraph: void WriteTGA (const char *fname, const char *descr="")
C function: void mgl_write_tga (HMGL gr, const char *fname, const char *descr)

Exports current frame to TGA file. Parameter fname specifies the file name, descr adds description to file. There is no compression used.

Method on mglGraph: void WriteEPS (const char *fname, const char *descr="")
C function: void mgl_write_eps (HMGL gr, const char *fname, const char *descr)

Exports current frame to EPS file using vector representation. So it is not recommended for the export of large data plot. It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file. By default there is no description added. If file name is terminated by ‘z’ (for example, ‘fname.eps.gz’) then file will be compressed in gzip format. Note, that EPS format don’t support color interpolation, and the resulting plot will look as you use quality=1 for plotting.

Method on mglGraph: void WriteBPS (const char *fname, const char *descr="")
C function: void mgl_write_eps (HMGL gr, const char *fname, const char *descr)

Exports current frame to EPS file using bitmap representation. Parameter fname specifies the file name, descr adds description to file. By default there is no description added. If file name is terminated by ‘z’ (for example, ‘fname.eps.gz’) then file will be compressed in gzip format.

Method on mglGraph: void WriteSVG (const char *fname, const char *descr="")
C function: void mgl_write_svg (HMGL gr, const char *fname, const char *descr)

Exports current frame to SVG (Scalable Vector Graphics) file using vector representation. In difference of EPS format, SVG format support transparency that allows one to correctly draw semitransparent plot (like surfa, surf3a or cloud). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name). If file name is terminated by ‘z’ (for example, ‘fname.svgz’) then file will be compressed in gzip format. Note, that SVG format don’t support color interpolation, and the resulting plot will look as you use quality=1 for plotting.

Method on mglGraph: void WriteTEX (const char *fname, const char *descr="")
C function: void mgl_write_tex (HMGL gr, const char *fname, const char *descr)

Exports current frame to LaTeX (package Tikz/PGF) file using vector representation. Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name). Note, there is no text scaling now (for example, in subplots), what may produce miss-aligned labels.

Method on mglGraph: void WritePRC (const char *fname, const char *descr="", bool make_pdf=true)
C function: void mgl_write_prc (HMGL gr, const char *fname, const char *descr, int make_pdf)

Exports current frame to PRC file using vector representation (see http://en.wikipedia.org/wiki/PRC_%28file_format%29). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name). If parameter make_pdf=true and PDF was enabled at MathGL configure then corresponding PDF file with 3D image will be created.

Method on mglGraph: void WriteOBJ (const char *fname, const char *descr="")
C function: void mgl_write_obj (HMGL gr, const char *fname, const char *descr)

Exports current frame to OBJ/MTL file using vector representation (see OBJ format for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name).

Method on mglGraph: void WriteXYZ (const char *fname, const char *descr="")
C function: void mgl_write_xyz (HMGL gr, const char *fname, const char *descr)

Exports current frame to XYZ/XYZL/XYZF files using vector representation (see XYZ format for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name).

Method on mglGraph: void WriteSTL (const char *fname, const char *descr="")
C function: void mgl_write_stl (HMGL gr, const char *fname, const char *descr)

Exports current frame to STL file using vector representation (see STL format for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name.

Method on mglGraph: void WriteOFF (const char *fname, const char *descr="", bool colored=false)
C function: void mgl_write_off (HMGL gr, const char *fname, const char *descr, bool colored)

Exports current frame to OFF file using vector representation (see OFF format for details). Note, the output file may be too large for graphic of large data array (especially for surfaces). It is better to use bitmap format (for example PNG or JPEG). However, program has no internal limitations for size of output file. Parameter fname specifies the file name, descr adds description to file (default is file name).

Method on mglGraph: void ShowImage (const char *viewer, bool nowait=false)
C function: void mgl_show_image (const char *viewer, int nowait)

Displays the current picture using external program viewer for viewing. The function save the picture to temporary file and call viewer to display it. If nowait=true then the function return immediately (it will not wait while window will be closed).

Method on mglGraph: void WriteJSON (const char *fname, const char *descr="")
C function: void mgl_write_json (HMGL gr, const char *fname, const char *descr)

Exports current frame to textual file using JSON format. Later this file can be used for faster loading and viewing by JavaScript script. Parameter fname specifies the file name, descr adds description to file.

Method on mglGraph: void ExportMGLD (const char *fname, const char *descr="")
C function: void mgl_export_mgld (HMGL gr, const char *fname, const char *descr)

Exports points and primitives in file using MGLD format. Later this file can be used for faster loading and viewing by mglview utility. Parameter fname specifies the file name, descr adds description to file (default is file name).

Method on mglGraph: void ImportMGLD (const char *fname, bool add=false)
C function: void mgl_import_mgld (HMGL gr, const char *fname, int add)

Imports points and primitives in file using MGLD format. Later this file can be used for faster loading and viewing by mglview utility. Parameter fname specifies the file name, add sets to append or replace primitives to existed ones.