Skip to main content

I’m using the ZOS-API (ver. 2024 R1) with C# and creating an Open3DViewerExport (I3DViewerExport) bitmap of the Ray Trace.

The bitmap gets generated to a file but includes the axis (X,Y,Z) in the lower left corner of the image.


The application allows to turn this access off but I don’t see the option within the API.

 

Is there anyway that the API can turn this off as well?

Thanks.

B.

Hi Brian,

I don’t believe there is a way to turn this off via the API (most of the API focuses on changing the actual optical system, not on visualization).  Although this might not work in all cases, I would simply copy a rectangle from the bottom right of the saved image and paste it over the bottom left to cover up the orientation indicator.  

static void RemoveOrientationIndicator(string filename, int width = 100, int height = 100, int left = 10, int bottom = 10)
{
string output = Path.GetFileNameWithoutExtension(filename) + "_cleaned" + Path.GetExtension(filename);
output = Path.Combine(Path.GetDirectoryName(filename), output);

using (Bitmap bmp = new Bitmap(filename))
{
using (Graphics g = Graphics.FromImage(bmp))
{
// get the left and right coordinates for the 2 rectangles
int rightX = bmp.Width - width - left;
int rightY = bmp.Height - height - bottom;
int leftX = left;
int leftY = bmp.Height - height - bottom;

// get the left and right rectangles
var rightRect = new Rectangle(rightX, rightY, width, height);
var leftRect = new Rectangle(leftX, leftY, width, height);

// copy & paste from the right side to the left side to hide the indicator
g.DrawImage(bmp, leftRect, rightRect, GraphicsUnit.Pixel);
}

// Save the modified image
bmp.Save(output);
}
}

Simply call this function after you have saved the layout via the RunAndWaitForCompletion:

var tool = TheSystem.Tools.Layouts;
var layout = tool.OpenShadedModelExport();
layout.SaveImageAsFile = true;
layout.OutputFileName = bmpOutputName;
layout.RunAndWaitForCompletion();
layout.Close();

RemoveOrientationIndicator(layout.OutputFileName);

I get the following for a before and after (this work for both the white background of Open3DViewerExport and the gradient background of OpenShadedModelExport):

 


Hi Michael,
 

I think your right. The API is going to provide minimal “customizations” for something that I want.
 

I’m going to give your suggestion a try.

 

Thanks.

B.


Reply