Description This subroutine takes an array of ARNs and writes them out to image files with user-specified resolution, color palette and data range. The supported image formats are BMP, JPEG, GIF and TIFF.
Syntax ARNSaveToImage( arns(), height, width, rangeMin, rangeMax, palette, format, directory )
Parameters arns() As Long Input array of analysis result nodes whose data will be written to output image files.
height As Long Output image height in pixels. If height = width = 0, the output image will be "Auto" scaled. When custom height and width resolution is supplied, each ARN image will be written with the same custom resolution.
width As Long Output image width in pixels. If height = width = 0, the output image will be "Auto" scaled. When custom height and width resolution is supplied, each ARN image will be written with the same custom resolution.
rangeMin As Double Specifies a minimum data value below which the pixel color will be assigned the color at the low end of the color palette. If rangeMin = rangeMax = 0, the color scaling is "Auto".
rangeMax As Double Specifies a maximum data value above which the pixel color will be assigned the color at the high end of the color palette. If rangeMin = rangeMax = 0, the color scaling is "Auto".
palette As String Designates a color palette for the output image files. Options are:
format As String Designates the output file format as one of "bmp", "jpeg", "gif", or "tiff".
directory As String Output file directory path location where the image file(s) will be written.
Example The example below performs a raytrace and analysis inside of a loop to generate a number of Analysis Results Nodes. These ARNs are then added to an array which is passed into the ARNSaveToImage subroutine to write the ARN data out to image files with 1000x1000 pixel resolution and auto color scaling using the Spectrum2 color palette. The image files are written into the same file directory as the FRED document using the JPEG file format.
Sub Main
ARNDeleteAllNodes()
Dim src As Long, ana As Long src = FindFullName( "Optical Sources.Plane Wave Source" ) ana = FindFullName( "Analysis Surface(s).Focal Plane" )
'Source scan and analysis Dim curAng As Double, curArn As Long Dim parmString As String For curAng = 0 To 25 Step 5
'Set the Plane Wave type source primitive direction parmString = "0," & CStr(curAng) & ",SD" SourcePrimSetParmValue( src, 5, parmString )
'Raytrace and analyze DeleteRays() CreateSource( src ) TraceExisting() IrradianceToARN( ana, "Irradiance " & CStr(curAng), curArn )
Next
'Form an array of the ARNs being written to image files Dim arnList() As Long ReDim arnList(ARNGetMaxNodeNum()) For curArn = 0 To ARNGetMaxNodeNum() arnList(curArn) = curArn Next
'Write the ARNs out to image files in the current FRED document directory ARNSaveToImage( arnList(), 1000, 1000, 0, 0, "Spectrum2", "jpeg", GetDocDir() )
End Sub
See Also
|
|||||||||||||||||||||||||||||||||||||||||||