Free Support Forum - aspose.com

Converting STL file to PNG file with smooth color/shading

Hi,

Converting STL file to PNG file produces a PNG file with wireframe surface of the front.
Is there a way to convert STL to PNG with smooth or flat surface color or nearly smooth/flat just like the original?

Attached is the original STL and converted PNG.

Original_STL.zip (39.1 KB)
Converted_STL_to_PNG.zip (94.4 KB)

Thanks.

I attached the expected PNG file converted from STL file.
I just screenshot this from original STL.
Expected_PNG_Conversion.zip (19.0 KB)

This is what I want as end result.
Not the lines crisscrossing.

Is this possible?

@franciss

Can you please share the source code that you have used along with API version that you have tried.

@mudassir.fayyaz, thanks for prompt reply…

I just followed the usual demo code for STL to PNG conversion.

Regarding API version, I used Aspose-cad:20.7

AsposeVersion.JPG (16.4 KB)


  void convertStlToPng(File sourceFile, File targetFile) {
    try {
        var image = (CadImage) Image.load(sourceFile.toString());

        // Create an instance of CadRasterizationOptions and set its various properties
        CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();

        rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);
        rasterizationOptions.setPageWidth(1500);
        rasterizationOptions.setPageHeight(1500);
        
        // Create an instance of PngOptions
        PngOptions pngOptions = new PngOptions();

        // Set the VectorRasterizationOptions property
        pngOptions.setVectorRasterizationOptions(rasterizationOptions);
        
        // Export the STL to PNG
        image.save(targetFile.toString(),pngOptions);
    }
    catch (Exception e)
    {
        throw new RuntimeException(e);
    }
}

basically when I convert an STL file to PNG file, the following happens:

  1. Converted PNG file has the STL image but the surface disappeared.
    Only lines crisscrossing.

Question:
Is there a way for the surface to remain when converting STL to PNG or any other image format?

@franciss

Can you please try using the latest version and if the issue is still reproduced then please share the source STL and generated PNG file with us for investigation and resolution on our end.

Hi,

I have tried with the latest version, the issue still happens.
Attached is the source STL and generated PNG file.

Converted_STL_to_PNG.zip (94.4 KB)
Original_STL.zip (39.1 KB)

@franciss

I have created the issue with ID CADNET-8044 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.