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

Free Support Forum - aspose.com

Aspose-imaging jar包LoadOptions类setBufferSizeHint方法耗时很长,并且设置值大小没区别

使用产品: Aspose.Imaging for Java

1.aspose-imaging jar包LoadOptions类设置setBufferSizeHint后耗时很长,转换1.wmf大概要40秒,
2.aspose-imaging jar包LoadOptions类设置setBufferSizeHint为50和500没区别,耗时一样,转
1.wmf为png都要40秒左右
maven如下:

	<dependency>
		<groupId>com.aspose</groupId>
		<artifactId>aspose-imaging</artifactId>
		<version>21.12</version>
		<classifier>jdk16</classifier>
	</dependency>

代码如下:

public static boolean convert(String fromPath, String toPath) {
	LoadOptions options = new LoadOptions();
	options.setBufferSizeHint(500);
	Image image = Image.load(fromPath, options);
	try {			
		VectorRasterizationOptions vectorOption = new VectorRasterizationOptions();
		vectorOption.setPageWidth(image.getWidth());
		vectorOption.setPageHeight(image.getHeight());

		PngOptions pngOptions = new PngOptions();
		pngOptions.setVectorRasterizationOptions(vectorOption);
		//pngOptions.setBufferSizeHint(50);

		image.save(toPath, pngOptions);
		return true;
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		image.dispose();
	}
	return false;
}

1.zip (16.2 KB)

@aaaConvert
在我的电脑上,
未设置 setBufferSizeHint 时
您的代码持续 4.5 秒
当 setBufferSizeHint 设置为 500
您的代码持续 6.5 秒.

这是正常的,当 setBufferSizeHint 由于其分配给内存优化而不是速度优化而减慢操作时。