[ Prev | Index | Next ]
Japanese English

Exporting to Image Files

Once you've drawn to a graphics resource, it needs to be output to either the display or a file in order to be useful. This section explains how to export the graphics to an image file.

Exporting a Graphics Resource to an Image File

In addition to displaying a graphics resource on the screen, you can also export it to an image file using the "exportGraphics" function from the Graphics library. Supported formats include BMP, PNG, and JPEG.

- Function Format -
void exportGraphics( int graphicsID, string fileName, string format )

Arguments:

  • graphicsID: The ID of the graphics resource you want to export.
  • fileName: The name of the output file.
  • format: The file format -- choose one of "BMP", "PNG", or "JPEG".

If you're exporting to JPEG format, you can optionally specify image quality by adding an additional argument at the end:

- Function Format -
void exportGraphics(
  int graphicsID, string fileName, string format, float quality
)

The "quality" parameter can be set in the range from 0.0 (lowest quality) to 1.0 (highest quality). You can also specify a value up to 100.0, in which case it will be interpreted as a percentage.

Example Program

Let's try generating a window and exporting the graphics resource. Write and run the following program:


import Graphics;
import Graphics2D;
import GUI;

// Create a graphics resource
int graphicsID = newGraphics( );

// Create a renderer
int rendererID = newGraphics2DRenderer( 800, 600, graphicsID );

// Export the graphics resource to a PNG file
exportGraphics( graphicsID, "Test.png", "PNG" );
Sample.vcssl

This program won't show anything on the screen, so after launching it, wait a few seconds and then close the console window.

You should find a file named Test.png in the same folder as the program. Since we didn't draw anything, the image will be completely blank (transparent).


Author of This Article

Fumihiro Matsui
[ Founder of RINEARN, Doctor of Science (Physics), Applied Info Tech Engineer ]
Develops VCSSL, RINEARN Graph 3D and more. Also writes guides and articles.

Translation Cooperator

ChatGPT AIs
[ GPT-3.5, 4, 5, 5.1 ]
We greatly appreciate the cooperation of ChatGPT AIs in translating this article.


Sponsored Link



Japanese English
Index
News From RINEARN
* VCSSL is developed by RINEARN.

Exevalatorv2.4Released—MCPSupportAdded,NowUsableasanAICalculationTool
2025-11-15 - We'vereleasedExevalatorv2.4,ourexpression-evaluationlibrary.Startingwiththisversion,itsupportsMCP,makingitusableasacalculationtoolforAIassistants.

Exevalatorv2.3Released—NowUsablefromPython
2025-11-04 - We'vereleasedExevalatorv2.3.Startingwiththisversion,youcannowuseitfromPython!WithgrowingdemandaroundAItooldevelopmentinmind,wesharethedetailshere.

ExevalatorUpdated—EasyJapaneseLocalizationforErrorMessages
2025-10-31 - Exevalator2.2.2isout.YoucannowlocalizeerrormessagestoJapanesewithasimplecopy-and-paste,andwe'veincludedseveralbugfixesandminorparseradjustments.

InsideRINPnOnline:ArchitectureOverview
2025-10-22 - AninsidelookatthearchitectureoftherecentlylaunchedonlineversionoftheRINPnscientificcalculator.It'sopensource,soyoucanfreelymodifyandreuseittobuildyourownwebcalculator(maybe!).

MeetRINPnOnline:UsetheScientificCalculatorAnywhere,Instantly
2025-10-21 - RINPn,thefreescientificcalculator,nowhasanonlineversionyoucanuseinstantlyinyourbrowser—onbothPCandsmartphones.Readtheannouncementfordetails.

TheVCSSLSupportAIisHere!—RequiresaChatGPTPlusAccountforPracticalPerformance
2025-08-19 - AnewAIassistantfortheVCSSLprogramminglanguageisheretoansweryourquestionsandhelpwithcoding.ThisarticleexplainshowtouseitandshowcasesplentyofrealQ&Aandgeneratedcodeexamples.

EnglishDocumentationforOurSoftwareandVCSSLIsNowNearlyComplete
2025-06-30 - We'rehappytoannouncethatthelarge-scaleexpansionofourEnglishdocumentationwiththesupportofAI—aprojectthatbegantwoyearsago—hasnowreacheditsinitialtargetmilestone.

VCSSL3.4.52Released:EnhancedIntegrationwithExternalProgramsandMore
2025-05-25 - Thisupdateintroducesenhancementstotheexternalprogramintegrationfeatures(e.g.,forrunningC-languageexecutables).Severalotherimprovementsandfixesarealsoincluded.Detailsinside.