We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

The original image is too large, causing the dwg to png image to be completely black

Hi!
If the original image is relatively large, it will be completely black, and the original image is displayed normally if it is small.
code show as below:

PngOptions pngOptions = new PngOptions();
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
pngOptions.setCompressionLevel(9);
int unitType = image.getUnitType();
rasterizationOptions.setUnitType(unitType);
rasterizationOptions.setPageSize(new SizeF(image.getWidth() / 20F, image.getHeight() / 20F));
List showLayerList = image.getLayers().getLayersNames();
showLayerList.remove(“xxx”);
rasterizationOptions.setLayers(showLayerList);
GraphicsOptions graphicsOptions = new GraphicsOptions();
graphicsOptions.setSmoothingMode(1);
rasterizationOptions.setGraphicsOptions(graphicsOptions);
rasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);
pngOptions.setVectorRasterizationOptions(rasterizationOptions);
image.save(targetPath, pngOptions);
result:
image.png (140.3 KB)
linux server:4核 16g
version:21.1
jvm: -Xms4096m -Xmx13000m -Xss1024K -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=1024m

@komorebi

Unfortunately, from the shared image it is not getting evident what is actual image and what is being rendered. Please provide the source file and generated output for comparison. You can also try our free online convertor tool to verify your file output as well. The tool is always current w.r.t latest version of Aspose.CAD for .NET.