STL – also known as “Standard Triangle Language” or “Standard Tessellation Language” – is the native file format for stereolithography CAD software. STL files store only the surface geometry of a 3‑D object, without color, texture, or other attributes. To view an STL file you typically need applications such as Microsoft 3D Viewer, Microsoft Print 3D, IMSI TurboCAD Pro, or GOM Inspect. Many of these tools require a license, and viewing STL files on mobile devices can be cumbersome. Converting STL to a raster image format like BMP provides a quick, universally viewable solution. Below we explain how to perform STL to BMP conversion in C# using a REST API.

CAD Files Processing API

Aspose.CAD Cloud offers a REST‑based API that can scale, rotate, flip, edit CAD drawings, or export AutoCAD files to popular image formats (BMP, PNG, JPG) and fixed‑layout PDFs (vector or raster). See the full list of supported formats at supported file formats. Because the API follows REST principles, it can be integrated into desktop, mobile, web, or cloud applications.

To simplify development, Aspose provides language‑specific SDKs. This article focuses on the Aspose.CAD Cloud SDK for .NET. Before using the SDK, install it as described in How to install Aspose.Cloud SDKs.

STL to BMP in C#

Follow these steps to convert an STL file stored in the cloud and save the resulting BMP back to cloud storage. The PostDrawingBmp operation performs the conversion.

  • Create a File.Create instance with your ClientId and ClientSecret.
  • Instantiate a BmpOptionsDTO object to specify conversion settings such as image size or compression.
  • Build a PostDrawingBmpRequest with the input STL filename and the BmpOptionsDTO.
  • Call PostDrawingBmp(…) to start the conversion.
  • Write the returned Stream to a file using the File.Create object.

Download the sample STL and the expected BMP output from galeon.stl and converted.bmp.

Convert STL to BMP using cURL

Because the API is RESTful, you can invoke it with cURL on any platform. First, generate a JWT access token using your ClientId and ClientSecret from the Aspose.Cloud dashboard.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=4ccf1790-accc-41e9-8d18-a78dbb2ed1aa&client_secret=caac6e3d4a4724b2feb53f4e460eade3" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

For more details, see How to Obtain JWT token using a Client ID and Client Secret key.

After obtaining the JWT token, run the following command to convert the STL file to BMP and save it locally.

curl -X GET "https://api.aspose.cloud/v3.0/cad/galeon.stl/saveAs/bmp" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-o Converted.bmp

Conclusion

We demonstrated a straightforward, code‑free way to convert STL files to BMP raster images using Aspose.CAD Cloud. The entire process runs in the cloud, keeping your local system lightweight. All SDK source code is available under the MIT license on GitHub. If you encounter any issues or have questions, visit our free product support forum.

We also recommend visiting the following links to learn about: